Php 使用ajax提交表单后获取表单值(mysql\u insert\u id)
在我的表单被ajax和表单验证(jquery.validationEngine)提交后,我试图获取一个值(mysql\u insert\u id),但没有成功Php 使用ajax提交表单后获取表单值(mysql\u insert\u id),php,jquery,mysql,ajax,Php,Jquery,Mysql,Ajax,在我的表单被ajax和表单验证(jquery.validationEngine)提交后,我试图获取一个值(mysql\u insert\u id),但没有成功 $(document).ready(function() { $("#form1").validationEngine('attach', { autoHidePrompt:true,showOneMessage:true, onValidationCompl
$(document).ready(function()
{
$("#form1").validationEngine('attach',
{
autoHidePrompt:true,showOneMessage:true,
onValidationComplete: function(form, status)
{
if(status === true)
{
formget(document.getElementById('form1'),'page.php');
TINY.box.show({html:'The entry (i want the id here..) has been updated successfully!',animate:false,close:false,mask:false,boxid:'success',autohide:2,top:5});
}
else
{
TINY.box.show({html:'Please check the form and try again',animate:false,close:false,mask:false,boxid:'error',autohide:2,top:5});
}
}
});
mypage.php文件
$query="INSERT INTO users (userid,title,)VALUES ('".$_SESSION['id']."', '".$_REQUEST['title']."')"; $result=mysql_query($query);
$id = mysql_insert_id();
查看错误消息 一切对我来说都很好,我只是无法得到($id)值,我可以将其用于其他函数。请注意,PHP的
mysql\u xxx()
函数已被弃用,不建议使用。应修改代码以使用较新的mysqli
或PDO
扩展。是的,我知道-mysqli\u insert\u id()。:-)还请注意,在插入
查询中使用$\u会话
和$\u请求
,而不清除用户提交的数据可能会导致严重的安全问题,并使您的应用程序遭受MySQL注入攻击。看看没人能帮我吗?
$query="INSERT INTO users (userid,title,)VALUES ('".$_SESSION['id']."', '".$_REQUEST['title']."')"; $result=mysql_query($query);
$id = mysql_insert_id();
echo mysql_error();