Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php // best practice: always have <?php at the top
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root"; // Mysql password
$db_name="account"; // Database name
// Connect to server and select databse.
$db = new mysqli($host, $username, $password, $db_name);
// username and password sent from form
$email=$_POST['email'];
$password=$_POST['password'];
// To protect MySQL injection (more detail about MySQL injection)
$statement = $db->prepare('SELECT * FROM `member` WHERE `email` = ? AND `password` = ?');
$statement->bind_param('ss', $email, $password);
$statement->execute();
// Mysql_num_row is counting table row
$result = $statement->get_result();
// If result matched $username and $password, table row must be 1 row
if($result->num_rows == 0) {
$url = '../index.php';
} elseif (!array_key_exists('prod_id', $_POST)) {
$url = '../members/' . urlencode($email) . '/index.php';
} else {
$url = '../members/' . urlencode($email) . '/checkout.php?id=' . urlencode($_POST['prod_id']);
}
header("Location: $url");
exit();
?>
<html>
<head>
<style>
body{background-color: #DF0000; color: #FFF;}
h1{ color: #FFF}
h2{color: #FFF;}
</style>
</head>
<body>
<div align="center">
<div align="right" style="width:1024">
<h2>
<a href="index.html">Home</a> |
<a href="login.php">My Account</a> |
<a href="login.php">My Cart</a> |
<a href="login.php">Chekout</a> |
<a href="login.php">Login</a>
</h2>
</div>
<div align="center">
<p align="center"><img src="#" width="1024" height="512" />
<br>
<p align="left">
<h3>Please log in to your account first.</h3>
</p></p>
</div>
<div align="center" style="width:1024">
<font color="#FFFFFF">
<table width="90%" cellspacing="05" cellpadding="05">
<tr>
<td>
<table width="460.8" height="600" cellspacing="05" cellpadding="05" bgcolor="#333333">
<tr style="height:100">
<td>
<h2>Create an Account</h2>
<hr>
<h4><font color="#FFFFFF">PERSONAL INFORMATION</font> </h4>
</td>
</tr>
<tr>
<td>
<form name="home" method="post" action="Registration/registration.php">
<p>
Title :
<select name="select">
<option value="Mr.">Mr.</option>
<option value="Mrs.">Mrs.</option>
</select>
</p>
<p>First Name : <input type="text" name="fname" value=""></p>
<p>Last Name : <input type="text" name="lname" value=""></p>
<p>&nbsp;</p>
<p>Email Address :</p>
<input type="text" name="email" id="email" value="" size="40">
<input type="hidden" value="<?php echo $_GET['id']; ?>" name="prod_id">
<p>Confirm Email Address :</p>
<p>
<input type="text" name="cemail" id="cemail" value="" size="40">
</p>
<p>&nbsp;</p>
<table>
<tr>
<td>Password</td>
<td>:</td>
<td><input type="password" name="password" id="password" value=""></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>Confirm password</td>
<td>:</td>
<td><input type="password" name="cpassword" id="cpassword" value=""></td>
</tr>
</table>
<br />
<input type="submit" name="submit" value="Submit">
</form>
</td>
</tr>
</table>
</td>
<td>
<table width="460.8" height="600" cellpadding="05" cellspacing="05" bgcolor="#333333">
<tr height="100">
<td>
<h2>REGISTERED CUSTOMERS</h2>
<hr>
<h4>If you have an account with us, please log in.</h4>
</td>
</tr>
<tr>
<td>
<form name="form1" method="post" action="Login/checklogin.php">
<table>
<tr>
<td>Email Address : </td>
</tr>
<tr>
<td><input name="email" type="text" id="email" size="40"></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>Password : </td>
</tr>
<tr>
<td>
<input name="password" type="password" id="password" size="40">
<input type="hidden" value="<?php echo isset($_GET['id'])?($_GET['id']):"no_id"; ?>" name="prod_id">
</td>
</tr>
<tr>
<td><br /> <a href="#">Forgot your password?</a> <br /></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="LOGIN"></td>
</tr>
</table>
</form>
<p align="center"><img src="#" width="350" height="250">
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</font>
</div>
<div align="center">
<table width="1024" height="45">
<tr>
<td width="1024" height="45" bgcolor="#000000">
<h2>
<center>&#169;2014 copyright by All Rights Reserved.</center>
</h2>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment