Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

HTML
<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;">
        <input type="radio" id="female" name="female" value="female"> Female
        </strong__^
    </div>
    <div class="form-group">
        ^__strong__^ 
            <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;">
        ^__strong style="font: Raleway; color: #999; font-size: 16.5px;" id="specialneeds"__^Does Your Child Have Special Needs: 
        ^__strong style="color: #888;">
            <input id="yes"" type="radio" name="yes" value="yes">Yes
        
        ^__strong style="color: #888;">
            <input id="no" type="radio" name="no" value="no"> No
        
    </div>
    <div class="form-group">
        ^__strong> 
            <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">^__strong>Submit</button>
</form>


and php is this:
PHP
<?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);
         }                   
    
    ?>
Posted

Why are there 2 action attributes in the form tag? Where is the method attrbute? You have to learn the correct way of form handling and construction => http://www.w3schools.com/php/php_forms.asp[^]
Study the other topics provided at this link too.
 
Share this answer
 
v4
hi

don't use multiple "id" on single tag u had use of input tag and also use only one action attributes in fom
 
Share this answer
 
Comments
Wombooo 23-Jun-15 23:56pm    
So by removing the extra IDs, that solves the problem? I didn't think by having an extra id it would do anything?
Arun-23 29-Jun-15 3:24am    
whether its solves r not but its not a right way to do

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900