dousou1878 2018-05-03 10:21
浏览 26

php脚本没有进入数据库

I have been following the tutorials on youtube by mmtuts and got to the section, how to insert database from mysqli. It was working well for a while and I managed to insert information into the database but suddenly, it fails to insert into the database. It just seems that it is not connecting to my database but I can insert it manually.... Here are my codes.. I have the main database file in my includes folder...

 <?php

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

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

          ?>

This is my main registration page:

<!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>

This is the page where it processed the information to be inserted into the database..

<?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');

  ?>

This is my activateaccount.php page:

<?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>

When I run the code, there are no errors displayed but it just doesn't add into the database....

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?