Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'common.php';
- session_start();
- $sn = session_id();
- $expire_period = time()+60*60;
- //$login_success = false;
- if(isset($_COOKIE['login_success'])){
- if ($_COOKIE['login_success']==true && !isset($_GET['logout'])){
- $extra = "store.php?s=".$sn;
- header("Location: ".directoryURL($extra));
- }
- }
- if(isset($_POST['loginName'])){
- $loginName = $_POST['loginName'];
- $pw = $_POST['pw'];
- //MySQL
- include 'mysqlQuery.php';
- $connet=mysqlConnect();
- //check login Name
- $query = "SELECT pw FROM users WHERE loginName='".$loginName."';";
- $rs=mysqlQuery($query,$connet);
- $errMsg = $errMsg . mysql_error();
- $pws = mysql_fetch_row($rs);
- $rpw = $pws[0];
- mysqlClose($connet);
- //end my SQL
- setcookie("login_success", false, $expire_period);
- if($pw == $rpw){
- //$login_success = true;
- setcookie("login_success", true, $expire_period);
- setcookie("login_time", date(DATE_COOKIE), $expire_period);
- setcookie("session_id", $sn, $expire_period);
- $_SESSION['loginName']=$loginName;
- $extra = "store.php?s=".$sn;
- header("Location: ".directoryURL($extra));
- exit();
- }
- else{
- header( "Location:".$_SERVER['PHP_SELF']."?error=1");
- //echo "fail";
- }
- }
- if(isset($_GET['logout'])){
- setcookie("login_success", '', time()-3600);
- setcookie("login_time", '', time()-3600);
- setcookie("session_id", '', time()-3600);
- //header( "Location:".$_SERVER['PHP_SELF'] );
- //exit();
- }
- ?>
- <html>
- <header>
- <title>Dressing Online Shop</title>
- <link rel="stylesheet" href="css/style.css" type="text/css" />
- <script type="text/javascript" src="./js/form_login.js"></script>
- <script type="text/javascript">
- function display(index) {
- var xmlhttp = new XMLHttpRequest();
- xmlhttp.onreadystatechange=function() {
- if (xmlhttp.readyState==4 && xmlhttp.status==200) {
- document.getElementById("imageDiv").innerHTML=xmlhttp.responseText;
- }
- };
- xmlhttp.open("GET", "advertisement.php", true);
- xmlhttp.send();
- index = (index + 1) % 3;
- setTimeout("display(" + index + ")", 3000);
- }
- </script>
- </header>
- <body onLoad="display(0)">
- <div align="center" class="header">
- Welcome to<br> Dressing Online Shop
- <img src = "fashion.jpg"/>
- </div>
- <div align="center">
- <p class = "description">Please login to continue <a href="registration.php">New User?</a> </p>
- <form name="frm_login" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
- <table width="500" border="0" cellspacing="5" cellpadding="5">
- <tr>
- <td rowspan="3" scope="col"><div align="center" id="imageDiv" ></div></th>
- <td id="lgn">Username : </td>
- <td><input name="loginName" type="text"></td>
- </tr>
- <tr>
- <td id="pw" >Password : </td>
- <td><input name="pw" type="password"></td>
- </tr>
- <tr>
- <td><input type="submit" value="Login" onClick="return validate()"></td>
- <td><?php
- if(isset($_GET['error'])){
- echo "Wrong Login name or password.";
- }
- if(isset($_GET['logout'])){
- echo "You have logged out sucessfully.";
- }
- ?></td>
- </tr>
- </table>
- </form>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement