treasure hunt
Posted: Sat May 21, 2005 4:41 am
I am trying to create a treasure hunt for a clients website - the visitors are given the URL of the login page and some clues to guess the username and password required to login and unlock the treasure.
The successful user logs in and is presented with instructions on how to claim their prize. Subsequent visitors are directed to a page informing them that they didn't quite make it on time.
The way I'm thinking of doing this relies on logging the IP of the first user to correctly input the username and password (the one and only winner). Their IP is written to a text file.
The treasure page then compares user IP with the first IP in the text file - if they match - user can proceed to collect the bounty - if not they are sent to a page informing them they arrived to late and have not won.
This is what I have written so far:
I only want one IP to be written to the file ip.txt - is this possible?
I'm faltering a bit now.
Does this interest anyone?
JCART | PLEASE USE
The successful user logs in and is presented with instructions on how to claim their prize. Subsequent visitors are directed to a page informing them that they didn't quite make it on time.
The way I'm thinking of doing this relies on logging the IP of the first user to correctly input the username and password (the one and only winner). Their IP is written to a text file.
The treasure page then compares user IP with the first IP in the text file - if they match - user can proceed to collect the bounty - if not they are sent to a page informing them they arrived to late and have not won.
This is what I have written so far:
Code: Select all
<form name="e;form"e; method="e;post"e; action="e;login.php"e;>
<ul>
<li>User: <input type="e;text"e; size="e;20"e; name="e;user"e;></li>
<li>Pass <input type="e;password"e; size="e;20"e; name="e;pass"e;></li>
<li><input type="e;submit"e; value="e;Login"e;></li>
</ul>
</form>Code: Select all
<?php
$usercorrect=blah;
$passcorrect=blah;
if ($user==$usercorrect && $pass==$passcorrect) {
$log_file = "e;ip.txt"e;;
$ip = getenv('REMOTE_ADDR');
$fp = fopen("e;$log_file"e;, "e;a"e;);
fputs($fp, "e;$ip"e;);
flock($fp, 3);
fclose($fp);
$goforth = "e;location: treasure.php"e;; // login correct - go forth and rejoice in thy treasure
header($goforth);
} elseif ($user!=$usercorrect || $pass!=$passcorrect) {
header("e;location: try_again.php"e;); // login incorrect - access denied
} else {
break;
}
?>Code: Select all
<?php
$ip = getenv('REMOTE_ADDR');
$winner = fopen the file ip.txt and parse the ip address - any pointers?
if ($ip!=$winner) {
header("e;location: oh_well.php"e;); // user re-directed and informed that they have lost
elseif ($ip==$winner) {
<html>Does this interest anyone?
JCART | PLEASE USE
Code: Select all
TAGS AND REVIEW [url=http://forums.devnetwork.net/viewtopic.php?t=21171]POSTING CODE IN THE FORUMS[/url][/color]