0

i have a contact form. html is done. php is done as well. but the submit button doesnt seem to read my php code. sorry if my coding is too long but i just had to post the whole thing incase i missed something. any help is very much appreciated.

html

<div class="form-wrapper">
    <form method="post" action="add_contact.php" class="add-contact-form">
        <fieldset>
            <legend>Add Contact</legend>
                <table>
                Salutation : 
                    <select name="salutations">
                        <option value="" disabled selected>Choose</option>
                        <option value="Datin">Datin</option>
                        <option value="Datin Paduka">Datin Paduka</option>
                        <option value="Dato Paduka">Dato Paduka</option>
                        <option value="Dato'">Dato'</option>
                        <option value="Dato' Seri">Dato' Seri</option>
                        <option value="Datuk">Datuk</option>
                        <option value="Datuk Seri">Datuk Seri</option>
                        <option value="Dr.">Dr.</option>
                        <option value="Haji">Haji</option>
                        <option value="Hajjah">Hajjah</option>
                        <option value="HM">HM</option>
                        <option value="HRH">HRH</option>
                        <option value="Miss">Miss</option>
                        <option value="Mrs.">Mrs.</option>
                        <option value="Mr.">Mr.</option>
                        <option value="Pehin">Pehin</option>
                        <option value="Professor">Professor</option>
                        <option value="Raja">Raja</option>
                        <option value="Tan Sri">Tan Sri</option>
                        <option value="Tengku">Tengku</option>
                        <option value="Tuanku">Tuanku</option>
                        <option value="Tun">Tun</option>
                        <option value="Tunku">Tunku</option>
                        <option value="Ungku">Ungku</option>
                    </select></br>
                    <label class="salute-label">*If a person has many salutations, choose the highest form of salutation*</label>
                </p>
                <div style="height:0"><label>First Name :</label><input type="text" name="fname" id="fname" required /></div>
                <div style="float:right;"><label>Last Name :</label><input type="text" name="lname" id="lname" required /></div>
                <div style="clear:both">&nbsp;</div>
                <div style="height:0"><label>House No.  :</label><input type="text" name="houseno" id="houseno" required /></div>
                <div style="float:right;"><label>Street Name :</label><input type="text" name="street" id="street" required /></div>
                <div style="clear:both">&nbsp;</div>
                <div style="height:0"><label>Postcode :</label><input type="text" name="postcode" id="postcode" required /></div>
                <div style="float:right;"><label>City :</label><input type="text" name="city" id="city" required /></div>
                <div style="clear:both">&nbsp;</div>
                <div style="height:0">State :
                <select name="state" id="state" required>
                    <option value="" disabled selected>Choose</option>
                    <option value="Johor">Johor</option>
                    <option value="Kedah">Kedah</option>
                    <option value="Kelantan">Kelantan</option>
                    <option value="Melaka">Melaka</option>
                    <option value="Negeri Sembilan">Negeri Sembilan</option>
                    <option value="Pahang">Pahang</option>
                    <option value="Perak">Perak</option>
                    <option value="Perlis">Perlis</option>
                    <option value="Pulau Pinang">Pulau Pinang</option>
                    <option value="Sabah">Sabah</option>
                    <option value="Sarawak">Sarawak</option>
                    <option value="Selangor">Selangor</option>
                    <option value="Terengganu">Terengganu</option>
                </select></div>
                <div style="float:right"><label>Country</label><input type="text" name="country" id="country" required/></div>
                <div style="clear:both">&nbsp;</div>
                <div style="height:0"><label>Mobile No. :</label><input type="tel" name="tel" id="tel" required/></div>
                <div style="float:right;"><label>Office No. :</label><input type="tel" name="off" id="off" required/></div>
                <div style="clear:both">&nbsp;</div>
                <div><label>Email Address :</label><input type="email" name="email" id="email" required/></div>
                    <div style="clear:both">&nbsp;</div>
                    <div><label>Children ?</label><input type="radio" value="Yes" name="child" id="child-yes"/>Yes<input type="radio" value="No" name="child" id="child-no"/>No</div>
                    <div style="clear:both">&nbsp;</div>
                    <div ><label>Spouse ? </label><input type="radio" name="spouse" id="spouse-yes" value="Yes" onclick="FillSpouse()"/>Yes<input type="radio" value="No" name="spouse" id="spouse-no"/>No<label class="radio-label">*If divorced or widowed, No*</label></div>
                    <input type="submit" name="submitC" value="Submit" /><a href="contact_data.php"><input type="button" id="cancel" name="cancel" value="Cancel" /></a>
        </fieldset>
    </form>
