我在使用php将值插入MySQL时得到<br />
语句。
我尝试过更改insert语句以及echo语句,但没有任何效果。
<?php
if($_SERVER['REQUEST_METHOD']=='POST'){
$userfullname=$_POST['userfullname'];
$usernickname=$_POST['usernickname'];
$usermail=$_POST['usermail'];
$userusname=$_POST['userusname'];
$useruspassword=$_POST['useruspassword'];
$user="";
$curr_timestamp = now();
define('HOST','********');
define('USER','*******');
define('PASS','*****');
define('DB','********');
$con = mysqli_connect(HOST,USER,PASS,DB) or die('Unable to Connect');
$sql = "INSERT INTO 0_users (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES (NULL, '$userusname', '$useruspassword', '$usernickname', '$usermail', '', '$curr_timestamp', '', '0', '$userfullname')";
$check = mysqli_fetch_array(mysqli_query($con,$sql));
if(isset($check)){
echo "success";
}else{
echo "Invalid Username or Password";
}
mysqli_close($con);
}else{
echo "error try again";
}
?>
答案 0 :(得分:0)
试试这个
<?php
if($_SERVER['REQUEST_METHOD']=='POST'){
$userfullname=preg_replace( "/\r|\n/", "", $_POST['userfullname'] );
$usernickname=preg_replace( "/\r|\n/", "", $_POST['usernickname']);
$usermail=preg_replace( "/\r|\n/", "", $_POST['usermail']);
$userusname=preg_replace( "/\r|\n/", "", $_POST['userusname']);
$useruspassword=preg_replace( "/\r|\n/", "", $_POST['useruspassword']);
$user="";
$curr_timestamp = now();
define('HOST','********');
define('USER','*******');
define('PASS','*****');
define('DB','********');
$con = mysqli_connect(HOST,USER,PASS,DB) or die('Unable to Connect');
$sql = "INSERT INTO 0_users (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('$userusname', '$useruspassword', '$usernickname', '$usermail', '', '$curr_timestamp', '', '0', '$userfullname')";
$check = mysqli_query($con,$sql);
if(isset($check)){
echo "success";
}else{
echo "Invalid Username or Password";
}
mysqli_close($con);
}else{
echo "error try again";
}
&GT;