Dynadot โ€” .com Registration $8.99

My user system

Spaceship Spaceship
Watch

Barrucadu

Established Member
Impact
64
OK, i've been coding a magicians-only website, to get in you have to register, to register you have to complete a magic quiz, the file users.log remains empty no-matter how many times I try to register.

User Validation (in the members section):
PHP:
<?php
if(!$_GET['uid'] OR !$_GET['pcode'])
{
   header("Location: /nologin.php");
   exit;
}
else
{
    $users[] = fopen('users.log',w);
    foreach($users as $person)
    {
        if(filesize('users.log') < 1){
			header("Location: /badlogin.php");
			exit;
		}
		if(eregi("UID: ".$_POST['uid']."PCO: ".$_POST['pcode'],$person))
        {
            $usrfound = true;
        }
    }
    if(!usrfound)
    {
        header("Location: /badlogin.php");
		exit;
    }
    else
    {
        exit;
    }
}
?>

login form code (index.php):
Code:
  <form name="form1" method="get" action="main.php">
    <table width="200" border="2" cellpadding="5" cellspacing="5">
      <tr>
        <td><div align="left"><strong><span class="style3">User ID: </span></strong></div></td>
        <td><input name="uid" type="text" id="uid"></td>
      </tr>
      <tr>
        <td><div align="left"><strong><span class="style3">Passcode:</span></strong></div></td>
        <td><input name="pcode" type="password" id="pcode"></td>
      </tr>
      <tr>
        <td colspan="2"><div align="center"><strong>
            <input type="submit" name="Submit" value="Login to Realm of Magic">
        </strong></div></td>
      </tr>
      <tr>
        <td colspan="2"><div align="center">
          <p><strong><span class="style5"> <a href="register.php">Register to Realm of Magic</a></span></strong>              
          </p>
          </div></td>
      </tr>
    </table>
  </form>

Register form code (register.php):
PHP:
  <form name="form1" method="post" action="RegVerify.php">
    <table width="200" border="2" cellpadding="5" cellspacing="5">
      <tr>
        <td><div align="left"><strong><span class="style3">User ID: </span></strong></div></td>
        <td><input name="uid" type="text" id="uid"></td>
      </tr>
      <tr>
        <td><div align="left"><strong><span class="style3">Passcode:</span></strong></div></td>
        <td><input name="pcode" type="password" id="pcode"></td>
      </tr>
      <tr>
        <td><div align="center" class="style3">
          <div align="left"><strong>Name:</strong></div>
        </div></td>
        <td><input name="fname" type="text" id="fname"></td>
      </tr>
      <tr>
        <td><div align="center" class="style3">
          <div align="left"><strong>Surname:</strong></div>
        </div></td>
        <td><input name="sname" type="text" id="sname"></td>
      </tr>
      <tr>
        <td><span class="style3"><strong>Email:</strong></span></td>
        <td><input name="email" type="text" id="email"></td>
      </tr>
    </table>
    <p><strong><span class="style5"><u>Magic Quiz</u></span></strong></p>
    <p><strong><span class="style3">To gain access to the site you must get all the questions correct. </span></strong></p>
    <table width="513" border="2" cellpadding="5" cellspacing="5">
      <tr>
        <td width="326"><div align="left"><strong><span class="style3">Which magicians catchphrase was "<small>Abracadabra Cadabra Cadeen</small></span><small><font face="Arial">"</font><span class="style3">?</span></small></strong></div></td>
        <td width="144"><select name="quiz1" size="1" id="quiz1">
            <option value="1a">Ali Bongo</option>
            <option value="1b">Doug Henning</option>
            <option value="1c" selected>Prof. Henry Bessette</option>
                        </select></td>
      </tr>
      <tr>
        <td><div align="left"><strong><span class="style3">What was Abracadabra originally used as? </span></strong></div></td>
        <td><select name="quiz2" size="1" id="quiz2">
            <option value="2a">A medieval charm</option>
            <option value="2b" selected>An occult incantation</option>
            <option value="2c">A swear word</option>
        </select></td>
      </tr>
      <tr>
        <td><div align="center" class="style3">
            <div align="left"><strong>What religion practices magic? </strong></div>
        </div></td>
        <td><select name="quiz3" size="1" id="quiz3">
            <option value="3a">Wicca</option>
            <option value="3b">Christianity</option>
            <option value="3c" selected>Hinduism</option>
        </select></td>
      </tr>
      <tr>
        <td><div align="center" class="style3">
            <div align="left"><strong>Where was Houdini born?</strong></div>
        </div></td>
        <td><select name="quiz4" size="1" id="quiz4">
            <option value="4a">Budapest</option>
            <option value="4b" selected>New York</option>
            <option value="4c">Calafornia</option>
        </select></td>
      </tr>
      <tr>
        <td><span class="style3"><strong>Which magician invented pay-per-use toilets?</strong></span></td>
        <td><select name="quiz5" size="1" id="quiz5">
            <option value="5a" selected>Houdini</option>
            <option value="5b">Howard Thurston</option>
            <option value="5c">John Neville Maskelyne</option>
        </select></td>
      </tr>
    </table>
    <p>ย </p>
    <p><strong><span class="style3">
      <input name="Submit" type="submit" id="Submit" value="Register to Realm of Magic">
    </span></strong></p>
  </form>

