Jump to content

how to get two numbers match with a posting form,,,,,


redarrow

Recommended Posts

how can i get a session to match a varable...

 

as soon as i post the varable $res, the session

changes so how do you do it thank you...

 

 

<?php session_start();

$_SESSION['number']=rand(000000,999999);

$res=$_SESSION['number'];

if($_POST['submit']){

$res=$_POST['res'];

if($res==$_SESSION['number']){

	echo "correct";
}
}
?>

<form method="POST" action="">
<br><br>
<?php echo $_SESSION['number']; ?>
<br><br>
please enter number
<br></br>
<input type="text" name="res">
<br><BR>
<input type="submit" name="submit" value="SEND">
</form>

secuity form like gotcha if the numbers match goto the page lol

 

 

example but the session always matches i need it to match on posting

<?php session_start();

$_SESSION['number']=rand(000000,999999);

$_SESSION['last_number']=$_SESSION['number'];

if($_POST['submit']){

$res=$_SESSION['last_number'];

if($res==$_SESSION['number']){

	echo "correct";
}
}
?>

<form method="POST" action="">
<br><br>
<?php echo $_SESSION['number']; ?>
<br><br>
please enter number
<br></br>
<input type="text" name="res">
<br><BR>
<input type="submit" name="submit" value="SEND">
</form>

sorry the 'gotcha' thing flew straight by me (self taught)...

Change this bit to:

if($res==$_SESSION['last_number']){

	echo "correct";
}
}

 

The way I do is to generate a gotcha string and a md5/salt of it, store both in a table, then send the md5 in the page, which calls a gd image gen page passing the md5, this then looks up the gotcha string in the table using the md5. This way the gotcha string is never sent in plain text...

Archived

This topic is now archived and is closed to further replies.

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