PDA

View Full Version : I can't explain in title ...



Pazza
22-04-2008, 04:57 PM
Basically, I am looking for a code where say...

There is an input box, and you must enter a certain code to proceed to the next page. So say the code was 123, if u typed 29475 it would say something like 'unfortunately, your code is incorrect'.

I'm needing it for a competition at school :D

+rep for help

Protege
22-04-2008, 04:59 PM
image verification basically?

Kieran
22-04-2008, 05:00 PM
But number verification :P

Basically a code could be:

Randomly generate number
Check if number entered = number displayed
If yes, proceed
If no, dont proceed

Protege
22-04-2008, 05:13 PM
In a nutshell.

Pazza
22-04-2008, 05:18 PM
Yeah, basically. But the code wouldn't be shown ...

And I don't know PHP :(

Protege
22-04-2008, 05:30 PM
Yeah, basically. But the code wouldn't be shown ...

And I don't know PHP :(

Im seriously tired I've coded 13 hours straight =/ but I'll give it ago. You need like a small jpeg and call it image.jpg - we'll use this to put the numbers on.

Call that, whatever.html


<form method="post" action="page.php">
<img src="image.php"><br>
<b>Image text:</b> <input type="text" name="image"><br>
<input type="submit" value="SUBMIT">
</form>
Call this image.php (same directory as wwhatever.html)


<?php
session_start();
$numbers = "1234567890";
$random = substr(str_shuffle($numbers), 0, 10);
$_SESSION["image"] = $random;
$image = imagecreatefromjpeg("image.jpg");
$textColor = imagecolorallocate ($image, 255,000,000);
imagestring ($image, 3, 15, 1, $random, $textColor);
imagejpeg($image);
imagedestroy($image);
?>
Call this page.php


<?php
session_start();
// cheap and nasty php you get theidea
if($_POST["image"] == $_SESSION["image"]) {
echo("yay you got it right");
} else {
echo("you got it wrong, you fail.");
}
session_destroy();
?>
you can use my image btw

http://www.members.driftpanzy.co.uk/image.jpg

Save it and upload it, dont hotlink me.

Any problems, ask someone else. im tired.

Moh
22-04-2008, 05:51 PM
Should work :P

<?php

if($_GET["act"] == "submit")
{
$entry = ($_POST["entry"]);
$answer = ($_POST["rand"]);

if($entry == $answer)
{
echo("Well Done! You got it right. The answer was $answer.. you can replace this with the form or what ever.");
} else {
echo("Ohh Noes! You got it wrong.. lol");
}
}
else
{
$rand = rand();
echo("Please enter the following number in the box below:<br>$rand<br>
<form method=\"post\" action=\"?act=submit\">
<input readonly type=\"hidden\" name=\"rand\" value=\"$rand\">
<input type=\"text\" name=\"entry\"><br><br>
<input type=\"submit\" value=\"Submit\">
</form>");
}
?>

I kinda cheated by making a textbox store the code.

Protege
22-04-2008, 05:59 PM
ehehehe :P Its easy to get past tho with robots.

Moh
22-04-2008, 07:23 PM
ehehehe :P Its easy to get past tho with robots.
Its only a competition at school..

Pazza
22-04-2008, 07:27 PM
Yeah, for this enterprise evening.

So in Jacks code,

Do I specify a code, and that code is the only one accepted. So, basically the page will just be a box to type the code in, and a submit button. If I say the code is 123, if 123 is entered it will redirect to another page saying congrats you won bla bla bla. If it is the wrong one it will say sorry, you have lost. I don't mean there is a code shown, but 123 would be the only code that could be accepted ??

Jme
22-04-2008, 09:04 PM
Is it like a guessing game? Or like above you give the user a code and they have to repeat it in a text box?

Moh
22-04-2008, 09:07 PM
Yeah, for this enterprise evening.

So in Jacks code,

Do I specify a code, and that code is the only one accepted. So, basically the page will just be a box to type the code in, and a submit button. If I say the code is 123, if 123 is entered it will redirect to another page saying congrats you won bla bla bla. If it is the wrong one it will say sorry, you have lost. I don't mean there is a code shown, but 123 would be the only code that could be accepted ??
Below :)




<?php

if($_GET["act"] == "submit")
{
$entry = ($_POST["entry"]);
$answer = "123";

if($entry == $answer)
{
echo("Well Done! You got it right. The answer was $answer.. you can replace this with the form or what ever.");
} else {
echo("Ohh Noes! You got it wrong.. lol");
}
}
else
{
echo("Please enter the answer into the box below:<br>
<form method=\"post\" action=\"?act=submit\">
<input type=\"text\" name=\"entry\"><br><br>
<input type=\"submit\" value=\"Submit\">
</form>");
}
?>

Coldplay
22-04-2008, 09:22 PM
Just use re-captcha?

Pazza
22-04-2008, 09:22 PM
Below :)




<?php

if($_GET["act"] == "submit")
{
$entry = ($_POST["entry"]);
$answer = "123";

if($entry == $answer)
{
echo("Well Done! You got it right. The answer was $answer.. you can replace this with the form or what ever.");
} else {
echo("Ohh Noes! You got it wrong.. lol");
}
}
else
{
echo("Please enter the answer into the box below:<br>
<form method=\"post\" action=\"?act=submit\">
<input type=\"text\" name=\"entry\"><br><br>
<input type=\"submit\" value=\"Submit\">
</form>");
}
?>

Thanks xD

@ above Jack's post, We are doing this Enterprise thing, and we have to make a profit. And my product is simply they pay 50p and get a card with code on it, they go to the website i'm going to set up, and enter code . If they win they get £5 (low budge) :P

Thanks again :P

Want to hide these adverts? Register an account for free!