PHP basic code for register
<?php
$localhost="localhost";
$user="root";
$pass="";
$db="test";
$connect = mysqli_connect('localhost', 'root', '' ,'test');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Books</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="css/layout.css" type="text/css" />
</head>
<body id="top">
<div class="wrapper col0">
<div id="topline">
<p>Name: Books Website</p>
<br class="clear" />
</div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper">
<div id="header">
<div class="fl_left">
<h1><a href="index.html"><strong>T</strong>e<strong> s</strong>T</a></h1>
<p>Welcome to our website</p>
</div>
<br class="clear" />
</div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper col2">
<div id="topbar">
<div id="topnav">
<ul>
<li class="active"><a href="add.php">Add</a></li>
<li><a href="show.php">Show</a></li>
<li><a href="delete.php">Delete</a></li>
<li><a href="register.php">Register</a></li>
<li><a href="login.php">Login</a></li>
</ul>
</div>
<br class="clear" />
</div>
</div>
<!-- ####################################################################################################### -->
<div class="wrapper">
<div class="container">
<div class="content">
<div id="hpage_cats">
<div class="fl_left">
<h2><a href="#">Register »</a></h2>
<h3 class="p2">Registeration Form</h3>
<form method="POST" action="" name="loginForm" >
<table cellpadding="2" cellspacing="2" border="0">
<tr>
<td> Username * </td>
<td> <input type="text" name="username_form" required></td>
</tr>
<tr>
<td> Fullname </td>
<td> <input type="text" name="fullname_form"></td>
</tr>
<tr>
<td> Password * </td>
<td> <input type="password" name="password_form" required></td>
</tr>
<tr>
<td> Confirm Password * </td>
<td> <input type="password" name="confirmpassword_form" required></td>
</tr>
<tr>
<td> Email * </td>
<td> <input type="email" name="email_form" required></td>
</tr>
<tr>
<td> Phone </td>
<td> <input type="tel" name="phone_form"></td>
</tr>
<tr>
<td> Address </td>
<td> <input type="text" name="address_form"></td>
</tr>
</table>
<p> <input type="hidden" name="send" value="send" id="send"/>
<input type="submit" value="Send" />
</p>
<h2 class="p2">You have already acount? ... <a href="login.php">Log In </a></h2>
</form>
</div>
</div></div></div>
<!--==============================PHP=================================-->
<?php
if(isset($_POST["send"]))
{
$sql="INSERT INTO `users` ( `username`, `fullname`, `password`, `confirmpassword`, `email`, `phone`, `address`)
VALUES ( '".$_POST['username_form']."', '".$_POST['fullname_form']."', '".$_POST['password_form']."', '".$_POST['confirmpassword_form']."',
'".$_POST['email_form']."', '".$_POST['phone_form']."', '".$_POST['address_form']."')";
$result=mysqli_query($connect,$sql);
if($result)
echo "Your data has saved";
else
echo "Try again";
}
?>
<!--==============================footer=================================-->
</body>
</html>
No comments:
Post a Comment