Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hiimdoublej committed May 27, 2016
0 parents commit 3b01253
Show file tree
Hide file tree
Showing 6 changed files with 290 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dbconnect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
if(!mysql_connect("localhost","root","Ladiesman41&"))
{
die('oops connection problem ! --> '.mysql_error());
}
if(!mysql_select_db("dbtest"))
{
die('oops database selection problem ! --> '.mysql_error());
}
?>
31 changes: 31 additions & 0 deletions home.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
session_start();
include_once 'dbconnect.php';

if(!isset($_SESSION['user']))
{
header("Location: index.php");
}
$res=mysql_query("SELECT * FROM users WHERE user_id=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome - <?php echo $userRow['email']; ?></title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id="header">
<div id="left">
<label>cleartuts</label>
</div>
<div id="right">
<div id="content">
hi' <?php echo $userRow['username']; ?>&nbsp;<a href="logout.php?logout">Sign Out</a>
</div>
</div>
</div>
</body>
</html>
58 changes: 58 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
session_start();
include_once 'dbconnect.php';

if(isset($_SESSION['user'])!="")
{
header("Location: home.php");
}
if(isset($_POST['btn-login']))
{
$email = mysql_real_escape_string($_POST['email']);
$upass = mysql_real_escape_string($_POST['pass']);
$res=mysql_query("SELECT * FROM users WHERE email='$email'");
$row=mysql_fetch_array($res);
if($row['password']==md5($upass))
{
$_SESSION['user'] = $row['user_id'];
header("Location:home.php");
}
else
{
?>
<script>alert('wrong details');</script>
<?php
}

}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>cleartuts - Login & Registration System</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<center>
<div id="login-form">
<form method="post">
<table align="center" width="30%" border="0">
<tr>
<td><input type="text" name="email" placeholder="Your Email" required /></td>
</tr>
<tr>
<td><input type="password" name="pass" placeholder="Your Password" required /></td>
</tr>
<tr>
<td><button type="submit" name="btn-login">Sign In</button></td>
</tr>
<tr>
<td><a href="register.php">Sign Up Here</a></td>
</tr>
</table>
</form>
</div>
</center>
</body>
</html>
19 changes: 19 additions & 0 deletions logout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
session_start();

if(!isset($_SESSION['user']))
{
header("Location: index.php");
}
else if(isset($_SESSION['user'])!="")
{
header("Location: home.php");
}

if(isset($_GET['logout']))
{
session_destroy();
unset($_SESSION['user']);
header("Location: index.php");
}
?>
62 changes: 62 additions & 0 deletions register.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
session_start();
if(isset($_SESSION['user'])!="")
{
header("Location: home.php");
}
include_once 'dbconnect.php';

if(isset($_POST['btn-signup']))
{
$uname = mysql_real_escape_string($_POST['uname']);
$email = mysql_real_escape_string($_POST['email']);
$upass = md5(mysql_real_escape_string($_POST['pass']));

if(mysql_query("INSERT INTO users(username,email,password) VALUES('$uname','$email','$upass')"))
{
?>
<script>alert('successfully registered ');</script>
<?php
}
else
{
?>
<script>alert('error while registering you...');</script>
<?php
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login & Registration System</title>
<link rel="stylesheet" href="style.css" type="text/css" />

</head>
<body>
<center>
<div id="login-form">
<form method="post">
<table align="center" width="30%" border="0">
<tr>
<td><input type="text" name="uname" placeholder="User Name" required /></td>
</tr>
<tr>
<td><input type="email" name="email" placeholder="Your Email" required /></td>
</tr>
<tr>
<td><input type="password" name="pass" placeholder="Your Password" required /></td>
</tr>
<tr>
<td><button type="submit" name="btn-signup">Sign Me Up</button></td>
</tr>
<tr>
<td><a href="index.php">Sign In Here</a></td>
</tr>
</table>
</form>
</div>
</center>
</body>
</html>
110 changes: 110 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
@charset "utf-8";
/* CSS Document */

*
{
margin:0;
padding:0;
}
#login-form
{
margin-top:70px;
}
table
{
border:solid #dcdcdc 1px;
padding:25px;
box-shadow: 0px 0px 1px rgba(0,0,0,0.2);
}
table tr,td
{
padding:15px;
//border:solid #e1e1e1 1px;
}
table tr td input
{
width:97%;
height:45px;
border:solid #e1e1e1 1px;
border-radius:3px;
padding-left:10px;
font-family:Verdana, Geneva, sans-serif;
font-size:16px;
background:#f9f9f9;
transition-duration:0.5s;
box-shadow: inset 0px 0px 1px rgba(0,0,0,0.4);
}

table tr td button
{
width:100%;
height:45px;
border:0px;
background:#db8d00;
background:-moz-linear-gradient(top, #595959 , #515151);
border-radius:3px;
box-shadow: 1px 1px 1px rgba(1,0,0,0.2);
color:#f9f9f9;
font-family:Verdana, Geneva, sans-serif;
font-size:18px;
font-weight:bolder;
text-transform:uppercase;
}
table tr td button:active
{
position:relative;
top:1px;
}
table tr td a
{
text-decoration:none;
color:#00a2d1;
font-family:Verdana, Geneva, sans-serif;
font-size:18px;
}

/* css for home page */

*
{
margin:0;
padding:0;
}
#header
{
width:100%;
height:60px;
background:rgba(00,11,22,33);
color:#9fa8b0;
font-family:Verdana, Geneva, sans-serif;
}
#header #left
{
float:left;
position:relative;
}
#header #left label
{
position:relative;
top:5px;
left:100px;
font-size:35px;
}
#header #right
{
float:right;
position:relative;
}
#header #right #content
{
position:relative;
top:20px;
right:100px;
color:#fff;
}
#header #right #content a
{
color:#00a2d1;
}

/* css for home page */

0 comments on commit 3b01253

Please sign in to comment.