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