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 ";
            
        }
    }
} 
	
?>

Dani AI

Generated

A few clarifications and practical fixes that aren’t in the thread yet.

Apache is a web server; it does not “receive e‑mail.” To accept mail on the same machine you need a mail server (Postfix/Exim/Sendmail) or a hosted provider. Web apps can then either (a) read a mailbox via IMAP (see PHP IMAP) or (b) have the MTA pipe incoming mail to a script. To send mail from PHP use the mail function or a library like PHPMailer.

Session/login enforcement

  • and are correct: set a server-side session value after validating credentials, and check that value on every protected page. Session values are created on the server after login — they are not the same as input field names.
  • Put the authentication check at the very top of each protected file (before any HTML) or include a single auth.php at the top. If any output is sent before you call header('Location: ...') the redirect will fail (headers already sent).
  • Regenerate the session id on successful login to prevent fixation, and always exit right after a redirect.

Examples you can adapt:

<?php
// on login success
session_start();
session_regenerate_id(true);
$_SESSION['uid'] = $dbUserId;
$_SESSION['role'] = 'admin';
header('Location: client.php');
exit;
?>
<?php
// include at top of client.php
session_start();
if (empty($_SESSION['uid'])) { header('Location: login.php'); exit; }
?>

Auto‑logout / expire page

  • Track $_SESSION['LAST_ACTIVITY'] and destroy the session after N seconds of inactivity (see example pattern above).

Security notes

  • Stop using old mysql_* calls. Use PDO or mysqli with prepared statements (PDO prepare).
  • Never store plain passwords — use password_hash() / password_verify() (see password_hash).
  • For destructive actions (delete), require POST, check the user role, and add a CSRF token and confirmation.

Recommended Answers

All 10 Replies

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 ";            
        }
    }
}

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 ?

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

help me please !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

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"); 
}

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

pleassssssssssssssssssssssssssssssssse help meeeeeeeeeeeeeeeeeeeeeeeeeeee!!!!!!!!

>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.

I don't see any probleme .

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.