尝试修改无效电子邮件时获得500个内部值

时间:2019-04-06 23:09:10

标签: php mysql sql

我正在制作一家网上商店并尝试建立登录和注册系统,所以当我完成该操作时,我正在寻找可能的错误,然后遇到此错误。当我输入电子邮件而不是@时,如果验证有效,则无法使用ckeck,但是随后出现500个内部服务器错误。当我输入真实的电子邮件地址时,效果很好。

这是注册页面:

<h1 style="text-align: center; width: 100%;">Registrere bruker</h1>
   <div class="" style="width: 20%; margin: auto;">
      <form class="" action="includes/signup.inc.php" method="post">
         <input type="text" name="first" placeholder="Fornavn">
          <input type="text" name="last" placeholder="Etteranavn" >
          <input type="text" name="mail"  placeholder="Email" >
          <input type="password" name="pswd" placeholder="Passord">
          <input type="password" name="pswd-repeat" placeholder="Gjenta passord">
          <input type="text" name="tlf"  placeholder="Telefon">
          <input type="text" name="adress"  placeholder="Adresse">
          <input type="text" name="zip"  placeholder="Postnummer">
          <button type="submit" name="signup_submit" style="width:50%; margin-left: 25%; margin-top: 12px;">Registrer</button>
       </form>
     </div>

这是动作文件

if (isset($_POST[signup_submit])){

require 'connect.php';

 $first = $_POST['first'];
 $last = $_POST['last'];
 $email = $_POST['mail'];
 $phone = $_POST['tlf'];
 $password = $_POST['pswd'];
 $passwordRepeat = $_POST['pswd-repeat'];
 $adress = $_POST['adress'];
 $zip = $_POST['zip'];

  if (empty($first) || empty($last) || empty($email) || empty($passwordRepeat) || empty($adress) || empty($adress)){
   header("Location: ../signup.php?error=emptyfields");
  } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
    header("Location : ../signup.php?error=invalidmail&first=".$firstname."&last=".$last."&tlf=".$phone."&adress=".$adress."&zip=".$zip);
    exit();
    } elseif ($password !== $passwordRepeat) {
      header("Location : ../signup.php?error=pswdmismatch&first=".$firstname."&last=".$last."&tlf=".$phone."&adress=".$adress."&zip=".$zip);
      exit();
       } else {
         $sql = "SELECT * FROM astellas.bruker WHERE epost=?";
         $stmt = mysqli_stmt_init($connection);

        if (!mysqli_stmt_prepare($stmt, $sql)) {
        header("Location: ../signup.php?error=sqlerror");
        exit();
      } else {
        mysqli_stmt_bind_param($stmt, "s", $email);
        mysqli_stmt_execute($stmt);
        mysqli_stmt_store_result($stmt);
        $resultCheck = mysqli_stmt_num_rows($stmt);
        }

        if ($resultCheck > 0) {
            header("Location: ../signup.php?error=emailtaken&first=".$firstname."&last=".$last."&tlf=".$phone."&adress=".$adress."&zip=".$zip);
            exit();
        } else {

            $sql = "INSERT INTO astellas.bruker (fornavn, etternavn, passord, epost, adresse, postnummer_id, tlf) VALUES (?, ?, ?, ?, ?, ?, ?);";
            $stmt = mysqli_stmt_init($connection);

            if (!mysqli_stmt_prepare($stmt, $sql)) {
                header("Location: ../signup.php?error=sqlerror2");
                exit();
            } else {

                $hashedpass = password_hash($password, PASSWORD_DEFAULT);

                mysqli_stmt_bind_param($stmt, "sssssss", $first, $last, $hashedpass, $email, $adress, $zip, $phone);
                mysqli_stmt_execute($stmt);
                header("Location: ../mainpage.php?signup=success");
                exit();

              }
          }

    }

} else {
    header("Location: ../signup.php");
  }

我试图通过网页创建一个单独的页面,我的数据库被删除了,现在它不想将值插入数据库,但是我认为这取决于我认为的sql表。

[06-Apr-2019 23:36:43 UTC] PHP Warning:  Use of undefined constant signup_submit - assumed 'signup_submit' (this will throw an Error in a future version of PHP) in C:\wamp64\www\PHPstuff\AstellNettside\includes\signup.inc.php on line 3
[06-Apr-2019 23:36:43 UTC] PHP Stack trace:
[06-Apr-2019 23:36:43 UTC] PHP   1. {main}() C:\wamp64\www\PHPstuff\AstellNettside\includes\signup.inc.php:0
[06-Apr-2019 23:36:43 UTC] PHP Notice:  Undefined variable: firstname in C:\wamp64\www\PHPstuff\AstellNettside\includes\signup.inc.php on line 20
[06-Apr-2019 23:36:43 UTC] PHP Stack trace:
[06-Apr-2019 23:36:43 UTC] PHP   1. {main}() C:\wamp64\www\PHPstuff\AstellNettside\includes\signup.inc.php:0

这是错误消息

0 个答案:

没有答案