Hi,
I am working on submitting a form with various info to update on db using jquery, ajax. The db is updating perfectly when I disable JS on firefox. When enabled, a few fields (adID, userID, comments) are not updating on the db. The field userID updated as zero, but the other two are blank.
Structure of table :
Field-Type
adID-varchar(250)
userID-int(11)
ContactDate-date
IP-varchar(250)
ModeOfContact-varchar(250)
comments-text
Please help me.
jquery code :
$("#Econtactadvertiserpanelsubmit").click(function(){
$("#Econtactadvertiserpanel").append("<h2 id='loading'>Please wait..</h3>");
var comments = $("#emailmsg").val();
var adID = $("#adID").val();
var userID = $("#userID").val();
var ContactDate = $("#ContactDate").val();
var ip = $("#ip").val();
var ModeOfContact = $("#ModeOfContact").val();
//console.log(emailmsg,con_name);
$.ajax({
type: "POST",
url: "sendmail/selemail.php",
data: 'adid=' + adID + '&userid=' + userID + '&ContactDate=' + ContactDate + '&ip=' + ip + '&ModeOfContact=' + ModeOfContact + '&comments=' + comments,
success: function(result){
console.log(result);
}
})
return false;
});
HTML form :
<div id="Econtactadvertiserpanel" style="margin: 0px; padding: 5px; text-align: center; background: #F3EFE0; border: #006400 dashed thin">
<form name="Econtactadvertiserpanel" method="POST" action="selemail.php">
<table>
<tr>
<td><label>Your Name</label></td>
<td id="con_name"><?php echo $conlst['name']; ?></td>
</tr>
<tr>
<td>Your Message</td>
<td><textarea id="emailmsg" name="emailmsg" cols="50" rows="5"></textarea> </td>
</tr>
<tr>
<td colspan="2"><input id="Econtactadvertiserpanelsubmit" type="submit" name="submit" value="Submit" /></td>
</tr>
</table>
<input type="hidden" name="adID" id="adID" value="<?php echo $adID; ?>">
<input type="hidden" name="userID" id="userID" value="<?php echo $conlst['userID']; ?>">
<input type="hidden" id="ContactDate" name="ContactDate" value="<?php echo $datetoday; ?>">
<input type="hidden" id="ModeOfContact" name="ModeOfContact" value="E">
<input type="hidden" id="ip" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>">
</form>
</div>
PHP file :
<?php
$adID=$_POST['adID'];
$userID=intval($_POST['userID']);
$ContactDate = date('Y-m-d', strtotime($_POST['ContactDate']));
$IP=$_POST['ip'];
$ModeOfContact=$_POST['ModeOfContact'];
$comments=$_POST['emailmsg'];
require_once('dbcon.php'); // DataBase connection
mysql_query("INSERT INTO contactdata VALUES('$adID', '$userID', '$ContactDate', '$IP', '$ModeOfContact', '$comments')");
if($adreply_q) {
echo "Success";
}
else {
echo "Failed";
}
?>
Thanks in advance.
Regards,
Kiran