dongxiangqian1855 2017-01-17 04:32
浏览 26
已采纳

使用php表单发送反馈[复制]

This question already has an answer here:

I want to send Feedback from from to my email address. I have write following code. But when I press submit nothing happen.

<?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>
Return-path: $email";
        $subject="Message sent using your contact form";
        mail("myemail@gmail.com", $subject, $message, $from);
        echo "Email sent!";
    }
}  
?>

I want to send one copy email to sender also.

</div>
  • 写回答

1条回答 默认 最新

  • doufenpaiyu63706 2017-01-17 04:36
    关注

    Changes Required

    1) create a submit to submit form

    2) check isset that submit button is clicked or not

    Try This

    <?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>
    Return-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 
    }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler