我在index.php
中加入了我的联系表格 index.php中的
left.php代码是
html代码
<form action="" enctype="multipart/form-data" method="post">
<div align="left">
<table border="0" cellpadding="0" cellspacing="0" hspace="0" vspace="0" width="100%">
<tbody>
<tr>
<td class="fth" height="20" valign="middle"></td>
</tr>
<tr>
<td class="ft">* Name:</td>
</tr>
<tr>
<td class="ft"><input name="author" id="name" class="text" required="true" valtype="name" type="text" maxlength="25" placeholder="Enter Your Full Name" pattern="^[a-zA-Z -]+$"></td>
</tr>
<tr>
<td class="ft">* Phone:</td>
</tr>
<tr>
<td align="left" valign="top" class="ft">
<input name="mobile" id="phone" class="text" size="20" valtype="phmob" required="true" type="text" maxlength="12" placeholder="Enter 10 Digit Mobile Number" pattern="[789][0-9]{9}">
<span class="style3">eg : 9795042637</span></td>
</tr>
<tr>
<td class="ft">* E-mail:</td>
</tr>
<tr>
<td class="ft">
<input name="email" id="email" class="text" valtype="email" required="true" type="text" maxlength="55" pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$" placeholder="Enter Your Email Address">
</td>
</tr>
<tr>
<td class="ft">*Write your message:</td>
</tr>
<tr>
<td class="ft">
<textarea name="msg" id="msg" cols="25" rows="3" class="text" valtype="msg" nameinerr="Message" required="true" onkeypress="return preventCopy.disableCtrlKeyCombination(event, this);" onkeydown="return preventCopy.disableCtrlKeyCombination(event, this);" oncontextmenu="return false;" onmousedown="return preventCopy.rightClick(event,this);"></textarea>
</td>
</tr>
<tr>
<td class="ft">
<label for="home_loan"><input id="home_loan" class="home_loan" name="home_loan" value="Yes" type="checkbox">I am interested in Home Loan</label>
</td>
</tr>
<tr>
<td class="ft" height="45">
<br>
<input class="submit" value="Send" type="submit" name="button">
<input class="submit" type="reset" name="reset" id="reset" value="Reset" />
</td>
</tr>
</tbody></table>
</div>
同一文件中的php代码
if(isset($_POST['button']))
{
ob_start();
$name=$_POST['author'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$msg=$_POST['msg'];
$home_loan=$_POST['home_loan'];
$to ='mysite@gmail.com';
//$to ='info@mysite.in';
$subject = 'Enquiry Through mysite HomePage';
$message ="
Name = $name\r\n
E-mail = $email\r\n
Mobile = $mobile\r\n
Message = $msg\r\n
Home loan = $home_loan";
$headers = "From: $name < $email >" . "\r\n" .
"CC:mysite@gmail.com";
$sendmail = mail($to,$subject,$message,$headers,"-from@mysite.com");
if($sendmail)
{
//header("location:thanks.html");
echo "<h4 style='text-align:center;color:red;'>Your enquiry has been sent.</h4>";
}
else
{
header("location:index.php");
}
}
运行mysite.com/left.php
时工作正常但是当我使用in include时它不提交查询哪里错了帮助我 谢谢
答案 0 :(得分:0)
尝试更改您的表单声明:
<form action="" enctype="multipart/form-data" method="post">
到此:
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" enctype="multipart/form-data" method="post">
答案 1 :(得分:0)
将php代码移动到index.php的顶部。你应该在输出任何东西之前做事。如果index.php在运行之前输出任何内容,则会失败。