<?php
if(isset($_POST['btnSubmit1'])){
$fullName=htmlentities(mysql_real_escape_string($_POST['name']));
$emailID=htmlentities(mysql_real_escape_string($_POST['email']));
$mobNo=htmlentities(mysql_real_escape_string($_POST['mobile']));
$c=htmlentities(mysql_real_escape_string($_POST['city']));
$p=htmlentities(mysql_real_escape_string($_POST['pincode']));
$t=$_POST['type'];
$tm=time();
$query = 'PREPARE statement FROM "INSERT INTO agrl
VALUES(?,?,?,?,?,?,?)"';
mysql_query($query);
$query = 'SET @name = "$fullName",' .
'@email = "$emailID",' .
'@mobo = "$mobNo",' .
'@city = "$c",' .
'@pincode = "$p",'.
'@country = "$t",'.
'@time = "$tm"';
$query = 'EXECUTE statement USING
@name,@email,@mobo,@city,@pincode,@country,@time';
if(!(mysql_query($query))){
echo "Sorry!!! please try again";
}
else{
$query = 'DEALLOCATE PREPARE statement';
mysql_query($query);
echo "<script
type='text/javascript'>alert('success')</script>";
}
}
?>
这段代码完全可以工作 f9 但不是从表单字段插入数据而是插入变量名例如:如果我在表单的名称字段中键入 robert 并点击提交按钮然后而不是在我的数据库中保存 robert 它保存 $fullName.. 请帮助.. 提前致谢