Heloo Guys,我有一个非常讨厌的问题,我的变量一直在失去范围,似乎没有任何作用,我不确定是什么错误。
这个php的目的是让Let和Admin编辑用户的电子邮件,用户ID在链接中发送,这里收到,我选择用户向他显示当前的电子邮件,然后管理员通过一个新的电子邮件提交形式,它更新......
但是$ user_id变量在IF里面是空的..就像它将它识别为另一个变量一样,我尝试了var_dump ..它实际上是空的,尝试过全局和$ GLOBALS ..没有任何作用
$userid = $_POST['user_id'];
$mysqli_object = fQuery('users', 'SELECT', '*', null, array('user_id'), array($userid), null, null);
$mysqli_count = mysqli_num_rows($mysqli_object);
$user_id = '';
$account = '';
$name = '';
$email = '';
while($row = mysqli_fetch_array($mysqli_object)) {
$user_id = $row['user_id'];
$account = $row['account'];
$name = $row['name'];
$email = $row['email'];
}
if(isset($_POST['new_email'])) {
if(!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) {
header("Location: editEmail.php?R=2");
die();
}
if(!empty($_POST['new_email'])) {
//NOTHING
}else {
header("Location: editEmail.php?R=2");
die();
}
$new_email = $_POST['new_email'];
$mysqli_object = fQuery('users', 'UPDATE', array('email'), array($new_email), array('user_id'), array($user_id), null, null);
if($mysqli_object) {
header("Location: editEmail.php?R=1");
die();
}else {
header("Location: editEmail.php?R=3");
die();
}
}