This is my init.inc file:
<?php
session_start();
$exceptions= array('index','contactus');
$page = explode('/', $_SERVER['SCRIPT_NAME']);
$page = end($page);
$page = substr($page, 0, -4);
if (in_array($page, $exceptions) === false){
if (isset($_SESSION['username']) === false){
header('Location: index.php');
die(); }}
$host= "localhost";
$username= "****";
$password= "******";
$db= "******";
$connect= mysql_connect($host,$username,$password);
if ($connect){
echo "Connection successful.";
$select= mysql_select_db($db);
if ($select){
echo "<br /> Connected to ".$db;
}else{
echo "<br /> Unable to connect to".$db;}
}else{
echo "Failed connection.";
}
$path= dirname(__FILE__);
include("{$path}/inc/user.inc.php");
?>
This is my form in my index html:
<!--Sign up-->
<table id="signup">
<thead></thead>
<tbody><div id="signup">
<form action="" method="POST">
<tr><td><input type="text" name"username" placeholder="Username"/></td></tr>
<tr><td><input type="text" name"email" placeholder="Email"/></td></tr>
<tr><td><input type="password" name="password" placeholder="Password"/></td></tr>
<tr><td><input type="password" name="confirmpassword" placeholder="Confirm password"/></td></tr>
<tr><td id="location">Campus: <select name="select" style="width:120px" id="select" >
<option value="sca" />Sca</option>
<option value="mis" />Mis</option>
<option value="st" />St</option></select></td></tr>
<tr><td id="privacy"><input type="checkbox" name="privacy"/>I agree to <a href="">Terms</a></td></tr>
<tr><td><center><input type="submit" name="submit" value="Sign up" /></center></td></tr>
</form></div></tbody></table>
This is my php code in my index html before the html:
<?php
include('core/init.inc.php');
$errors= array();
if (isset($_POST['username'], $_POST['email'],$_POST['password'], $_POST['confirmpassword'])){
if (empty($_POST['username'])){
$errors[]= 'Please enter a username';
}
if (empty($_POST['email'])){
$errors[]= 'Please enter an email address';
}
if (empty($_POST['password']) || empty($_POST['confirmpassword'])){
$errors[]= 'Please enter a password';
}
if ($_POST['password'] !== $_POST['confirmpassword']){
$errors[]= 'Password verification failed.';
}
if (user_exists($_POST['username'])){
$errors[]= 'The username you have entered already exists';
}
if (empty($errors)){
add_user($_POST['username'], $_POST['email'],$_POST['password']);
$_SESSION['username'] = htmlentities($_POST['username']);
header('Location: contactus.php');
die();
}
}
?>
I apologize for the mistakes in my last post. I am trying to create a new user by entering inputs in my registration box on my index.html. I know for a fact that I am connected to the database but no inputs are being stored (I checked my database after clicking submit and no data was stored). When I click submit, the page refreshes and then nothing happens. Thank you for your help, I really appreciate it!