Saturday, April 16, 2011

Simple web form not working

I have created simplest of web forms.

purpose- visitors will enter their name and email address and comment and hit send, I will receive that comment in my email inbox and visitor will see a conformation page.

result- I receive an email everytime, but it doesn't show visitor's email address, name or the comment that they enter.

I assigned a veriable for each of them and set up $msg to show all these. The mail comes from some undefined@gator1064.hostgator.com and I found an error message that says something like: "[15-Apr-2011 02:29:33] PHP Parse error: syntax error, unexpected T_ECHO in... (bla bla bla)... on line 13". Line 13 is the mail() command so the problem probably is with $msg, which is the line before.

There is no sign of any confirmation page either.

My research shows that the problem is I am missing a (") or "}" or something similar. My php is not finding it, instead seeing the end of php (?>). Triple checked but can't see anything missing.

I have added the contact.php and html form page below.

Let me know if you need more information.

Thanks for taking a look guys.


Html Form-

<form action="contact.php" method="post" id="contactform">
<ol>
<li><label for="firstname">Name</label><br/>
<input name="firstname" type="text" /></li><br/>
<li><label for="email">Email</label><br/>
<input name="email" type="text" /></li><br/>
<li><label for="comment">Comment</label><br/>
<textarea row="6" cols="50" name="comment"></textarea></li><br/>
<input value="send" type="submit" />
</ol>
</form>


PHP script-


<html>
<head>
<title>this was a try</title>
</head>
<body>

<?php
$name = $_POST['firstname'];
$email = $_POST['email'];
$comment = $_POST['comment'];


$to = 'myemail@yahoo.com';
$subject = 'test';
$msg = "$name sent you a message from $email and said $comment";


mail($to, $subject, $msg, 'From:' . $email);


echo 'Thanks for you comment.<br/>';
echo 'Your message has been sent from' . $email . '<br/>';
echo 'We will get back to you with in 48 hours or less.';
?>
</body>
</html>
***end of codes***
The only difference is that I replaced "myemail@yahoo.com" with a real email adress

3 comments:

  1. Hello, i have seen your problem at odesk site, i can resolved your problem, if you need then contact me on
    skype : umesh1787
    gmail : umesh1787@gmail.com

    ReplyDelete
  2. I can resolve the issue for you...
    mail: abhishek@myphpscriptz.com
    gtalk : abhicyco

    ReplyDelete
  3. some minor modification required in this. this is simple job i can fix this in couple of minutes. please drop an email to me. I will help you on this. I don't think you have to pay for this.

    bisusubedi
    subedibisu@gmail.com

    ReplyDelete