Help - Search - Members - Calendar
Full Version: Problem With Forms
HTMLHelp Forums > Programming > Server-side Scripting
newwebdesigner
Hi guys,
So I have been struggling with HTML forms again, and I don't know what is wrong. I don't really know much about PHP but I am trying to learn. I have been having this problem for a few months now, not with this form, but handling forms in general. Thanks in advance for your responces. I took my email out of the following code for safety reasons:
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Basic Form</title>
</head>
<Body>
<form method="post" name="Basicform" action="handle.php">
Enter Name:<input type="text" name="name">
Enter Email:<input type="Text" name="email">
Enter Message:<textarea name="message"></textarea>
<input type="submit" value="Send Form"
</body>
</html>

Here is handle.php:
<?php
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];


$email_from = 'emailwouldgohere';

$email_subject = "New Form submission";

$email_body = "You have received a new message from the user $name.\n".
"Here is the message:\n $message".


$to = "Emailwouldgohere";

$headers = "From: $email_from \r\n";

$headers .= "Reply-To: $visitor_email \r\n";

mail($to,$email_subject,$email_body,$headers);

?>
CharlesEF
You did not say what the problem is. I can see a couple of small errors so lets try that first:
CODE
<input type="submit" value="Send Form"
is missing the closing > character.
Also, $email_body is missing the ending ; character and I'm not sure why you have an ending . there (the first period is to join the 2 sentences, I assume).
Christian J
Also the </form> end tag is missing.
CharlesEF
QUOTE(Christian J @ Aug 15 2014, 05:20 PM) *

Also the </form> end tag is missing.
I missed that one. sad.gif
newwebdesigner
SO you guys think if I fix those small things it will work perfectly?
Christian J
There could be other problems too, but start with fixing the above.
newwebdesigner
I fixed those things, but it is still asking me if I want to save handle.php(the script)
CharlesEF
Are you sure you have PHP installed? I have seen the save action before, on computers without PHP.
newwebdesigner
Ah you are right. Like I said- I am new to php, and for some reason I did not come across that I needed to install something. I will install apache, and PHP and see if it works, thanks for all the help guys . biggrin.gif
newwebdesigner
So I decided on webmatrix 3, and I dunno if it is a glitch or something but when I fill out the form and push enter I get a 404 error.That is normal because I do not have a redirect set up, but when I go check the email I am using this for, it doesn't show up, I have checked spam folder and everything, and suggestions?
CharlesEF
Without seeing any code all I can do is guess. Post some code.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.