Authentification avec delai

cs_esteller Messages postés 49 Date d'inscription mardi 8 septembre 2009 Statut Membre Dernière intervention 26 novembre 2012 - 21 juin 2010 à 12:47
cs_esteller Messages postés 49 Date d'inscription mardi 8 septembre 2009 Statut Membre Dernière intervention 26 novembre 2012 - 21 juin 2010 à 18:46
Bonjour à tous.s'il vous plait j'ai ecrit un code pour une authentification de 15 secondes et ca ne fonctionne pas.apres les 15 secondes s'il n'a pas pu s'authentifier alors l'authentification est annulé.voici mon code:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
var autoCloseTimer;
var timeoutObject;
var timePeriod = 5000; // 5 seconds
var warnPeriod = 15000; // 15 seconds

function promptForClose()
{
autoCloseDiv.style.display = 'block';
autoCloseTimer = setTimeout("definitelyClose()",warnPeriod);
}

function autoClose()
{
autoCloseDiv.style.display = 'block'; //shows message on page
autoCloseTimer = setTimeout("definitelyClose()",timePeriod); //starts countdown to closure
}
function cancelClose()
{
clearTimeout(autoCloseTimer); //stops auto-close timer
autoCloseDiv.style.display = 'none'; //hides message
}

function resetTimeout()
{
clearTimeout(timeoutObject); //stops timer
timeoutObject = setTimeout("promptForClose()",timePeriod); //restarts timer from 0
}
function definitelyClose() {
top.opener = self;
top.window.close();
}
-->
</SCRIPT>

</head>



<center>Inactivity warning!
This window will autoclose in 15 seconds unless you hit 'Cancel.'




</center>


<?php
function afficherformulaire ($u '', $error '')
{
if ($error != '')
echo '' . $error . '';
?>
<form name="form1" action="<?php echo $_SERVER['PHP_SELF']; ?>"
method="POST">
Formulaire de
connexion
,
----
Nom d'utilisateur :,
">,
----
Mot de passe :,
,
----


</form>
<script type="text/JavaScript">
function onValider()
{
if (document.form1.utilisateur.value == '') {
alert("Veuiller taper un nom d'utilisateur.");
return false;
}
if (document.form1.password.value == '') {
alert("Veuiller taper un mot de passe.");
return false;
}
return true ;
}
</script>
<?php
} //fin de la fonction afficherformulaire()
if (!isset ($_POST["valider"]) && !isset($_POST['annuler']))
{
afficherformulaire();
}
if (isset($_POST["annuler"]))
{
header("Location:Annuler.php");
$utilisateur="";
$password="";
}
if (isset($_POST["valider"]))
{
require_once("Connexion.php");
$query = "select login,password from user where login='" .
addslashes($_POST["utilisateur"]) . "' and password = '"
. addslashes($_POST["password"]) . "'";
$result = mysql_query($query) or die();
if(mysql_num_rows($result)>0)
{
header("location:Accueil.php");
}
else
{
afficherformulaire($_POST["utilisateur"],
"Nom d'utilisateur ou mot de passe incorrect");
}
}
//Fin du fichier
?>

aidez moi svp

2 réponses

cs_esteller Messages postés 49 Date d'inscription mardi 8 septembre 2009 Statut Membre Dernière intervention 26 novembre 2012
21 juin 2010 à 18:43
Bonjour à tous.s'il vous plait j'ai ecrit un code pour une authentification de 15 secondes et ca ne fonctionne pas.apres les 15 secondes s'il n'a pas pu s'authentifier alors l'authentification est annulé.voici mon code:

<?php
function afficherformulaire($nom='',$prenom='',$genre=1,$datnais='',$datemb='',$salbrut=''            ,$sitmat=1,$nbenf='',$numtel='',$email='',$photo='',$loisir1=1,$loisir2=1,$loisir3=1,   	$loisir4=1,$loisir5=1,$loisir6=1,$loisir7=1,$error='')
{
  if ($error!='') echo ''.$error.'';
?>
<?php
   function checkForm()
    {
   $tabChamps = array('nom', 'prenom','genre','datnais','datemb', 'salbrut','sitmat','loisir1',  'loisir2','loisir3','loisir4','loisir5','loisir6','loisir7','nbenf', 'numtel', 'email','photo');

   for($i=0; $i<count($tabChamps); $i++)
         if(empty($_POST[$tabChamps[$i]]))
           {
  echo $tabChamps[$i]." n'a pas été renseigné";
  return false;
  afficherformulaire($_POST['nom'],$_POST['prenom'],$_POST['genre'],$_POST['datnais'],
$_POST['datemb'],$_POST['salbrut'],$_POST['sitmat'],$_POST['loisir1'],$_POST['loisir2'],  $_POST['loisir3'],$_POST['loisir4'],$_POST['loisir5'],$_POST['loisir6'],$_POST['loisir7'],$_POST['nbenf'],
$_POST['numtel'],$_POST['email'],$_FILES['photo'],$error);
die();
        }

   echo 'Le formulaire a bien été rempli';
   return true;
   }
?>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" 

 		method="POST">

NOM:">
PRENOMS:">
GENRE:>                      Masculin
>Feminin
DATE DE NAISSANCE:">
DATE D'EMBAUCHE:">
SALAIRE BRUT:">
SITUATION MATRIMONIALE:>Célibataire
>Marié
>Veuf(ve)
>Divorcé
LOISIR1:>Cinéma
>N'aime pas Cinéma


LOISIR2:>Musique
>N'aime pas Musique
LOISIR3:>Litterature
>N'aime pas Litteraure
LOISIR4:>Sport
>N'aime pas Sport
LOISIR5:>Religion
>N'aime pas Religion
LOISIR6:>Religion
>N'aime pas Religion
LOISIR7:>Politique
>N'aime pas Politique
NOMBRE D'ENFANTS:">
NUMERO DE TELEPHONE:">
EMAIL:">
PHOTO:

</form>
<?php
}
?>
<?php
if(!isset($_POST['Valider']))
{
afficherformulaire();
die();
}
if(isset($_POST['Valider']))
{
checkForm();
}

