Member Registration
Posted: Wed Dec 08, 2010 4:57 am
Hi I was wondering if anybody might be able to help me with a member registration page I have been having difficulty with. I am new to the language and not sure exactly where I'm going wrong.
I have a mysql database called beat with fields fullname, password and username.
However the page is throwing the following errors on load.
Notice: Undefined index: submit in (filename) on line 4
Notice: Undefined index: filename in (filename) on line 8
Notice: Undefined index: username in (filename) on line 9
Notice: Undefined index: password in (filename) on line 11
Notice: Undefined index: repeatpassword in (filename) on line 12
The page will move to the next on submit and valadation is upheld. However data is not passed to the db.
Any help you could offer would be greatly apreciated.
<?php
echo "<h1>Register</h1>";
$submit = $_POST['submit'];
//form data
$fullname = strip_tags($_POST['fullname']);
$username = strtolower(strip_tags ($_POST['username']));
$password = strip_tags($_POST['password']);
$repeatpassword = strip_tags($_POST['repeatpassword']);
$date = date ("Y-m-d");
if ($submit)
{
//connect to database
$connect = mysql_connect("localhost","root","");
mysql_select_db("beat");//select database
$namecheck = mysql_query ("Select username FROM users where username='$username'");
$count = mysql_num_rows($namecheck);
if ($count!=0)
{
die("Username already exists");
}
//check for existance
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 fullname is too long";
}
else
{
//check password length
if (strlen($password)>11||strlen($password)<6)
{
echo "Password must be between 6 & 11 characters";
}
else
{
//encrypt password
//$password = md5($password);
//$repeatpassword = md5($repeatpassword);
$queryreg = mysql_query("
Insert INTO users VALUES ('', '$fullname','$username','$password','$date')
");
die("You have been registered. <a href=' index_1.php'>Return to login page</a>");
}
}
}
else
echo "Your passwords do not match";
}
else
echo "Please fill in <b>all</b> fields";
}
?>
<html>
<p>
<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 Password:
</td>
<td>
<input type='password' name='repeatpassword'>
</td>
</tr>
</table>
<p>
<input type='submit' name='submit' value='Register'>
</form>
I have a mysql database called beat with fields fullname, password and username.
However the page is throwing the following errors on load.
Notice: Undefined index: submit in (filename) on line 4
Notice: Undefined index: filename in (filename) on line 8
Notice: Undefined index: username in (filename) on line 9
Notice: Undefined index: password in (filename) on line 11
Notice: Undefined index: repeatpassword in (filename) on line 12
The page will move to the next on submit and valadation is upheld. However data is not passed to the db.
Any help you could offer would be greatly apreciated.
<?php
echo "<h1>Register</h1>";
$submit = $_POST['submit'];
//form data
$fullname = strip_tags($_POST['fullname']);
$username = strtolower(strip_tags ($_POST['username']));
$password = strip_tags($_POST['password']);
$repeatpassword = strip_tags($_POST['repeatpassword']);
$date = date ("Y-m-d");
if ($submit)
{
//connect to database
$connect = mysql_connect("localhost","root","");
mysql_select_db("beat");//select database
$namecheck = mysql_query ("Select username FROM users where username='$username'");
$count = mysql_num_rows($namecheck);
if ($count!=0)
{
die("Username already exists");
}
//check for existance
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 fullname is too long";
}
else
{
//check password length
if (strlen($password)>11||strlen($password)<6)
{
echo "Password must be between 6 & 11 characters";
}
else
{
//encrypt password
//$password = md5($password);
//$repeatpassword = md5($repeatpassword);
$queryreg = mysql_query("
Insert INTO users VALUES ('', '$fullname','$username','$password','$date')
");
die("You have been registered. <a href=' index_1.php'>Return to login page</a>");
}
}
}
else
echo "Your passwords do not match";
}
else
echo "Please fill in <b>all</b> fields";
}
?>
<html>
<p>
<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 Password:
</td>
<td>
<input type='password' name='repeatpassword'>
</td>
</tr>
</table>
<p>
<input type='submit' name='submit' value='Register'>
</form>