defektdesigns Posted December 1, 2010 Share Posted December 1, 2010 Hi I am brand new to PHP Freaks and really hope someone can help me out with my php problem. I have a contact form that I am using and all the php and form info is in one file. The contact form worked before but it wasn't correct because one of the names was wrong on the form. Here is the php I have put just below the opening body tag: <?php $name = $_POST["name"]; $email = $_POST["email"]; $subject = $_POST["subject"]; $comment = $_POST["comment"]; $submit = $_POST["submit"]; if(isset($submit)){ $sendTo = "myemail@mydomain.com"; $message = "<h3>To You:</h3> $comment<br /> <br /> From: $name ($email)"; $headers = "From: $name <$email> \r\n"; $headers .= "X-Mailer:PHP/\r\n"; $headers .= "MIME-Version:1.0\r\n"; $headers .= "Content-type:text/html; charset=iso-8859-1\r\n"; $sent = mail($sendTo, $subject, $message, $headers); } ?> and here is the form: <form action="" method="post"> <table> <tr> <td>Name: </td> <td><input type="text" name="name" class="field"/></td> </tr> <tr> <td>Email: </td> <td><input type="text" name="email" class="field" /></td> </tr> <tr> <td>Subject: </td> <td><input type="text" name="subject" class="field"/></td> </tr> <tr> <td>Comment: </td> <td><textarea name="comment" cols="30" rows="8" > </textarea></td> </tr> <tr> <td><input type="submit" name="submit" value="Send" /></td> </tr> </table> </form> <?php if ($sent){ echo "Thank you for your message!"; } ?> now when I had it working I had accidentally had the subject name set to "email" but when I simply change it to "subject" as it should be it won't work anymore. I would love to just let it work the wrong way but this won't work because when I receive the email it displays the subject instead of the persons email and I need to see the email to get back to them. I really hope someone can help me with this! Thanks, Curtis Quote Link to comment Share on other sites More sharing options...
requinix Posted December 1, 2010 Share Posted December 1, 2010 it won't work anymore. You're the only one who knows what that means. How about you explain it to us? Quote Link to comment Share on other sites More sharing options...
princeofpersia Posted December 1, 2010 Share Posted December 1, 2010 well have you tried to instead of <form action="" method="post"> add <form action="yourpage.php" method="post"> ??? your page should do the post action somewhere isnt it?if te process happens on the same page (it means both php and html codes are in the same page) add the page name to your action i hope it helps Quote Link to comment Share on other sites More sharing options...
Rifts Posted December 1, 2010 Share Posted December 1, 2010 he said its posting to the same page Quote Link to comment Share on other sites More sharing options...
defektdesigns Posted December 1, 2010 Author Share Posted December 1, 2010 I'll try my best to explain it. It will work if i simply change <input type="text" name="subject" class="field"/> to <input type="text" name="email" class="field"/> but for some reason if I make it <input type="text" name="subject" class="field"/> it will not work. Yes the php and the html form are in the same file called contact.php Quote Link to comment Share on other sites More sharing options...
requinix Posted December 2, 2010 Share Posted December 2, 2010 Yes, but what does "work" mean? Do you not get the email? Error messages? You get the email but the data is messed up? Quote Link to comment Share on other sites More sharing options...
defektdesigns Posted December 2, 2010 Author Share Posted December 2, 2010 what I mean by it works is that it will send me an email but the email will not show me the email they have entered. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.