Register page 2 code (regverify.php)
PHP:
<?php
if(!$_POST['uid']) {
	echo( '<center>You need to enter a user id!<p><a href = \'register.php\'>Try Again</a></p></center>');
	exit;
}else if(!$_POST['pcode']) {
	echo( '<center>You need to enter a passcode!<p><a href = \'register.php\'>Try Again</a></p></center>');
	exit;
}else if(!$_POST['fname']) {
	echo( '<center>You need to enter a first name!<p><a href = \'register.php\'>Try Again</a></p></center>');
	exit;
}else if(!$_POST['sname']) {
	echo( '<center>You need to enter a last name!<p><a href = \'register.php\'>Try Again</a></p></center>');
	exit;
}else if(!$_POST['email']) {
	echo( '<center>You need to enter an email address!<p><a href = \'register.php\'>Try Again</a></p></center>');
	exit;
}else {
	if(!$_POST['quiz1'] == '1c') {
		echo( '<center>Incorrect answer for question 1!<p><a href = \'register.php\'>Try Again</a></p></center>');
		exit;
	}else if(!$_POST['quiz2'] == '2a') {
		echo( '<center>Incorrect answer for question 2!<p><a href = \'register.php\'>Try Again</a></p></center>');
		exit;
	}else if(!$_POST['quiz3'] == '3a') {
		echo( '<center>Incorrect answer for question 3!<p><a href = \'register.php\'>Try Again</a></p></center>');
		exit;
	}else if(!$_POST['quiz4'] == '4a') {
		echo( '<center>Incorrect answer for question 4!<p><a href = \'register.php\'>Try Again</a></p></center>');
		exit;
	}else if(!$_POST['quiz5'] == '5c') {
		echo( '<center>Incorrect answer for question 5!<p><a href = \'register.php\'>Try Again</a></p></center>');
		exit;
	}else {
		$users[] = file('users.log');
		foreach($users as $person) {
			if(eregi( "UID: ".$_POST['uid']."PCO: ".$_POST['pcode'],$person)) {
				echo( '<center>Username taken!<p><a href = \'register.php\'>Try Again</a></p></center>');
				exit;
			}
		}
		$handle = fopen('users.log','w');
		fwrite($handle, "UID: ".$_POST['uid']."PCO: ".$_POST['pcode']."EMA: ".$_POST['email']."FNA: ".$_POST['fname']."SNA: ".$_POST['sname']);
		echo( '<center>Registration complete!<p><a href = \'index.php\'>Continue</a></p></center>');
		exit;
	}
}
?>

now, I think the problem is in the RegVerify.php page but I included all the related code incase there was something wrong with that.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
PHP:
    $users[] = fopen('users.log', 'w');
And has to be writable... if 'w' doesn't work, then you could use..
PHP:
    $users[] = fopen('users.log', 'w+');
 
0
•••
If the above code doesn't want to work either make sure user.log is chmodded and try a insted of w+ this means you can read and write but it does the job..
Here is anther idea.

PHP:
//If users.log is writable
if (is_writable(users.log)) {
        $handle = fopen('users.log','w');
        fwrite($handle, "UID: ".$_POST['uid']."PCO: ".$_POST['pcode']."EMA: ".$_POST['email']."FNA: ".$_POST['fname']."SNA: ".$_POST['sname']);
        echo( '<center>Registration complete!<p><a href = \'index.php\'>Continue</a></p></center>');
        exit;
}else{
// Users.log is not writable
print "File users.log is not writable.<br>";
exit;
}
    }
}
?>
 
0
•••
Unstoppable Domains
Domain Recover
DomainEasy โ€” Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back