Posting Data to Database

Hello folks, ve been wandering around what could be the problem with my script. All my Data from my form are not getting stored in my Db, i mean some are stored why some are not. i dont know where the problem is. my code below

`

<?php include ('config.php'); function getStatus($trnxid, $amt) { $query = "SELECT trnxid, amount FROM transactions WHERE trnxid= '$trnxid'"; $result = mysql_query($query) or die(mysql_error()); $res = mysql_fetch_assoc($result); if($res != false) { $t_trnxid = $res['trnxid']; $t_amt = $res['amount']; } else { $t_trnxid = NULL; $t_amt = NULL; } if ($trnxid == $t_trnxid AND $amt== $t_amt){ return True; } else{ return False; } } $trxnid= isset($_POST['trxnid']) ? $_POST['trxnid'] : time(); $amount= isset($_POST['amt']) ? $_POST['amt'] : 1000; if (isset($_POST['trxnid'])){ $name= isset($_POST['RegFullName']) ? $_POST['RegFullName'] : ""; $org= isset($_POST['RegOrganization']) ? $_POST['RegOrganization'] : ""; $pos= isset($_POST['RegPosition']) ? $_POST['RegPosition'] : ""; $officetel= isset($_POST['RegOfficeTel']) ? $_POST['RegOfficeTel'] : ""; $mobile= isset($_POST['RegMobile']) ? $_POST['RegMobile'] : ""; $fax= isset($_POST['RegFax']) ? $_POST['RegFax'] : ""; $email= isset($_POST['RegEmailaddress']) ? $_POST['RegEmailaddress'] : ""; $add= isset($_POST['RegAddress']) ? $_POST['RegAddress'] : ""; $trans=isset($_POST['RegTranYes']) ? $_POST['RegTranYes'] : ""; $transHotel=isset($_POST['RegHotelYes']) ? $_POST['RegHotelYes'] : ""; $regpol1=isset($_POST['RegPol1']) ? $_POST['RegPol1'] : ""; $regpol2=isset($_POST['RegPol2']) ? $_POST['RegPol2'] : ""; $profile=isset($_POST['RegOrgProfile']) ? $_POST['RegOrgProfile'] : ""; $picture=isset($_POST['RegPic']) ? $_POST['RegPic'] : ""; $uprofile="upload/orgfile/" . $profile; $upicture="upload/" . $picture; $query= "INSERT INTO registration VALUES('', '$name', '$org', '$pos', '". mysql_escape_string($add). "', '$upicture', '$uprofile', '$officetel', '$mobile', '$fax', '$email', '$regpol1', '$regpol2', '$trans', '$transHotel', '$trxnid')"; $result=mysql_query($query) or die(mysql_error()); $query = "INSERT INTO transactions VALUES('', '$trxnid', '$amount', '', '')"; $result= mysql_query($query) or die(mysql_error()); } $trnxvalid= False; $_SESSION['amount']= $amount; $_SESSION['txnref']= $trxnid; if (isset($trxnid) AND isset($amount)){ $trnxvalid=getStatus($trxnid, $amount); } $response= ($trnxvalid) ? "Validity check passed" : "Validity Check Failed, try again"; ?>

`

only this Data is stored ($name, $upicture, $uprofile , $regpol1 , $regpol2 , $trxnid )

Please anyone with ideas where the prob is coming from

Add the following line of code after the check for the posted trxnid.
print_r($_POST)

This will display all the datahfrom the posted form. With this you can check if the field names you’re using are actually correct and if they contain data.

thanks. This is what i got
;
Array ( [RegFullName] => olubukola [RegPic] => frtees.jpg [RegOrgProfile] => A Business Directory Just Isn.docx [RegPol1] => Science & Technology [RegPol2] => Human Develoment [trxnid] => 1318159729 [amt] => 12000000 ).

What can i do make sure all the data is posted. please spot any error in the code

From your insert statement u are trying to insert 15 items but your form is only posting 7 items, check your form to make sure the element names match the names in your $_post

I think maybe my php script is failing, i tried it now, it updates all the field in the db and tried it again and it does not just only picking the other fields