使用php表单发送反馈
我想将反馈发送到我的电子邮件地址。我已经编写了以下代码。但当我按下submit时,什么也没发生使用php表单发送反馈,php,html,Php,Html,我想将反馈发送到我的电子邮件地址。我已经编写了以下代码。但当我按下submit时,什么也没发生 <?php $action=$_REQUEST['action']; if ($action=="") { /* display the contact form */ ?> <form method="post" action="" enctype="multipart/form-data"> <input class="inputst" ty
<?php
$action=$_REQUEST['action'];
if ($action=="") {
/* display the contact form */
?>
<form method="post" action="" enctype="multipart/form-data">
<input class="inputst" type="text" placeholder="Your Name" name="s_name"><br>
<input class="inputst" type="email" placeholder="Your Email" name="s_email"><br>
<input class="inputst" type="text" placeholder="Phone Number" name="s_mobile"><br>
<input class="inputst" type="text" placeholder="Delivery Address" name="s_address"><br>
<input class="inputst" name="s_link" type="text" value="http://alutamarket.com/boutique-and-fashion-store/phones-tabs-accessories/samsung-galaxy-note-3_i3" name="productlink"><br>
<div style="margin-top:20px;"><a type="submit" class="im-contac"><span class="im-top">Send Now</span><span class="im-bot">Send inquiry now</span><i class="fa fa-paper-plane"></i></a></div>
</form>
<?php
} else {
/* send the submitted data */
$name=$_REQUEST['s_name'];
$email=$_REQUEST['s_email'];
$mobile=$_REQUEST['s_mobile'];
$address=$_REQUEST['s_address'];
$message=$_REQUEST['s_link'];
if (($name=="")||($email=="")||($mobile=="")||($address=="")||($message=="")) {
echo "All fields are required, please fill <a href=\"\">the form</a> again.";
} else {
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Message sent using your contact form";
mail("myemail@gmail.com", $subject, $message, $from);
echo "Email sent!";
}
}
?>
再一次。”;
}否则{
$from=“from:$name\r\n返回路径:$email”;
$subject=“使用您的联系方式发送的邮件”;
邮件(“myemail@gmail.com“,$subject,$message,$from);
回显“已发送电子邮件!”;
}
}
?>
我还想向发件人发送一份副本电子邮件。需要更改 1)创建提交到提交表单 2)检查是否设置了“提交”按钮 试试这个
<?php
if(isset($_POST['submit'])) {
$name=$_POST['s_name'];
$email=$_POST['s_email'];
$mobile=$_POST['s_mobile'];
$address=$_POST['s_address'];
$message=$_POST['s_link'];
if (($name=="")||($email=="")||($mobile=="")||($address=="")||($message=="")) {
echo "All fields are required, please fill <a href=\"\">the form</a> again.";
} else {
$from="From: $name<$email>\r\nReturn-path: $email";
$subject="Message sent using your contact form";
mail("myemail@gmail.com", $subject, $message, $from);
echo "Email sent!";
}
}
?>
<?php
$action=$_REQUEST['action'];
if ($action=="") {
/* display the contact form */
?>
<form method="post" action="" enctype="multipart/form-data">
<input class="inputst" type="text" placeholder="Your Name" name="s_name"><br>
<input class="inputst" type="email" placeholder="Your Email" name="s_email"><br>
<input class="inputst" type="text" placeholder="Phone Number" name="s_mobile"><br>
<input class="inputst" type="text" placeholder="Delivery Address" name="s_address"><br>
<input class="inputst" name="s_link" type="text" value="http://alutamarket.com/boutique-and-fashion-store/phones-tabs-accessories/samsung-galaxy-note-3_i3" name="productlink"><br>
<div style="margin-top:20px;"><button type="submit" name="submit" class="im-contac"><span class="im-top">Send Now</span><span class="im-bot">Send inquiry now</span><i class="fa fa-paper-plane"></i></button></div>
</form>
<?php
}
?>
立即发送立即发送询价