Page 1 of 1

php processor does not seem to work: mail form??

Posted: Wed May 21, 2008 10:51 am
by josh22x
I am trying to write a simple mail form, but when ever the script is processed, nothing is returned, no errors or anything. Is something wrong with my PHP processor or something??

Here is the form and script:

Code: Select all

<form action="mailprocessor.php" method="post">
     
<fieldset class = "fieldset1">
<legend class = "legend">Contact Form</legend>
 
<dt class = "dt">Name</dt>
 
<dd><input class = "text_area" type="text" name="name" maxlength="20" size="20"></dd>
 
<dt class = "dt">Email:</dt>
 
<dd><input class = "text_area" type="text" name="email" maxlength="20" size="20"></dd>
 
<dt class = "dt">Text:</dt>
 
<dd><textarea class = "text_area" name="comments" font-size= 18px" cols = "40" rows = "5">
</textarea></dd>
 
<dd><input class = "text_area" type="submit" value="Register" name="submit"></dd>
 
</fieldset>
</div>
</form>
PHP script:

Code: Select all

<?php
 $name=$_POST['name'];
  $email=$_POST['email'];
  $comments=$_POST['comments'];
  $submit=$_POST['submit'];
  
$to = 'josh22x@gmail.com';
$subject = '$name . "Commented on your Blogging site" . "<br>" . "His email address is:" . $email . 
"He had this to say:" . $comments';
 
$message = 'Comment from viewer';
 
if(isset($name, $email, $comments)) 
{
$sent = mail($to, $subject, $message);
}
else 
{
echo 'Please fill out all of the fields';
}
exit;
 
if($sent)
{
echo 'Mail sent successfully';
}
else
{ 
echo 'Mail Error';
}
?>
 
I believe the script should work - do you know what is wrong?
What perplexes me, is that no errors are returned and no echo statements are produced either.

Re: php processor does not seem to work: mail form??

Posted: Wed May 21, 2008 4:27 pm
by Jade
Are you redirecting to the correct page? Have you tried putting an echo statement outside of the if statements?

Re: php processor does not seem to work: mail form??

Posted: Wed May 21, 2008 9:35 pm
by nowaydown1
I would follow Jade's troubleshooting steps. The reason you don't see your messages about mail being sent or not sent is because you have an exit outside any conditionals on line 21. Script execution ends before your if($sent) check ever happens. Hope that helps.

Also, make sure you have something installed to send mail. There have been times when I forgot to install postfix and sat around scratching my head for a minute.