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]