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>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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

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.