|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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~ |
|
#2
|
|||
|
|||
|
in php.ini change your error level to
Code:
error_reporting = E_ALL & ~E_NOTICE |
|
#3
|
|||
|
|||
|
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~ |
|
#4
|
|||
|
|||
|
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~ |
|
#5
|
|||
|
|||
|
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, |
|
#6
|
|||
|
|||
|
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 Code:
|
|
#7
|
|||
|
|||
|
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>
|
|
#8
|
|||
|
|||
|
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 |
|
#9
|
|||
|
|||
|
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... |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > problems with working page on a different webserver |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|