开发者

HTML and PHP simple contact form

开发者 https://www.devze.com 2022-12-27 12:17 出处:网络
I tried to make a simple contact form via HTML and PHP but the form doesn\'t seem to submit. it stays on the HTML page and doesn\'t post to the php form.

I tried to make a simple contact form via HTML and PHP but the form doesn't seem to submit. it stays on the HTML page and doesn't post to the php form.

simple_form.html code

    <!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 = "jack@xxxxxxx.com.au";
$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 ht开发者_运维知识库ml 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>


maybe instead of

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

write

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号