Php 联系人表单忽略字段并排除错误
我的联系方式有错误。我不太熟悉PHP,所以这里是我为PHP和HTML编写的代码 HTML:Php 联系人表单忽略字段并排除错误,php,contact-form,Php,Contact Form,我的联系方式有错误。我不太熟悉PHP,所以这里是我为PHP和HTML编写的代码 HTML: <form name="contactform" method="post" action="sendmail.php" align="center"> <table width="450px" id="black2" style="background-color:#fff" align="center"> </tr> <tr> <td v
<form name="contactform" method="post" action="sendmail.php" align="center">
<table width="450px" id="black2" style="background-color:#fff" align="center">
</tr>
<tr>
<td valign="top" id="black2"style="background-color:#fff">
<label for="first_name" >First Name *</label>
</td>
<td valign="top"id="black2">
<input type="text" name="first_name" maxlength="50" size="30" id="black2">
</td>
</tr>
<tr>
<td valign="top"" id="black2">
<label for="last_name" id="black2">Last Name *</label>
</td>
<td valign="top">
<input type="text" name="last_name" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="email">Email Address *</label>
</td>
<td valign="top">
<input type="text" name="email" maxlength="80" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="telephone">Telephone Number</label>
</td>
<td valign="top">
<input type="text" name="telephone" maxlength="30" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="comments">Comments *</label>
</td>
<td valign="top">
<textarea name="comments" maxlength="1000" cols="24" rows="6"></textarea>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<input type="submit" value="Submit">
</td>
</tr>
</table>
名字*
Urlput ob_start();在代码的第一行,只接受5个参数,但你已经给出了7个!在body参数中放入$telephone、$first\u name、$last\u name
。Hi Rohan。非常感谢你。虽然我不知道如何把它放到我需要的上下文中,因为我不知道PHP。我只是从网上的某个地方复制了一个代码,并将其应用到我的网站上。这对其他人也有作用。嗨,罗汉和钱德雷什。我为这样对你道歉。我想收集上述字段的信息。我该如何使用你的代码?@user2261249检查以上我的答案已做了更改。谢谢Rohan!你是个传奇人物!警告:此代码可能是垃圾邮件中继。可能可以使用精心构造的$\u请求['email']
输入,将额外的字段注入到
中,其中包含换行符和额外的标题。
<?php
$first_name = $_REQUEST['email'];
$last_name = $_REQUEST['last_name'];
$email = $_REQUEST['email'];
$telephone = $_REQUEST['telephone'];
$comments = $_REQUEST['comments'];
mail("mail@mywebsite.co.za","Feedback Form Results", $comments, $telephone, $first_name,
$last_name, "From: $email");
header( "Location: http://www.mywebsite.co.za/thankyou.html" );
?>
<?php
$first_name = $_REQUEST['email'];
$last_name = $_REQUEST['last_name'];
$email = $_REQUEST['email'];
$telephone = $_REQUEST['telephone'];
$comments = $_REQUEST['comments'];
// multiple recipients
$to = 'mail@mywebsite.co.za';
// subject
$subject = 'Feedback Form Results';
// message
$message='<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<td>First Name</td><td>'.$first_name.'</td>
</tr>
<tr>
<td>Last Name</td><td>'.$last_name.'</td>
</tr>
<tr>
<td>Telephone</td><td>'.$telephone.'</td>
</tr>
<tr>
<td>Comments</td><td>'.$comments.'</td>
</tr>
</table>
</body>
</html>';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: '.$email."\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>