0

hi!
I have prbleme is that how can apache recieve email and how I can add session it mean that the person can not add or delete or do any evenement before he login .

<?PHP
session_start();
include("connexion.php");
if (isset($_POST['login'])and isset($_POST['password']))
{
extract($_POST);
    if (empty($login) or empty($password))
    {
        echo "  sorry ,to connect you should to entre the both password and login ";
    }
    else
    { 


$result1 = mysql_query("select * from admin where login='$login' and password='$password'");       
        
		if(mysql_num_rows($result1)==true)
        {header("location:client.php"); 
        }
        else
        {		
      echo " sorry your password or login is not correct ";
            
        }
    }
} 
	
?>
4
Contributors
10
Replies
11
Views
7 Years
Discussion Span
Last Post by smi ensi
0

means you want to know how session works??

you can check session and if not found send user to login page.

if( !isset($_SESSION['admin_login']) && !$_SESSION['admin_login'])
{
    header("location:login.php"); 
}

during login you can set settion value like below.

session_start();
include("connexion.php");
if (isset($_POST['login'])and isset($_POST['password']))
{
extract($_POST);
    if (empty($login) or empty($password))
    {
        echo "  sorry ,to connect you should to entre the both password and login ";
    }
    else
    { 


		$result1 = mysql_query("select * from admin where login='$login' and password='$password'");       
        
		if(mysql_num_rows($result1)==true)
        {
			$_SESSION['admin_login'] = true;
			header("location:client.php"); 
        }
        else
        {		
     		echo " sorry your password or login is not correct ";            
        }
    }
}
0

but in the page web client.php what I can add in order to don't get in just after login . ie even if I make link of site client , the systeme tell me that I should login before get in . can you explain to me how ?

0

in web site client.php what I should add in order if any body know the site could not get in before login

0

Basically, you should check if certain session variable exist when the page is being accessed. If that session variable does not exist, then spit a message or take him to login page as vibhadevit said above.

if( !isset($_SESSION['admin_login']) )
{
    echo("Please login first"); 
}
0

ok , in order to well understand look what I write in the page of login:

<?PHP
session_start();
include("connexion.php");
if (isset($_POST['login'])and isset($_POST['password']))
{
extract($_POST);
    if (empty($login) or empty($password))
    {
        echo "  sorry ,to connect you should to entre the both password and login ";
    }
    else
    { 


$result1 = mysql_query("select * from admin where login='$login' and password='$password'");       
$result2 = mysql_query("select * from clientcar where surnom='$login' and cin='$password'");       
         if(mysql_num_rows($result2)==true)
        {header("location:clientel.php"); 
        }

        else if(mysql_num_rows($result1)==true)
        {header("location:client.php"); 
        }
         else
         { 
         echo "<font color='red'>  login or password is not correct </font>";

         }
     }
} 

?>



<form style="margin-left: 68px; width: 570px;" name="loginpassword" method="post"  >login:
&nbsp; &nbsp;
&nbsp; &nbsp; <input name="login" maxlength="50" value="login" type="text" /><br />

  <br />

password:&nbsp;<input name="password" maxlength="20" type="password" /><br />

  <br />

  <centre> <input value="connect" type="submit" />
  </centre>



&nbsp;<br />

</form>

the code of the client.php is

<form id="ajouteclient" method="post" >

 <centre> 
     <div align="left">
       <p class="Style3">&nbsp;</p>
       <p class="Style3">cin is important to delete client from database
         </p>
     </div>
     <table width="200" border="0" align="center">
  <tr>
    <td>nom</td>
    <td><input type="text" name="nom" size="20" value="" maxlength="35"></td>
  </tr>
  <tr>
    <td>prenom</td>
    <td><input type="text" name="prenom" size="20" value="" maxlength="35"></td>
  </tr>
  <tr>
    <td>cin</td>
    <td><input type="text" name="cin" size="20" value="" maxlength="35"></td>
  </tr>
  <tr>
    <td>login</td>
    <td><input type="text" name="surnom" size="20" value="" maxlength="35"></td>
  </tr>
  <tr>
    <td>adresse</td>
    <td><input type="text" name="adresse" size="20" value="" maxlength="35"></td>
  </tr>
  <tr>
    <td>tel</td>
    <td><input type="text" name="tel" size="20" value="" maxlength="35"></td>
  </tr>
  <tr>
    <td>fixe</td>
    <td><input type="text" name="fixe" size="20" value="" maxlength="35"></td>
  </tr>
  <tr>
    <td>email</td>
    <td><input type="text" name="email" size="20" value="" maxlength="35"></td>
  </tr>
  <tr>
    <td>profession </td>
    <td><input type="text" name="work" size="20" value="" maxlength="35"></td>
  </tr>
</table>
<p>&nbsp;</p>
<table width="196" border="0" align="center">
  <tr>
    <td align="left" valign="middle"><input type="submit" value="  next   " /></td>
    <td> <input type="reset" value="  cancel" /></td>
  </tr>
</table>
 <p class="Style1">&nbsp;</p>
 </centre>
</form>
<?php 

if(isset($_POST['nom'])) 

$nom=$_POST['nom'];
else $nom="";

if(isset($_POST['prenom'])) 

$prenom=$_POST['prenom'];
else $prenom="";

if(isset($_POST['email'])) 

$email=$_POST['email'];
else $email="";

if(isset($_POST['adresse'])) 

$adresse=$_POST['adresse'];
else $adresse="";

if(isset($_POST['tel'])) 

$tel=$_POST['tel'];
else $tel="";

if(isset($_POST['cin'])) 

$cin=$_POST['cin'];
else $cin="";

if(isset($_POST['surnom'])) 

$surnom=$_POST['surnom'];
else $surnom="";

if(isset($_POST['work'])) 

$work=$_POST['work'];
else $work="";

if(empty($cin)) 
    { 
    echo " cin ?";
    } 
else
{
$connect = mysql_connect('localhost','root',"") or die ("erreur de connexion");
mysql_select_db('fastcarlocation',$connect) or die ("erreur de connexion base"); 
mysql_query("delete from clientcar where cin='$cin'"); 

header("location:client.php"); 

} 

?> 

can you explain to me how I should add what do you tell me , because admin_login how is defined . I should declared or is name of imput balise ie: login <input type="text" neme="admin_login" /> can you explain to me

Edited by Dani: Formatting fixed

-1

pleassssssssssssssssssssssssssssssssse help meeeeeeeeeeeeeeeeeeeeeeeeeeee!!!!!!!!

0

>pleassssssssssssssssssssssssssssssssse help meeeeeeeeeeeeeeeeeeeeeeeeeeee!!!!!!!!
Bumping your thread with a post like that is not constructive - it's just annoying and is more likely to discourage people from helping you.

0

I want also ask about the function which make the page web expired

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.