hi guys. so i have this page that i have setup so the data gets submitted without refresh although the message saying data has been added is displayed, no data is submitted into database. I need a pair(or more) of fresh eyes. please and thank you.

form:

<form id='addspouse'>
        <fieldset class="updatespouse">
                <label style="font-size:20px;font-weight:bold">Edit Spouse</label><br><br>
                    <input type="hidden" value='$id' id='contactid'>
                    <input type="hidden" value='$session' id='session'>
                    <fieldset style='padding:3px;width:600px;margin-left:20px'>
                        <label>
                            <b>NOTE : </b>Fields with asterisk <label style='color:red'>*</label> &nbsp;are required fields unless information for that field &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is unavailable
                            then enter hyphen <label style='color:red'>-</label>&nbsp;&nbsp;. No fields should be left blank.
                        </label>
                    </fieldset><br>
                    <div style='width:100px;height:0px'><label><label style="color:red">*</label>Salutation</label></div>
                    <div style='margin-left:110px;'><label>:</label>
                    <select name="ssalute" id='spouse-salute' >
                        <option value='' selected>Title</option>
                        <option value="Datin">Datin</option>
                        <option value='Datin Sri'>Datin Sri</option>
                        <option value="Datin Paduka">Datin Paduka</option>
                    </select></div><br>

                <div style='width:120px;height:0px'><label><label style="color:red">*</label>First Name</label></div>
                <div style='margin-left:110px;width:200px;height:0px'><label>:</label>
                    <input type="text" name="sfname" class="style" id='spouse-fname'>
                </div>

                <div style='margin-left:300px;height:0px;width:120px'><label>Middle Name</label></div>
                <div style='margin-left:430px;'>
                    :&nbsp;<input type="text" name="smname" id="spouse-mname"  class="style">
                </div><br>
                <div style='height:0px;width:120px'><label><label style="color:red">*</label>Last Name</label></div>
                <div style='margin-left:120px;height:0px'>
                    :&nbsp;<input type="text" name="slname" id="spouse-lname"  class="style">
                </div>
                <div style='height:0px;margin-left:300px'><label><label style="color:red">*</label>Date of Birth</label></div>
                <div style='margin-left:420px'><label>:</label>
                    <input type="date" name="sdob" id='spouse-dob'>
                </div><br>
                <div style='height:0px'><label>Personal No.</label></div>
                <div style='margin-left:110px;width:200px;height:0px'><label>:</label>
                    <input type="text" name="spersonalno" class="style" id='spouse-pno'>
                </div>
                <div style='margin-left:300px;height:0px;'><label>House No.</label></div>
                <div style='margin-left:420px'><label>:</label>
                    <input type="text" name="shouseno" class="style" id='spouse-hno'>
                </div><br>
                <div style='height:0px;width:150px;'><label>Email Address &nbsp;&nbsp;(Personal)</label></div>
                <div style='margin-left:110px;height:10px'><label>:</label>
                    <input type="text" name="spersonalemail" class="style" id='spouse-pemail'>
                </div><br><br>
                <div style='height:0'><label><label style="color:red">*</label>House Address</label></div>
                <div style='margin-left:130px;'><label>:</label>
                    <input type='text' name="shouseadd" size="60" id='spouse-hadd'>
                </div><br>
                <div style='height:0px'><label><label style="color:red">*</label>Office Address</label></div>
                <div style='margin-left:130px;'><label>:</label>
                    <input type="text" name="sofficeadd" size="60" id='spouse-oadd'>
                </div><br>
                <div style='height:0px'><label><label style="color:red">*</label>PA Name</label></div>
                <div style='margin-left:110px;width:200px;height:0px'><label>:</label>
                    <input type="text" name="ssec" class="style" id='spouse-sec'>
                </div>
                <div style='height:0px;margin-left:300px;'><label>PA No.</label></div>
                <div style='margin-left:400px;width:200px;'><label>:</label>
                    <input type="text" name="spano" class="style" id='spouse-pano'>
                </div><br>
                <div style='height:0px'><label><label style="color:red">*</label>Office No.</label></div>
                <div style='margin-left:110px;height:0px'><label>:</label>
                    <input type="text" name="sofficeno" class="style" id='spouse-offno'>
                </div>
                <div style='height:0px;margin-left:300px;'><label><label style="color:red">*</label>Fax No.</label></div>
                <div style='margin-left:400px;width:200px;'><label>:</label>
                    <input type="text" name="sfaxno" class="style" id='spouse-fno'>
                </div><br>
                <div style='height:0px;width:110px;'><label>Email Address &nbsp;&nbsp;(PA)</label></div>
                <div style='margin-left:110px;height:0px'><label>:</label>
                    <input type="text" name="semailpa" class="style" id='spouse-epa'>
                </div>
                <div style='height:0px;width:150px;margin-left:300px'><label>Email Address &nbsp;&nbsp;(Work)</label></div>
                <div style='margin-left:400px;height:0px'><label>:</label>
                    <input type="text" name="semailwork" id="email" class="style" id='spouse-ework'>
                </div>
                <br><br><br>
        </fieldset>
        <br>
        <div style="margin-left:20px"><input type="button" name="submitSpouse" value="Add Spouse" id="submitSp"/>&nbsp;&nbsp;&nbsp;<input type="button" name="cancel" id="cancelAddSP" value="Cancel"/></div>
        <br>
    </form>

