I’m creating a registration page for a website. When i submit the form, the data is not sent to the database. Anyone know why this is occurring? The following code is from the script called register.php I dont see why it wont send to my mysql database. Last night i had an error “phpMyAdmin – Error Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly.”
But now its working. Could it be from that?
<?php
echo "<h1>Register</h1>";
$submit = filter_input(INPUT_POST, 'submit');
//form data
$fullname = strip_tags (filter_input(INPUT_POST, 'fullname'));
$username = strtolower(strip_tags (filter_input(INPUT_POST, 'username')));
$password = strip_tags(filter_input(INPUT_POST, 'password'));
$repeatpassword = strip_tags(filter_input(INPUT_POST, 'repeatpassword'));
$date = date("Y-m-d");
if ($submit)
{
//open database
$connect=mysql_connect("localhost","root","mypasswordwouldgohere");
mysql_select_db("phplogin");
$namecheck = mysql_query("SELECT username FROM users WHERE username='$username'" );
$count = mysql_num_rows($namecheck);
if($count!=0)
{
die("Username already taken, please choose another");
}
//check for existence
if($fullname&&$username&&$password&&$repeatpassword)
{
if ($password==$repeatpassword)
{
//check char length of username and fullname
if (strlen($username)>25||strlen($fullname)>25)
{
echo "Length of username or full name is too long!";
}
else
{
//check password length
if (strlen ($password)>25 || strlen ($password)<6)
{
echo "Password must be between 6 and 25 characters";
}
else
{
$password = md5($password);
//register user
$queryreg = mysql_query("INSERT INTO users VALUES ('','$fullname','$username','$password','$date',)");
die ("You have been registered! <a href='index.php'>Return to the login page</a>");
}
}
}
else echo "Your passwords do not match";
}
else echo "Please fill in <b>all</b> fields!";
}
?>
<p>
<html>
<form action='register.php' method='POST'>
<table>
<tr>
<td>
Your full name:
</td>
<td>
<input type='text' name='fullname' value='<?php echo $fullname;?>'>
</td>
</tr>
<tr>
<td>
choose a username:
</td>
<td>
<input type='text' name='username' value='<?php echo $username;?>'>
</td>
</tr>
<tr>
<td>
Choose a password:
</td>
<td>
<input type='password' name='password'>
</td>
</tr>
<tr>
<td>
Repeat your password:
</td>
<td>
<input type='password' name='repeatpassword'>
</td>
</tr>
<table>
<p>
<input type='submit' name='submit' value='Register'>
</form>
You have SQL Syntax error
"INSERT INTO users VALUES ('','$fullname','$username','$password','$date',)"here. Remove last ‘,’ in your query.