PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 1st, 2004, 08:53 AM
univinus univinus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 22 univinus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 48 sec
Reputation Power: 0
problems with working page on a different webserver

hi all.

I've just created a mailing list sign up for my client's webpage using php, the page seems to work fine on my own server where I test the pages, but when I upload it to the clients server, the page appears correctly but with this ugly error message at the top of the page:

Warning: Undefined variable: submit in d:\websites\virtualwebs\augustine.org.au\augunite\ side.php on line 10

i actually renamed the variable $submit after the original variable $_POST gave the same error. Here is my code:
Code:
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="menucss.css" />
</head>
<body bgcolor="#003399">
<?php

        // Handle POST method.
        if ($submit)
        {
            $emailaddress = $_POST['emailaddress'];
     
            $message = "This person wishes to $choice: $emailaddress";

            // Send message to recipient
            mail("email address", "New mailing list email address", $message);
        }
?>
<center>
	<a href="main.html" target="main" title="Back Home"><img src="flower.gif" align="middle" border="0"></a><br>
</center>
<p></p>
<p><a href="weekly.html" target="main">Programs</a><br>
<a href="special.html" target ="main">Special Events</a> - NEW!<br>
<a href="sat.html" target="main">Saturday Breakfast</a><br>
<a href="sun.html" target="main">Ritual Celebrations</a><br>
<a href="cont.html" target="main">Contemplation Path</a><br>
<a href="enrol.html" target="main">Enrollment</a><br>
<br>
<a href="about.html" target="main">About Us</a><br>
<a href="other.html" target="main">Other Services</a><br>
<a href="contmusic/contmusic.htm" target="main">Contemplative Music</a></p>
<p>Enter your email address to join our Mailing List:<br />
<form method="POST" action="<?php echo $PHP_SELF ?>">
<input type="text" name="emailaddress" /><br />
<p><input type="radio" name="choice" value="subscribe" checked="checked" />Subscribe<br />
<input type="radio" name="choice" value="unsubscribe" />Unsubscribe</p>
<p><input type="submit" name="submit" value="Submit" /> </p>
</form>
</body>
</html>



The exact same code has been posted on my own web hosting service and on my clients. But my hosting service doesn't give that error.

The page on my server: http://www.univinus.com/side.php
The page on client's server: http://www.augustine.org.au/augunite/side.php

I'm confused. What's even more bizarre is that the script seems to work despite the error message on the top of the screen. An email is successfully sent to me although the email address isn't included, so some error obviously has occured. Oh, and when I tried submitting it on the error page, the error messaged changed to: Warning: Undefined variable: _POST in d:\websites\virtualwebs\augustine.org.au\augunite\ side.php on line 12

Does this mean that the PHP on my client's server isn't up to scratch? Or is something wrong with my code? If it's my code, then why did it work on my server but not theirs?

All help is greatly appreciated

~magda~

Reply With Quote
  #2  
Old October 1st, 2004, 02:18 PM
xlordt xlordt is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: 127.0.0.1
Posts: 20 xlordt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 39 sec
Reputation Power: 0
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt
in php.ini change your error level to
Code:
error_reporting = E_ALL & ~E_NOTICE

Reply With Quote
  #3  
Old October 1st, 2004, 11:20 PM
univinus univinus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 22 univinus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 48 sec
Reputation Power: 0
um, i haven't written a php.ini file before, and there isn't one on my server. this isn't a server i built, it's a webhosting service i pay for. do i have access to the php.ini if that's the case? can anyone point me in the direction of a good beginner's guide to the php.ini?

thanks again in advance

~magda~

Reply With Quote
  #4  
Old October 2nd, 2004, 12:18 AM
univinus univinus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 22 univinus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 48 sec
Reputation Power: 0
I tried adding that php file to the directory where this page was, and it succeeded in getting rid of the error message, but when an email address is submitted, the page appears with a *new* error message saying that an unknown error occured on line 16, which is the mail() function.

the email address that was submitted also didn't get delivered in the email, only the rest of the message.

after doing a bit of googling, i tried using (empty($var)) but that only worked fot the $submit and $_POST variables but not $choice - which is on the error line 16.

when an email address is submitted now, then the empty() turns up as the email address - so something seems to be wrong with $choice but for the life of me I can't think what.

this is really confusing, how come it can't see these variables are the names from the form?

maybe i should give up on php and use a cgi thingy.

please help!

~magda~

Reply With Quote
  #5  
Old October 14th, 2004, 06:01 AM
Buster77 Buster77 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 28 Buster77 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hmmm.. I realize that this is a bit late for a reply, but I recently have had a few struggles with this same sort of thing.

