使用ajax提交表单后获取表单值(mysql_insert_id)

时间:2013-01-24 09:59:01

标签: php jquery mysql ajax

在我的表单由ajax和表单验证(jquery.validationEngine)提交后,我正在尝试获取一个值(mysql_insert_id),但没有成功..

$(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});
}
}  
});

我的page.php文件

$query="INSERT INTO users (userid,title,)VALUES ('".$_SESSION['id']."', '".$_REQUEST['title']."')"; $result=mysql_query($query);
$id = mysql_insert_id();

1 个答案:

答案 0 :(得分:0)

$query="INSERT INTO users (userid,title,)VALUES ('".$_SESSION['id']."', '".$_REQUEST['title']."')"; $result=mysql_query($query);
$id = mysql_insert_id();
echo mysql_error();

查看错误消息;