$dossierphotos="photo"; // dossier des photos
if($_FILES["photo"]["error"]!=0)
{
$error="Erreur lors du chargement du fichier";
afficherformulaire($_POST['nom'],$_POST['prenom'],$_POST['nbenf'],$_POST['salbrut'],                  $error);
die;
}
$destinationfile=$dossierphotos.'/'.$_FILES["photo"]["name"];
while (is_file(destinationfile))
$destinationfile=$dossierphotos.'/'.rand(0,1000).$_FILES["photo"]["name"];
$b=move_uploaded_file($_FILES["photo"]["trop_name"],$destinationfile);
if (!$b)
{
$error="Erruer lors de l'enregistrement de photo";
afficherformulaire($_POST['nom'],$_POST['prenom'],$_POST['mus'],$_POST['tel'],$error);
die;}

afficherformulaire($_POST['nom'],$_POST['prenom'],$_POST['numtel'],$_POST['salbrut'],                                       $error);

require_once ("connexion1.php");
$link = mysql_connect ($host, $username, $password) or die (mysql_errno() ." : ".         mysql_error());
$db=mysql_select_db($dbasename,$link); // ou $db=mysql_select_db(dbasename);
$query="INSERT INTO      		  employe1(Nom,Prenoms,Genre,DateNaissance,DateEmbauche,SalaireBrut,SituationMatrimoniale,NombreEnfant,
NumTel,Email,Photo,Loisir1,Loisir2,Loisir3,Loisir4,Loisir5,Loisir6,Loisir7) VALUES('".$_POST['nom']."','".$_POST['prenom']."','".$_POST['datnais']."',".$_POST['datemb'].",". $_POST['salbrut'].",'".$_POST['sitmat']."',". $_POST['nbenf'].",'".$_POST['numtel']."','".$_POST['emal']."','".$destinationfile."','".$_POST['loisir1'].",'".$_POST['loisir2'].",'".$_POST['loisir3'].",'".$_POST['loisir4'].",'".$_POST['loisir5'].",'".$_POST['loisir6'].",'".$_POST['loisir7']."')";
$result=mysql_query($query);
  ?>


aidez moi svp
0
cs_esteller Messages postés 49 Date d'inscription mardi 8 septembre 2009 Statut Membre Dernière intervention 26 novembre 2012
21 juin 2010 à 18:46
excusez moi voici le vrai code

Bonjour à tous.s'il vous plait j'ai ecrit un code pour une authentification de 15 secondes et ca ne fonctionne pas.apres les 15 secondes s'il n'a pas pu s'authentifier alors l'authentification est annulé.voici mon code:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
var autoCloseTimer;
var timeoutObject;
var timePeriod = 5000; // 5 seconds
var warnPeriod = 15000; // 15 seconds

function promptForClose()
{
autoCloseDiv.style.display = 'block';
autoCloseTimer = setTimeout("definitelyClose()",warnPeriod);
}

function autoClose()
{
autoCloseDiv.style.display = 'block'; //shows message on page
autoCloseTimer = setTimeout("definitelyClose()",timePeriod); //starts countdown to closure
}
function cancelClose()
{
clearTimeout(autoCloseTimer); //stops auto-close timer
autoCloseDiv.style.display = 'none'; //hides message
}

function resetTimeout()
{
clearTimeout(timeoutObject); //stops timer
timeoutObject = setTimeout("promptForClose()",timePeriod); //restarts timer from 0
}
function definitelyClose() {
top.opener = self;
top.window.close();
}
-->
</SCRIPT>

</head>



<center>Inactivity warning!
This window will autoclose in 15 seconds unless you hit 'Cancel.'




</center>


<?php
function afficherformulaire ($u '', $error '')
{
if ($error != '')
echo '' . $error . '';
?>
<form name="form1" action="<?php echo $_SERVER['PHP_SELF']; ?>"
method="POST">
Formulaire de
connexion
,
----
Nom d'utilisateur :,
">,
----
Mot de passe :,
,
----


</form>
<script type="text/JavaScript">
function onValider()
{
if (document.form1.utilisateur.value == '') {
alert("Veuiller taper un nom d'utilisateur.");
return false;
}
if (document.form1.password.value == '') {
alert("Veuiller taper un mot de passe.");
return false;
}
return true ;
}
</script>
<?php
} //fin de la fonction afficherformulaire()
if (!isset ($_POST["valider"]) && !isset($_POST['annuler']))
{
afficherformulaire();
}
if (isset($_POST["annuler"]))
{
header("Location:Annuler.php");
$utilisateur="";
$password="";
}
if (isset($_POST["valider"]))
{
require_once("Connexion.php");
$query = "select login,password from user where login='" .
addslashes($_POST["utilisateur"]) . "' and password = '"
. addslashes($_POST["password"]) . "'";
$result = mysql_query($query) or die();
if(mysql_num_rows($result)>0)
{
header("location:Accueil.php");
}
else
{
afficherformulaire($_POST["utilisateur"],
"Nom d'utilisateur ou mot de passe incorrect");
}
}
//Fin du fichier
?>
 

aidez moi svp
0
Rejoignez-nous