使用在线文件管理器将文件上传到您的网站

时间:2017-02-15 12:33:13

标签: php mysql

我在http://mutualpay.byethost7.com/wp/register.php?i=1有一个注册表单..我的表单操作是signup.php..i创建了该文件,但它似乎根本无法工作,当我点击它加载的注册按钮{{3它就像没有执行文件中的代码一样

这是我的signup.php代码

<?php session_start(); include 'dpconfig.php';
$first = $_POST['firsts'];
$last = $_POST['last'];
$uid = $_POST['uid'];   
$pwd = $_POST['pwd'];

if (empty($firsts)){
 header("Location: register.php?error=empty");
  exit();
}
if (empty($last)){
 header("Location: register.php?error=empty");
  exit();
}

 if (empty($uid)){
 header("Location: register.php?error=empty");
  exit();
}

if (empty($pwd)){
 header("Location: register.php?error=empty");
  exit();
}
else {
  $sql = "INSERT INTO user (firsts, last, uid, pwd)
 VALUES ('$firsts', '$last', '$uid', '$pwd')";
   $result = $conn->query($sql);
  header("Location: index.php")
}

就像这段代码没有被执行,点击注册按钮后,它会带来一个空白页面,我不知道是什么原因,任何帮助表示赞赏。谢谢

2 个答案:

答案 0 :(得分:0)

在第一次空检查中,检查未定义的变量($firsts)。我猜你的意思是$first,但是php并不像人类那样猜测。

将您的代码更改为

if (empty($first)){
  

编辑:你也可以将这4个空支票合并为一个,如果为了   拥有更少的代码和更好的可读性:

if (empty($first) || empty($last) || empty($uid) || empty($pwd)){
    header("Location: register.php?error=empty");
    exit();
}

答案 1 :(得分:0)

问题来自你的主人,byet Byet使用&#34;抗体&#34;系统,用javascript(大部分不是由机器人执行)将你重定向到同一个位置,并在i传递的参数中加1。 问题是:重定向时没有传递post参数,这意味着$ _POST var将为空。

同时检查是否isset($_POST['firsts'])以及传递给$ _POST变量的参数,还是可能会创建未定义的var错误。