gpt4 book ai didi

php - 签署表格问题

转载 作者:行者123 更新时间:2023-11-29 20:56:36 24 4
gpt4 key购买 nike

我只想制作一个简单的注册表单,当空白为空时,我单击按钮,我可以看到“请填写所有字段”。但是,当我填写空白并单击提交按钮时,什么也没有发生。我看不到“表格已提交”成功”并且任何插入到我的表“hastalar”中的内容。请帮助我。

http://www.eksiduyuru.com/files/1464/1464794851_1.jpg “未定义”

http://www.eksiduyuru.com/files/1464/1464794851.jpg “哈斯塔拉表”

脚本.js

$(document).ready(function(){
$("#submit").click(function(){

var name = $("#name").val();
var tc = $("#tc").val();
var password = $("#password").val();
var contact = $("#contact").val();
var dataString = 'name1='+ name + '&tc1='+ tc + '&password1='+ password + '&contact1='+ contact;

if(name==''||email==' '||password==''||contact=='')
{
alert("Please Fill All Fields");
}
else
{
// AJAX Code To Submit Form.
$.ajax({
type: "POST",
url: "ajaxsign.php",
data: dataString,
cache: false,
success: function(result){
alert(result);
}
});
}
return false;
});
});

ajaxsign.php

<?php include ("includes/db.php"); ?>
<?php

if(isset($_POST["submit"])){

$name2=$_POST['name1'];
$tc2=$_POST['tc1'];
$password2=$_POST['password1'];
$contact2=$_POST['contact1']; }
//Insert query
$query =mysql_query("insert into hastalar(adi, tc_no, password, tel) values ('$name2', '$tc2', '$password2','$contact2')");
if (!empty($name2) && !empty($tc2) && !empty($password2) && !empty($contact2) )
{
echo "Form Submitted Succesfully";
}




if(isset($connection)){


mysql_close($connection);
}

?>

db.php

   $connection=@mysql_connect("localhost","root","");

if(!$connection){


die("Veritabanı bağlantı hatası:".mysql_error());

}


$db=mysql_select_db("proje",$connection);

if(!$db){

die("Veritabanı tablo seçim hatası:".mysql_error());


}

最佳答案

script.js 第 8 行:语法错误。将 vvar dataString 更改为 var dataString

..好的编辑我的答案。

$(document).ready(function(){
$("#submit").click(function(){

var name = $("#name").val(),
tc = $("#tc").val(),
password = $("#password").val(),
contact = $("#contact").val();

if(name==''||email==' '||password==''||contact=='') {
alert("Please Fill All Fields");
} else {
// AJAX Code To Submit Form.
$.ajax({
type: "POST",
url: "ajaxsign.php",
data: {'name1':name,'tc1':tc,'password1':password,'contact1':contact},
cache: false,
success: function(result){
alert(result);
}
});
}
return false;
});
});

关于php - 签署表格问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37576151/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com