</div>

php

<?php
if(isset($_POST['submitC']))
{

    $salutations = mysql_real_escape_string($_POST['salutations']);
    $fname = mysql_real_escape_string($_POST['fname']);
    $lname = mysql_real_escape_string($_POST['lname']);
    $houseno = mysql_real_escape_string($_POST['houseno']);
    $street = mysql_real_escape_string($_POST['street']);
    $city = mysql_real_escape_string($_POST['city']);
    $state = mysql_real_escape_string($_POST['state']);
    $country = mysql_real_escape_string($_POST['country']);
    $postcode = mysql_real_escape_string($_POST['postcode']);
    $email = mysql_real_escape_string($_POST['email']);
    $tel = mysql_real_escape_string($_POST['tel']);
    $off = mysql_real_escape_string($_POST['off']);
    $spouse = ($_POST['spouse']);
    $child = ($_POST['child']);

                    require "connection.php";

                    if( $spouse AND $child == 'Yes')
                    {
                        $add = mysql_query("INSERT INTO contact VALUES('','".$salutations."','$fname','$lname','$spousefname $spouselname','$childfname $childlname','$houseno','$street','$postcode','$city','".$state."','$country','$tel','$off','$email')") or die(mysql_error());
                        $add2 = mysql_query("INSERT INTO dependents VALUES('$childfname','$childlname','$childhouseno','$childstreet','$childpostcode','$childcity','".$childstate."','$childcountry','$childemail','$childtel','$childoff','".$childsalutations."','')") or die(mysql_error());
                        $add3 = mysql_query("INSERT INTO dependents VALUES('$spousefname','$spouselname','$spousehouseno','$spousestreet','$spousepostcode','$spousecity','".$spousestate."','$spousecountry','$spouseemail','$spousetel','$spouseoff','".$spousesalutations."','')") or die(mysql_error());
                    }
                    else if($spouse AND $child == 'No')
                    {
                        $add4 = mysql_query("INSERT INTO contact VALUES('','".$salutations."','$fname','$lname','','','$houseno','$street','$postcode','$city','".$state."','$country','$tel','$off','$email')") or die(mysql_error());
                    }
                    else if(($spouse == 'Yes') AND ($child == 'No'))
                    {
                        $add5 = mysql_query("INSERT INTO contact VALUES('','".$salutations."','$fname','$lname','$spousefname $spouselname','','$houseno','$street','$postcode','$city','".$state."','$country','$tel','$off','$email')") or die(mysql_error());
                        $add6 = mysql_query("INSERT INTO dependents VALUES('$spousefname','$spouselname','$spousehouseno','$spousestreet','$spousepostcode','$spousecity','".$spousestate."','$spousecountry','$spouseemail','$spousetel','$spouseoff','".$spousesalutations."','')") or die(mysql_error());
                    }

                    else if(($spouse == 'No') AND ($child == 'Yes'))
                    {
                        $add7 = mysql_query("INSERT INTO contact VALUES('','".$salutations."','$fname','$lname','','$childfname $childlname','$houseno','$street','$postcode','$city','".$state."','$country','$tel','$off','$email')") or die(mysql_error());
                        $add8 = mysql_query("INSERT INTO dependents VALUES('$childfname','$childlname','$childhouseno','$childstreet','$childpostcode','$childcity','".$childstate."','$childcountry','$childemail','$childtel','$childoff','".$childsalutations."','')") or die(mysql_error());
                    }   
  }
?>
1
Contributor
1
Reply
19
Views
3 Years
Discussion Span
Last Post by nadiam
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.