HTML and PHP simple contact form.

Posted by user317128 on Stack Overflow See other posts from Stack Overflow or by user317128
Published on 2010-04-15T04:35:23Z Indexed on 2010/04/15 4:43 UTC
Read the original article Hit count: 445

Filed under:
|
|

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">
<html xmlns="http://www.w3.org/1999/xhtml">
<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">
<html xmlns="http://www.w3.org/1999/xhtml">
<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>

© Stack Overflow or respective owner

Related posts about html

Related posts about php