Your
if ($submit)
{

statement should really be

if (isset($_POST['submit'])
{

since submit is passed through the post method. The reason you would be getting the warning is that when you make the first pass through the page, there is no variable $submit, hence you need to check for it with isset(). Of course, on the second time through, $submit is not set either, since it is merely part of the $_POST array, so that is probably why you are getting your incorrect program behavior (I didn't really read through all the code, just skimmed it). If you want a variable named $submit, you will have to set it so:

$submit = $_POST['submit']; (after checking that $_POST['submit'] is set, of course.)

One thing that really helped me was getting a good debugging function that outputs the variable arrays (like $_GET, $_POST, $_SESSION, etc.). I can't post the one I have here since it is not mine, but I would imagine you could find one on the web fairly easily...

Hope this helps,

Reply With Quote
  #6  
Old October 17th, 2004, 03:19 PM
m3rajk m3rajk is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 24 m3rajk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
still late, but this could help if you're still trying to do this.

first off you should really let he page know it will use php athe very begining. so i kinda rearranged to make use of php's heredoc type of output. i've also done some splitting. so that you can an include file that can help you (make this look a little more modular, since that is always helpful)
new include file:
PHP Code:
<?php
 
 funcion startPage
($css){
     echo <<< END
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
 <head>
 <title></title>
 <link rel="stylesheet" type="text/css" href="$css.css" />
 </head>
 
 END;
 
}
 
 function endpage()
{ # ends all your pages
     echo <<<END
 </body>
 </html>
 END;
 
}
 ?>
this way you can start all your pages with the css schema you would like to use. also, you should move the bgcolor to css.
PHP Code:
<?php
     
include('./../includes/includefile.php'); # that new include file in a non-web browsable dir
 
     
startPage('menucss'); #start your page
     
echo '<body bgcolor="#003399">'#
 
         // Handle POST method.
         
if ($_POST['submit']) # look for the post submit variable if it's not set you will get null. normally i make it contain a value of 1 when set
         
{
 
             
$message "This person wishes to {$_POST['choice']}: {$_POST['emailaddress']}"# this assumes that the post variable used for the $choice was named choice. with register globals off (security dictates it should be) you need to use $_request or whichever global it would be in, it is safer to use the global than $_request. if you would like an explanation as to why i shall be happy to give it
 
             // Send message to recipient
             
mail($major_domo_admin"New mailing list email address"$message); # mail takes a min of 3 arguments : to address, subject, message. you have no @ in your address, so....
         
}
 
     echo <<<END
 <center>
     <a href="main.html" target="main" title="Back Home"><img src="flower.gif" align="middle" border="0"></a><br>
 </center>
 <p></p>
 <p><a href="weekly.html" target="main">Programs</a><br>
 <a href="special.html" target ="main">Special Events</a> - NEW!<br>
 <a href="sat.html" target="main">Saturday Breakfast</a><br>
 <a href="sun.html" target="main">Ritual Celebrations</a><br>
 <a href="cont.html" target="main">Contemplation Path</a><br>
 <a href="enrol.html" target="main">Enrollment</a><br>
 <br>
 <a href="about.html" target="main">About Us</a><br>
 <a href="other.html" target="main">Other Services</a><br>
 <a href="contmusic/contmusic.htm" target="main">Contemplative Music</a></p>
 <p>Enter your email address to join our Mailing List:<br />
 <form method="POST" action="<?php echo $PHP_SELF ?>">
 <input type="text" name="emailaddress" /><br />
 <p><input type="radio" name="choice" value="subscribe" checked="checked" />Subscribe<br />
 <input type="radio" name="choice" value="unsubscribe" />Unsubscribe</p>
 <p><input type="submit" name="submit" value="Submit" /> </p>
 </form>
 
 END;
 
     endpage();
 ?>

Reply With Quote
  #7  
Old November 8th, 2004, 01:44 AM
univinus univinus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 22 univinus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 48 sec
Reputation Power: 0
ok, so the warnings have gone....

quite a while since i got back to this, sorry for reviving an old thread. I used buster77's advice and changed my code to what's below. and it worked to get rid of the warnings on the troublesome server but the email that should be sent on 'submit' doesn't. once again, this seems to be a problem with this server because it works just fine on my server.

if it's any clue, the troublesome server runs php 4.04

anyway, if anyone can give some clue as to what i can do, it'll be appreciated

~magda~

Code:
<html>
<head>
<title>The Title</title>
<link rel="stylesheet" type="text/css" href="menucss.css" />
</head>
<body>
<?php

        // Handle POST method.
        if (isset($_POST['submit']))
        {
		$submit = $_POST['submit'];
            $emailaddress = $_POST['emailaddress'];
     
            $message = "This person wishes to $choice: $emailaddress";

            // Send message to recipient
            mail("address@email.com", "New mailing list email address", $message);
        }
?>
<center>
	<a href="main.html" target="main" title="Back Home"><img src="flower.gif" align="middle" border="0"></a><br>
</center>
<p></p>
<p><a href="weekly.html" target="main">Programs</a><br>
<a href="special.html" target ="main">Special Events</a> - NEW!<br>
<a href="sat.html" target="main">Saturday Breakfast</a><br>
<a href="sun.html" target="main">Ritual Celebrations</a><br>
<a href="cont.html" target="main">Contemplation Path</a><br>
<a href="enrol.html" target="main">Enrollment</a><br>
<br>
<a href="about.html" target="main">About Us</a><br>
<a href="other.html" target="main">Other Services</a><br>
<a href="contmusic/contmusic.htm" target="main">Contemplative Music</a></p>
<p>Enter your email address to join our Mailing List:<br />
<form method="POST" action="<?php echo $PHP_SELF ?>">
<input type="text" name="emailaddress" /><br />
<p><input type="radio" name="choice" value="subscribe" checked="checked" />Subscribe<br />
<input type="radio" name="choice" value="unsubscribe" />Unsubscribe</p>
<p><input type="submit" name="submit" value="Submit" /> </p>
</form>
</body>
</html>

Reply With Quote
  #8  
Old November 8th, 2004, 03:20 AM
univinus univinus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 22 univinus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 48 sec
Reputation Power: 0
i just tried another php email form script that's completely different from the one i posted and was taken straight from a php tute. and the same problem of not getting mail is happening.

so for now i am going to assume it's a problem with the mailing program on the servers php install.

i will update you allon the situation as it changes

Reply With Quote
  #9  
Old November 8th, 2004, 04:02 AM
Buster77 Buster77 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 28 Buster77 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Not that this has anything to do with the actual mailing problem, since I really don't understand all that much about email proggies, but I still think it's weird that you get the right value for $choice (or do you?), since you never assign it within the POST section, like so:

$choice = $_POST['choice'];

Unfortunately, I don't think that has anything whatsoever to do with the problem of sending the actual email. I'm sorry I am not able to help you with that...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > problems with working page on a different webserver


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT