tags:

views:

71

answers:

1

I tried to make a simple contact form via HTML and PHP but the form doesnt seem to submit. it stays on the HTML page and doesnt post to the php form. would love someone to look over the code, thanks in advanced.

simple_form.html cdoe

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Feedback Form</title>
</head>

<body>

<form action="send_simpleform.php" method="post">
<p>Your name<br />
<input name="sender_name" type="text" size="30" /></p>
<p>Email<br  />
<input name="sender_email" type="text" size="30" /></p>
<p>Message<br />
<textarea name="message" cols="30" rows="5"></textarea></p>
<input name="submit" type="button" value="Send This Form" />
</form>

</body>
</html>

send_simpleform.php code

<?
if (($_POST[sender_name] == "") || ($_POST[sender_email] == "") || ($_POST[message] == "") {
    header("Location: simple_form.php");
    exit;
}

$msg = "Email sent from wwwsite\n";
$msg .= "Sender's Name:\t $_POST[senders_name]\n";
$msg .= "Sender's E-mail:\t $_POST[senders_email]\n";
$msg .= "Sender's Message:\t $_POST[message]\n";
$to = "[email protected]";
$subject = "Website feedback message";
$mailheaders = "From: My web site <www.testwebsite.com>\n";
$mailherders .= "Reply to: $_POST[sender_email]\n";
$mail($to, $subject, $msg, $mailheaders);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Feedback Form Sent</title>
</head>

<body>

<h1>The following email has been sent</h1>

<p>Your Name:<br />
<? echo "$_POST[sender_name]"; ?>
<p>Your Email Adress:<br />
<? echo "$_POST[sender_email]"; ?>
<p>Message:<br />
<? echo "$_POST[message]"; ?>
</p>
</body>
</html>
+5  A: 

maybe instead of

<input name="submit" type="button" value="Send This Form" />

write

<input name="submit" type="submit" value="Send This Form" />
x2
thanks, that did it, the code had some errors in the php script but I managed to work them out. Thanks agian!
Jacksta