基本的なフォームは先生から提供されたものですが、私の場合は「次のエラーを修正してください: 名前を入力してください!」というメッセージが返ってきます。送信をクリックしたとき。私のウェブサイトの他のすべては正常に機能していますが、このフォームは私の髪を引っ張っています! どんな助けでも大歓迎です。(フォームのfake@fake.comは本アドレスに変更しました)
<?php
/* Set e-mail recipient */
$myemail = "Fake@fake.com";
$subject = "Order Form - B Bakery";
$name = check_input($_POST['name'],"Enter your name you tit!");
$Email = check_input($_POST['Email'],"Enter your email you tit!");
$Phone = check_input($_POST['Phone']);
$Message = check_input($_POST['Message'],"Enter your message you tit!");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}
/* Let's prepare the message for the e-mail */
$message = "Hello!
Your contact form has been submitted by:
Name: $name
E-mail: $Email
Phone: $Phone
Message:
$Message
End of message
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
header('Location: thankyou.html');
exit();
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
exit();
}
?>
HTML:
<!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>Order Form</title>
<style type="text/css">
#wrapper #ddffdd {
position: absolute;
height: 500px;
width: 929px;
left: 385px;
top: 230px;
background: #FFF;
}
body {
background-image: url(Pics/pink-floral-background.jpg);
background-repeat;
}
#wrapper {
width: 1000px;
margin: 0 auto;
height: 500px;
}
#menu ul li {
list-style-type: none;
display: inline;
height: auto;
padding-left: 17px;
border-right-width: thin;
border-left-width: thin;
border-top-style: none;
border-right-style: solid;
border-left-style: none;
border-right-color: #000;
border-left-color: #000;
border-top-width: thin;
border-bottom-width: thin;
border-bottom-style: none;
border-top-color: #000;
border-bottom-color: #000;
padding-right: 17px;
}
#menu ul {
position: absolute;
left: 399px;
top: 1px;
width: 737px;
}
#menu {
height: 27px;
width: 764px;
position: absolute;
left: 29px;
top: 170px;
}
#HomeText {
position: absolute;
left: 305px;
top: 9px;
width: 520px;
alignment: absolute;
height: 53px;
font-size: 36px;
font-family: "Comic Sans MS", cursive;
}
#cakepic {
position: absolute;
left: 3px;
top: 24px;
width: 200px;
height: 200px;
}
#HomeText2 {
position: absolute;
left: 47px;
top: 91px;
width: 192px;
alignment: absolute;
font-family: "Comic Sans MS", cursive;
height: 385px;
}
#HomeText3 {
position: absolute;
left: 478px;
top: 91px;
width: 192px;
alignment: absolute;
font-family: "Comic Sans MS", cursive;
height: 385px;
}
#Banner{
height: 90px;
width: 800px;
position: absolute;
top: 75px;
left: 325px;
}
#Banner #Bannertop {
position: absolute;
left: 237px;
top: -34px;
}
#Banner #Bannerbottom img {
position: absolute;
left: 381px;
top: 57px;
}
#wrapper #Banner div form table tr td {
text-align: right;
}
#wrapper #Banner div form table {
text-align: left;
}
#wrapper #ddffdd form table {
position: absolute;
left: 11px;
top: 124px;
width: 901px;
}
</style>
<script type="text/javascript">
function MM_validateForm() { //v4.0
if (document.getElementById){
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
} }
</script>
</head>
<body>
<div id="wrapper">
<div class=header></div>
<div id="menu">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="FAQ.html">FAQ</a></li>
<li><a href="Order Form.html">Contact</a></li>
<li><a href="Latest News.html">Latest News</li>
<li><a href="Product List.html">Product List</a></li>
</ul>
</div>
<p></p>
<div id="Banner">
<p>
<div id="Bannertop"> <img src="coollogo_com-201093071.png" width="409" height="83" /></div></p>
<p>
<div id="Bannerbottom"><img src="coollogo_com-200791182.png" width="406" height="34" />
</div>
<div>
</div>
</div>
<div id="ddffdd">
<div id=HomeText>Contact</div>
<form action="myform.php" method="get">
<table width="99%" border="1">
<tr>
<td width="33%" onfocus="MM_validateForm('name','','R','Phone','','RisNum','Email','','RisEmail');return document.MM_returnValue"><label for="name">
<div align="right" onfocus="MM_validateForm('name','','R','Phone','','RisNum','Email','','RisEmail','Message','','R');return document.MM_returnValue">Name</div>
</label> </td>
<td width="67%"><div align="left">
<input name="name" type="text" id="name" size="36" />
</div></td>
</tr>
<tr>
<td><label for="Phone">
<div align="right">Phone Number</div>
</label>
<label for="Email">
<div align="right">Email</div>
</label></td>
<td><div align="left">
<input type="text" name="Phone" id="Phone" />
</div>
<input type="text" name="Email" id="Email" /></td>
</tr>
<tr>
<td><div align="right">Message</div></td>
<td><div align="left">
<textarea name="Message" id="Message" cols="60" rows="5"></textarea>
</div></td>
</tr>
<tr>
<td><div align="right">
<input type="reset" name="Reset2" id="Reset2" value="Reset" />
</div></td>
<td><div align="left">
<input name="Reset" type="submit" id="Reset" onclick="MM_validateForm('name','','R','Phone','','RisNum','Email','','RisEmail');return document.MM_returnValue" value="Submit" />
</div></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><div align="right"></div></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
メールを受け取りました :D が、その後、私のウェブホスト 404 に送られ、私のサンキュー ページには送られません。どうもありがとうございました!
IT IS WORKING :DDDDDDDDDD 皆様、どうもありがとうございました。