jquery handling submit:

$(document).ready(function(){  
    $("#submitSp").live("click", function()
    {
        var id = $("#contactid").val();
        var ssalut = $("#spouse-salute").val();
        var sfname = $("#spouse-fname").val();
        var smname = $("#spouse-mname").val();
        var slname = $("#spouse-lname").val();
        var sdob = $("#spouse-dob").val();
        var shouseadd = $("#spouse-hadd").val();
        var sofficeadd = $("#spouse-oadd").val();
        var spersonalno = $("#spouse-pno").val();
        var shouseno = $("#spouse-hno").val();
        var sfaxno = $("#spouse-fno").val();
        var sofficeno = $("#spouse-offno").val();
        var spano = $("#spouse-pano").val();
        var spaname = $("#spouse-sec").val();
        var semailpa = $("#spouse-epa").val();
        var semailwork = $("#spouse-ework").val();
        var spersonalemail = $("#spouse-pemail").val();
        var session = $("#session").val();

        if(id=='' || ssalut==''|| sfname=='' || smname=='' || slname=='' || sdob=='' || shouseadd=='' || sofficeadd=='' || spersonalno=='' || shouseno=='' || sfaxno=='' || sofficeno=='' || spano=='' || spaname=='' || semailpa=='' || semailwork=='' || spersonalemail=='' || session =='')
        {
            alert("Insertion Failed, Some Fields are Blank!");      
        }
        else
        {
            // Returns successful data submission message when the entered information is stored in database.
            $.post("AddSpouseDetails.php",
            { 
                ids: id,
                ssaluts: ssalut,
                sfnames: sfname,
                smnames: smname,
                slnames: slname,
                sdobs: sdob,
                shouseadds: shouseadd,
                sofficeadds: sofficeadd,
                spersonalnos: spersonalno,
                shousenos: shouseno,
                sfaxnos: sfaxno,
                sofficenos: sofficeno,
                spanos: spano,
                spanames: spaname,
                semailpas: semailpa,
                semailworks: semailwork,
                spersonalemails: spersonalemail,
                sessions: session 
            },
            function(data) {
                alert("Spouse added!");
                $("#addspouseD").hide();
                $("#editD").show();
            });
        }
    });
});

AddSpouseDetails.php

<?php
    require "connection.php";

    $id = $_POST['ids'];
    $ssalut = $_POST['ssaluts'];
    $sfname = $_POST['sfnames'];
    $smname = $_POST['smnames'];
    $slname = $_POST['slnames'];
    $sdob = $_POST['sdobs'];
    $shouseadd = $_POST['shouseadds'];
    $sofficeadd = $_POST['sofficeadds'];
    $spersonalno = $_POST['spersonalnos'];
    $shouseno = $_POST['shousenos'];
    $sfaxno = $_POST['sfaxnos'];
    $sofficeno = $_POST['sofficenos'];
    $spano = $_POST['spanos'];
    $spaname = $_POST['spanames'];
    $semailpa = $_POST['semailpas'];
    $semailwork = $_POST['semailworks'];
    $spersonalemail = $_POST['spersonalemails'];
    $session = $_POST['sessions']; 

    $addspouse = $dbh->prepare("INSERT INTO spouse1(suser_id,s_salutation,s_fname,s_mname,s_lname,s_dob,s_personalno,s_houseno,s_personalemail,s_houseadd,s_officeadd,s_officeno,s_faxno,s_emailwork,s_secretary,s_emailpa,s_pano,my_spouse) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
    $addspouse->bindParam(1,$session,PDO::PARAM_INT);
    $addspouse->bindParam(2,$ssalut,PDO::PARAM_STR);
    $addspouse->bindParam(3,$sfname,PDO::PARAM_STR);
    $addspouse->bindParam(4,$smname,PDO::PARAM_STR);
    $addspouse->bindParam(5,$slname,PDO::PARAM_STR);
    $addspouse->bindParam(6,$sdob,PDO::PARAM_STR);
    $addspouse->bindParam(7,$spersonalno,PDO::PARAM_STR);
    $addspouse->bindParam(8,$shouseno,PDO::PARAM_STR);
    $addspouse->bindParam(9,$spersonalemail,PDO::PARAM_STR);
    $addspouse->bindParam(10,$shouseadd,PDO::PARAM_STR);
    $addspouse->bindParam(11,$sofficeadd,PDO::PARAM_STR);
    $addspouse->bindParam(12,$sofficeno,PDO::PARAM_STR);
    $addspouse->bindParam(13,$sfaxno,PDO::PARAM_STR);
    $addspouse->bindParam(14,$semailwork,PDO::PARAM_STR);
    $addspouse->bindParam(15,$spaname,PDO::PARAM_STR);
    $addspouse->bindParam(16,$semailpa,PDO::PARAM_STR);
    $addspouse->bindParam(17,$spano,PDO::PARAM_STR);
    $addspouse->bindParam(18,$id,PDO::PARAM_STR);
    $addspouse->execute();
?>

TIA!

Recommended Answers

All 2 Replies

Member Avatar for iamthwee

I counted 19 '?' for 18 parameters. But that was just a quick glance.

good catch iamthwee. but still no data submitted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.