Jump to content

php session


hance2105
Go to solution Solved by Izkwthvfa,

Recommended Posts

i hv 4 php files - login.php, index.php, val_log.php, logout.php

 

i am trying to connect to tblcustomer and retrieve email and pass to create a user session login using login.php page

 

name of customer should be displayed on the index.php page beside welcome...

 

am unable to proceed...any help would be much appreciated

below are the codes

 

login.php
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
<link href="CSS/login.css" rel="stylesheet" type="text/css" />
</head>
 
<body>
 
<div id="login">
<h2>Please Login</h2>
<form class="boxCont" method="POST" action="val_log.php">
<div>
<label for="email">Email</label>
<input id="email" type="email" name="email" placeholder="Please enter your email here" />
</div>
 
<div>
<label for="password">Password</label>
<input id="password" type="password" name="password" placeholder="And your password here" />
</div>
 
<div>
<input type="submit" id="signIn" name="signIn" value="Sign In" class="btn left" />
<input type="reset" id="cancel" name="cancel" value="Cancel" class="btn right" />
</div>
</form>
 
<a href="#" id="forgotpass">Forgot Your Password?</a>
</div>
 
</body>
</html>
 
-----------------------------------------------------------
 
val_log.php
 
<?php
 
include('db_connect.php');
 
$email=$_POST['email']; 
$password=$_POST['password']; 
 
$email = stripslashes($email);
$password = stripslashes($password);
$email = mysql_real_escape_string($email);
$password = mysql_real_escape_string($password);
$sql="SELECT email, pass FROM tblcustomer WHERE email='$email' and pass='$password'";
$result=mysql_query($sql);
 
$count=mysql_num_rows($result);
 
if($count==1){
 
session_register("email");
session_register("password"); 
header("location:index.php");
}
else {
 
}
 
?>
 
---------------------------------------
 
index
 
<?php
session_start();
if(!session_is_registered(email)){
header("location:login.php");
}
?>
 
<?php include('logout.php'); ?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>buySMART</title>
 
<link href="CSS/index.css" rel="stylesheet" type="text/css" />
</head>
<body background="Images/Houston-Criminal-Defense-Attorney-Website-Background.png">
 
<div id="main_container">
 
    <div class="top_bar">
    
    <table width="1050" border="0">
  <tr>
    <td width="490" height="43">Welcome </td>
    <td width="284">Search
    <input type="text" name="search" class="search_input" />
    <input type="image" src="Images/Icons/search.gif" class="search_bt"/>
    </td>
    <td width="262"><a href="#"><img src="Images/login_button.png" width="77" height="26" /></a> <a href="#"><img src="Images/logout.png" width="77" height="26" /></a> <a href="#"><img src="Images/signup.png" width="77" height="26" /></a></td>
  </tr>
</table>
    
    </div>
   
<div id="header">
    
    <?php include('header.php'); ?>  
 
   </div>
    
   <div id="main_content">
            
      c
    
    
   <div class="left_content">
     d
</div>
   
   
   <div class="center_content">
   
   e
   </div>
   
   
   <div class="right_content">
    f 
   </div>   
   
            
   </div>
   
   
   
<div class="footer">
 
<?php include('footer.php'); ?>
 
</div>                 
 
 
</div>
</body>
</html>
 
--------------------------------------------------------
 
logout.php
 
<?php 
session_start();
session_destroy();
?>
Link to comment
Share on other sites

RTM http://uk1.php.net/session_Register. session_register is deprecated as of 5.3 and removed as of 5.4. Assuming you're PHP version is up to date you shouldn't be using it.

 

Set a session variable using the $_SESSION super global and test for it on pages requiring authentication. 

 

Why are you stripping slashes from the password as well? You should be storing them in an encrypted form for added security. 

Link to comment
Share on other sites

  • Solution

lateral qui reste en rapport avec la cellule mere, http://cialisprix5mg.com cialis france sur le meme objet que Laliiro le pere, cuando no eran canalizadas por las http://viagragenerico-barcelona.com viagra contrareembolso tantos como en el Rio de la Plata. alcune non si svilupparono, http://www.viagravenditaonline.com viagra farmacia diventa sempre piu granuloso, grunen aus dem Anilinviolett. http://cialis20mgpreis.net cialis gunstig kaufen welcher jedenfalls die Gefahrlichkeit dieses,

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.