register.php
register form
<div class="regform">
<table border='0'>
<tr>
<td align="right"><label>Are you an :</label></td>
<td class="register"> <input type="radio" value="Individual" name="are_you">Individual Or <input type="radio" value="Business" name="are_you">Business ?</td>
</tr>
<tr>
<td align="right"><label for="login_username">Username :</label></td>
<td><input type="text" name="username" id="login_username" class="input" placeholder="Please provide your username" /></td>
</tr>
<tr>
<td align="right"><label for="login_password">Email :</label></td>
<td><input type="text" name="email" id="login_email" class="input" placeholder="Please provide your valid email id" size="30"/></td>
</tr>
<tr>
<td align="right"><label for="login_userpwd">Password :</label></td>
<td><input type="password" name="userpwd" id="login_username" class="input" placeholder="Password is required" size="30" /></td>
</tr>
<tr>
<td align="right"><label for="login_userpwd">Re-enter Password :</label></td>
<td><input type="password" name="userrepwd" id="login_username" class="input" placeholder="Please re-enter your password" size="30" /></td>
</tr>
<tr>
<td align="right"><label for="login_userpwd">Contact Number :</label></td>
<td><input type="text" name="contactno" id="login_username" class="input" placeholder="Please enter your contact number" size="30" /></td>
</tr>
<tr>
<td align="right"><label for="login_userpwd">City :</label></td>
<td><input type="text" name="city" id="login_username" class="input" placeholder="Please provide your city name" size="30"/></td>
</tr>
<tr>
<td align="right"><label for="login_userpwd">Address :</label></td>
<td><input type="text" name="address" id="login_username" class="input" placeholder="Please provide your address" size="30" /></td>
</tr>
<tr>
<td align="center"> </td>
<td><input type="submit" name="submit" value="Create Account" class="submit" id="registerNew" /></td>
</tr>
</table>
</div>
here two type of registration, one is business user and Individual user.business user will permit to access two pages(addarticle.php and addbusiness.php) and Individual user to access only one page(addarticle.php). after registration i have to login. based on that username and password it should go to that particular page.after login it should display logout.
login.php
<?php
ini_set('display_errors','OFF');
include("db.php");
include 'header.php';
session_start();
$business = $_GET['business'];
$article = $_GET['article'];
$abusiness = $_GET['abusiness'];
$myusername = $_POST['username1'];
$mypassword = $_POST['password'];
$are_you = $_POST['are_you'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql = "SELECT * FROM `register` WHERE Username='$myusername' AND Password='$mypassword'";
$result = mysql_query($sql); //are_you_an='$are_you'
$r = mysql_fetch_array($result);
$count = mysql_num_rows($result);
if($count == 1){
// If result matched $myusername and $mypassword, table row must be 1 row
if($business)
{
if($r['are_you_an'] == $business)
{
// Register $myusername, $mypassword and redirect to file "login_success.php"
$userl = $_SESSION['username1'];
session_register("username1");
session_register("password");
echo '<script>window.location="addbusiness.php?city=Bangalore&userid='.$r['Id'].'";</script>';
}
else
{
echo '<script>alert("Wrong Username or Password");
window.location="login.php?business=Business";</script>';
}
}
elseif($article || $abusiness)
{
if($r['are_you_an'] == $article || $r['are_you_an'] == $abusiness)
{
$userl = $_SESSION['username1'];
session_register("username1");
session_register("password");
echo '<script>window.location="addarticle.php?city=Bangalore&userid='.$r['Id'].'";</script>';
}
else
{
echo '<script>alert("Wrong Username or Password");
window.location="login.php?article=Individual&abusiness=Business";</script>';
}
}
else
{
echo '<script>alert("Wrong Username or Password");
window.location="login.php?article=Individual&abusiness=Business&business=Business";</script>';
}
}
?>
<div id="wrapper">
<div class="logincontainer">
<form id="login" method="post" action="">
<h1>Log in to your <strong>Namshimoga</strong> Account!</h1>
<p class="register">Not a Member ? <a href="register.php">Register Here !</a></p>
<?php
if($_SESSION['err'])
{
echo '<div class="err">'.$_SESSION['err'].'</div>';
unset($_SESSION['err']);
}
?>
<div class="login">
<table border='0'>
<!--<tr>
<td align="right"><label>Are you an :</label></td>
<td class="register"> <input type="radio" value="Individual" name="are_you">Individual Or <input type="radio" value="Business" name="are_you">Business ?</td>
</tr>-->
<tr>
<td><label for="username">Username :</label></td>
<td><input type="text" name="username1" id="username1" class="input" title="Invaid Email" size="30"/></td>
</tr>
<tr>
<td><label for="login_password">Password :</label>
<td><input type="password" name="password" id="login_password" class="input" title="Password is required" size="30"/></td>
</tr>
<tr>
<td>
<td><p class="forgot"><a href="forgotpwd.php">Forgot your Password?</a></p></td>
</tr>
<tr>
<td>
<td><input type="submit" id="submit" name="submit" value="Log in" class="submit" /></td>
</tr>
<tr><td colspan="2"align="center"></td>
</tr>
</table>
</div>
</form>
</div>
</div>
<div class="clearfooter"></div>
<?php include("footer.php"); ?>