php脚本没有进入数据库

时间:2018-05-03 10:21:00

标签: php

我一直在通过mmtuts关注youtube上的教程,并进入了如何从mysqli插入数据库的部分。它运行良好一段时间,我设法将信息插入数据库,但突然间,它无法插入数据库。它似乎没有连接到我的数据库,但我可以手动插入....这是我的代码..我有我的包文件夹中的主数据库文件...

 <?php

          $dbServername = "localhost";
          $dbUsername = "root";
          $dbPassword = "";
          $dbName = "loginsystem";

          $conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);

          ?>

这是我的主要注册页面:

<!DOCTYPE html>
 <html>
 <head>
<title></title>
   </head>
   <body>
   <form action="includes/signup.php" method="POST">
      <input type="text" name="first_name" placeholder="first_name">
      <br></br>
      <input type="text" name="last_name" placeholder="last_name">
      <br></br>
     <input type="text" name="email_address" placeholder="email_address">
     <br></br>
     <input type="text" name="password" placeholder="password">
     <br></br>
     <input type="text" name="confirm_password" 
     placeholder="confirm_password">
     <br></br>
     <input type="submit" name="submit" value="Register">
   </form>


 </body>
  </html>

这是处理要插入数据库的信息的页面。

<?php


  include_once 'dbh.php';

   $token1 = 'sfdsfdsfsfsdferewgagQWEDFGRTRTRGFGDFG123245345433!~';
   $token1 = str_shuffle($token1);
   $token1 = substr($token1, 0, 10);




 $first_name = $_POST['first_name'];
 $last_name = $_POST['last_name'];
 $email_address = $_POST['email_address'];
 $password = $_POST['password'];
 $confirm_password = $_POST['confirm_password'];

  $sql = "INSERT INTO users (user_first, user_last, user_email, user_uid, 
  user_pwd, token) VALUES ('$first_name', '$last_name', '$email_address', 
  '$password','$confirm_password', '$token1');";  // needs duoble quote

  mysqli_query($conn, $sql);

  header('Location:../includes/activateaccount.php?signup=success');

  ?>

这是我的activateaccount.php页面:

<?php
include_once 'dbh.php';


?>



<!DOCTYPE html>
<html>
    <head>
        <title></title>
    </head>
    <body>
    <p> Please enter the following information to activate your account</p>
    <form action='activate.php' method='POST'>
        <input type='text' name='email_address' placeholder='email_address'>
        <input type='text' name='confirm_email' placeholder='confirm_email'>
        <input type='submit' name='submit' values='activate account'>
    </form>


    </body>
</html>

当我运行代码时,没有显示错误,但它只是没有添加到数据库中....

0 个答案:

没有答案