Example: 1
register.php
<?php
echo "<h1> Register</h1>";
$submit = $_POST['submit'];
//form data
$fullname = strip_tags($_POST['fullname']);
$username = strip_tags($_POST['username ']);
$password = strip_tags($_POST['password ']);
$repeatpassword =strip_tags($_POST['repeatpassword ']);
$date = date("y-m-d");
if($submit)
{
// check for existance
if($fullname && $username && $password && $repeatpassword)
{
//encrypt password
$password = md5($password);
$repeatpassword = md5($repeatpassword);
if($password == $repeatpassword)
{
//chech char length of username and fullname
if(strlen($username) >25 || strlen ($fullname)>25)
{
echo "Length of username or fullname is too long!";
}
else
if(strlen($password) >25 || strlen ($password)<6)
{
echo "Password must be between 6 and 25 characters";
}
else
{
//register the user
echo "Success!!";
}
}
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'></td>
</tr>
<tr>
<td>Choose a username : </td>
<td><input type='text' name='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>
<p>
<input type='submit' name='submit' value='Register'>
</table>
</form>
</html>
Example: 2
register.php
<?php
echo "<h1> Register</h1>";
$submit = $_POST['submit'];
//form data
$fullname = strip_tags($_POST['fullname']);
$username = strip_tags($_POST['username ']);
$password = strip_tags($_POST['password ']);
$repeatpassword =strip_tags($_POST['repeatpassword ']);
$date = date("y-m-d");
if($submit)
{
// check for existance
if($fullname && $username && $password && $repeatpassword)
{
//encrypt password
$password = md5($password);
$repeatpassword = md5($repeatpassword);
if($password == $repeatpassword)
{
//chech char length of username and fullname
if(strlen($username) >25 || strlen ($fullname)>25)
{
echo "Length of username or fullname is too long!";
}
else
if(strlen($password) >25 || strlen ($password)<6)
{
echo "Password must be between 6 and 25 characters";
}
else
{
//register the user
echo "Success!!";
}
}
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 your password : </td>
<td><input type='password' name='repeatpassword'></td>
</tr>
<p>
<input type='submit' name='submit' value='Register'>
</table>
</form>
</html>
Example 3
register.php
<?php
echo "<h1> Register</h1>";
$submit = $_POST['submit'];
//form data
$fullname = strip_tags($_POST['fullname']);
$username = strip_tags($_POST['username ']);
$password = strip_tags($_POST['password ']);
$repeatpassword =strip_tags($_POST['repeatpassword ']);
$date = date("y-m-d");
if($submit)
{
// check for existance
if($fullname && $username && $password && $repeatpassword)
{
//encrypt password
$password = md5($password);
$repeatpassword = md5($repeatpassword);
if($password == $repeatpassword)
{
//chech char length of username and fullname
if(strlen($username) >25 || strlen ($fullname)>25)
{
echo "Length of username or fullname is too long!";
}
else
if(strlen($password) >25 || strlen ($password)>6)
{
echo "Password must be between 6 and 25 characters";
}
else
{
//register the user
echo "Success!!";
}
}
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 your password : </td>
<td><input type='password' name='repeatpassword'></td>
</tr>
<p>
<input type='submit' name='submit' value='Register'>
</table>
</form>
</html>
Example 4
register.php
<?php
echo "<h1> Register</h1>";
$submit = $_POST['submit'];
//form data
$fullname = strip_tags($_POST['fullname']);
$username = strip_tags($_POST['username ']);
$password = strip_tags($_POST['password ']);
$repeatpassword =strip_tags($_POST['repeatpassword ']);
$date = date("y-m-d");
if($submit)
{
// check for existance
if($fullname && $username && $password && $repeatpassword)
{
if($password == $repeatpassword)
{
//chech char length of username and fullname
if(strlen($username) >25 || strlen ($fullname)>25)
{
echo "Length of username or fullname is too long!";
}
else
if(strlen($password) >25 || strlen ($password)>6)
{
echo "Password must be between 6 and 25 characters";
}
else
{
//encrypt password
$password = md5($password);
$repeatpassword = md5($repeatpassword);
//register the user
echo "Success!!";
}
}
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 your password : </td>
<td><input type='password' name='repeatpassword'></td>
</tr>
<p>
<input type='submit' name='submit' value='Register'>
</table>
</form>
</html>
Example 5
register.php
<?php
echo "<h1> Register</h1>";
$submit = $_POST['submit'];
//form data
$fullname = strip_tags($_POST['fullname']);
$username = strip_tags($_POST['username ']);
$password = strip_tags($_POST['password ']);
$repeatpassword =strip_tags($_POST['repeatpassword ']);
$date = date("y-m-d");
if($submit)
{
// check for existance
if($fullname && $username && $password && $repeatpassword)
{
if($password == $repeatpassword)
{
//chech char length of username and fullname
if(strlen($username) >25 || strlen ($fullname)>25)
{
echo "Length of username or fullname is too long!";
}
else
if(strlen($password) >25 || strlen ($password)>6)
{
echo "Password must be between 6 and 25 characters";
}
else
{
//encrypt password
$password = md5($password);
$repeatpassword = md5($repeatpassword);
//register the user
$connect = mysql_connect ("localhost","root","");
mysql_select_db("phplogin");
$queryreg = mysql_query("
INSERT INTO user VALUES ('','$name','$username','$password','$data')
");
die("You have been registerd! <a href = 'index.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 your password : </td>
<td><input type='password' name='repeatpassword'></td>
</tr>
<p>
<input type='submit' name='submit' value='Register'>
</table>
</form>
</html>

No comments:
Post a Comment