联系表格不起作用 [英] Contact Form Not Working

查看:97
本文介绍了联系表格不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,

我正在处理我的网站的联系表格(我正在设计不同的表格),这是一个托儿所,我似乎无法得到表单与php连接,以便让它向用户发送验证,发送给我一份副本,并将其记录在csv中。



这是html页面上的表单:



Hey guys,
I am working on my contact form for a site of mine (i am designing the form differently) that is for a child care, and I can't seem to get the form to connect with the php in order to get it to send verification to the user, send me a copy, and record it within a csv.

Here is the html form that goes on the page:

<form action="#" class="footer-form" action="contact.php">
    <p class="title">Feel free to write some words</p>

    <div class="form-group">
        
            <input type="text" class="form-control" id="contactname" id="contact-name" placeholder="Your Name:">
        
    </div>
    <div class="form-group">
        
            <input type="email" class="form-control" id="contactemail" id="contact-email" placeholder="Your E-mail:">
        
    </div>
    <div class="form-group">
        
            <input type="phone" class="form-control" id="contactphone" id="contact-phone" placeholder="Your Phone Number:">
        
    </div>
    <div class="form-group">
         
            <input type="child_info" class="form-control" id="child_info" id="contact-text" placeholder="Information About Child:">
        
    </div>
    <div class="form-group" style="border-removed 1px solid #e5e5e5;">
        Child's Gender:
        
            <input type="radio" id="maLe" name="male" value="male"> Male
        
        
            <input type="radio" id="female" name="female" value="female"> Female
        
    </div>
    <div class="form-group">
         
            <input type="age" id="age" class="form-control" id="contact-text" placeholder="Age of Child:">
        
    </div>
    <div class="form-group" style="border-removed 1px solid #e5e5e5;">
        Does Your Child Have Special Needs: 
        
            <input id="yes"" type="radio" name="yes" value="yes">Yes
        
        
            <input id="no" type="radio" name="no" value="no"> No
        
    </div>
    <div class="form-group">
         
            <input type="comment" class="form-control" id="message" id="contact-text" placeholder="Comments about service or if you want to add another child, write here:">
        
    </div>
    <button type="submit" class="btn btn-default waves-effect waves-button waves-float waves-classic">Submit</button>
</form>





和php是这样的:



and php is this:

<?php 
        $contactname = $_POST["contact-name"];
        $contactemail = $_POST["contact-email"];
        $contactphone = $_POST["contact-phone"];
        $child_info = $_POST["child_info"];
        $gender = $_POST["gender"];
        $age = $_POST["age"];
        $specialneeds = $_POST["specialneeds"];   
        $message = $_POST["message"];
        $to      = 'yahoo@gmail.com';
        $subject = 'Contact Form Submission!';
    
        $v1 = "
                <html> <body> <style>
                    h1 {color:#000066;}
                    table {border:1px solid black; background: #e3f0ff;}
                </style> <h1>Hello, this form has been submitted!</h1> <img src= 'logo1.png' /> <table rules='all' style='border-color: #ffb300;' cellpadding='10' width='500px'> <tr style='background: #ffb300;'><td>First Name: $name</td> <tr style='background: #fafafa;'><td>Email: $email</td> <tr style='background: #fafafa;'><td>Phone: $phone</td> <tr style='background: #fafafa;'><td>Child Gender: $gender</td> <tr style='background: #fafafa;'><td>Child's Age:: $age </td> <tr style='background: #fafafa;'><td>Child with Special Needs: $specialneeds</td> <tr style='background: #fafafa;'><td>More Information: $message</td> </table> </body> </html> ";
        $message = $v1; 
        $headers  = "From: $from\r\n"; 
        $headers .= "Content-type: text/html\r\n"; 
        mail($to, $subject, $message, $headers); 
        echo "Message has been sent..."; //Page RE DIRECT 
        echo $v1;
    //******************************************************************************************************************************//
    
        $contactname = $_POST["contact-name"];
        $contactemail = $_POST["contact-email"];
        $contactphone = $_POST["contact-phone"];
        $child_info = $_POST["child_info"];
        $gender = $_POST["gender"];
        $age = $_POST["age"];
        $specialneeds = $_POST["specialneeds"];   
        $message = $_POST["message"];
        $subject = 'Message Confirmed!';
        $v1 = "
                <html> <body> <style>
                    #disclosure {font-size: 8px; color: #333;}
                    h1 {color:#000066;}
                    table {border:1px solid black;}
                </style> <img src= 'logo1.png' /> <table rules='all' style='border-color: #ffb300;' cellpadding='10' width='500px'> <tr style='background: #ffb300;'><td>Email Confirmation <tr style='background: #fafafa;'><td>Hello  $name, your message has been recieved! We will contact you shortly! <br><br>Best, <br>M<br>©M(TM) All Rights Reserved 2015 </div> </table> </body> </html> ";
        $headers  = "From: $from\r\n"; 
        $headers .= "Content-type: text/html\r\n"; 
         mail($email, $subject, $message, $headers);    
    
          $count= count(file("main_form.csv"));                       
            $today = date("d M Y h:i A");
            echo $today;
            echo $v1;
    
    $cvsData = "\n" . $count . "," . $today . "," . $contactname . "," . $contactemail . "," . $contactphone . "," . $child_info . "," . $gender . "," . "," . $age . "," . $specialneeds . "," . $message;
    
     $fp = fopen("main_form.csv", "a" );
     if($fp){
         fwrite($fp, $cvsData);
         fclose($fp);
         }                   
    
    ?>

推荐答案

contactname =
contactname =


_POST [ contact-名称];
_POST["contact-name"];


contactemail =
contactemail =


这篇关于联系表格不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