This is Signup form for submitting to databse.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>register</title>
<link rel="Stylesheet" type="text/css" href="field.css">
<head>
<body id="body" background="p.jpg">
<form action='index.html' method='post'>
<input type='submit' value='Home' id='button'/>
</form>
<?php
$form = "<form action='signup.php' method='post'>
<fieldset id='field'><legend id='legend'>Signup</legend>
<table id='table'>
<tr>
<td>First Name :</td>
<td><input id='input' type='text' name='firstname' required='required'></td>
</tr>
<br>
<tr>
<td>Last Name :</td>
<td><input id='input' type='text' name='lastname' required='required'></td>
</tr>
<br>
<tr>
<td>User Name :</td>
<td><input id='input' type='text' name='username' required='required'></td>
</tr>
<br>
<tr>
<td>Email :</td>
<td><input id='input' type='text' name='email' required='required'></td>
</tr>
<br>
<tr>
<td>Password :</td>
<td><input id='input' type='text' name='password1' required='required' ></td>
</tr>
<br>
<tr>
<td>Re-type :</td>
<td><input id='input' type='text' name='password2' required='required' ></td>
</tr>
<br>
<tr>
<td><input type='submit' name='signup' value='sign up'></td>
</tr>
</table>
</fieldset>
</form>";
if($_POST['signup']) {
$username = $_POST['username'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
if(strlen($password1)<12) {
if($password1 == $password2) {
require ("connect.php");
$password = md5(md5("n5cf7h".$password."me8ye3"));
//make sure registration info is already exist or not
$query = mysql_query("SELECT * FROM users WHERE username = '$username' OR email = '$email'");
$numrows = mysql_num_rows($query);
if ($numrows != 1){
require ("db.php");
}
else
echo "<font size='5' color='red'>either username or email already exist</font> $form";
}
else
echo "<font size='5' color='red'>password didn't match.</font> $form";
}
else
echo "<font size='5' color='red'>password should be 6 - 12 characters.</font> $form";
}
else
echo $form;
?>
</body>
</html>
This is connect.php for connecting to database.
<?php
mysql_connect ("localhost","root","password");
mysql_select_db ("login"); //login is name of database
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>register</title>
<link rel="Stylesheet" type="text/css" href="field.css">
<head>
<body id="body" background="p.jpg">
<form action='index.html' method='post'>
<input type='submit' value='Home' id='button'/>
</form>
<?php
$form = "<form action='signup.php' method='post'>
<fieldset id='field'><legend id='legend'>Signup</legend>
<table id='table'>
<tr>
<td>First Name :</td>
<td><input id='input' type='text' name='firstname' required='required'></td>
</tr>
<br>
<tr>
<td>Last Name :</td>
<td><input id='input' type='text' name='lastname' required='required'></td>
</tr>
<br>
<tr>
<td>User Name :</td>
<td><input id='input' type='text' name='username' required='required'></td>
</tr>
<br>
<tr>
<td>Email :</td>
<td><input id='input' type='text' name='email' required='required'></td>
</tr>
<br>
<tr>
<td>Password :</td>
<td><input id='input' type='text' name='password1' required='required' ></td>
</tr>
<br>
<tr>
<td>Re-type :</td>
<td><input id='input' type='text' name='password2' required='required' ></td>
</tr>
<br>
<tr>
<td><input type='submit' name='signup' value='sign up'></td>
</tr>
</table>
</fieldset>
</form>";
if($_POST['signup']) {
$username = $_POST['username'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
if(strlen($password1)<12) {
if($password1 == $password2) {
require ("connect.php");
$password = md5(md5("n5cf7h".$password."me8ye3"));
//make sure registration info is already exist or not
$query = mysql_query("SELECT * FROM users WHERE username = '$username' OR email = '$email'");
$numrows = mysql_num_rows($query);
if ($numrows != 1){
require ("db.php");
}
else
echo "<font size='5' color='red'>either username or email already exist</font> $form";
}
else
echo "<font size='5' color='red'>password didn't match.</font> $form";
}
else
echo "<font size='5' color='red'>password should be 6 - 12 characters.</font> $form";
}
else
echo $form;
?>
</body>
</html>
This is connect.php for connecting to database.
<?php
mysql_connect ("localhost","root","password");
mysql_select_db ("login"); //login is name of database
?>
No comments:
Post a Comment