NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page My user system

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-12-2005, 02:14 AM THREAD STARTER               #1 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




My user system


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 Code:
<?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 Code:
  <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 &quot;<small>Abracadabra Cadabra Cadeen</small></span><small><font face="Arial">&quot;</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>ProfHenry 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>
????: NamePros.com http://www.namepros.com/programming/114938-my-user-system.html
        </
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>
????: NamePros.com http://www.namepros.com/showthread.php?t=114938
            <
option value="5b">Howard Thurston</option>
            <
option value="5c">John Neville Maskelyne</option>
        </
select></td>
      </
tr>
    </
table>
    <
p>&nbsp;</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 Code:
<?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.
Barrucadu is offline  
Old 08-12-2005, 02:30 AM   #2 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
PHP Code:
    $users[] = fopen('users.log''w'); 
????: NamePros.com http://www.namepros.com/showthread.php?t=114938
And has to be writable... if 'w' doesn't work, then you could use..
PHP Code:
    $users[] = fopen('users.log''w+'); 
Eric is offline  
Old 08-12-2005, 05:59 AM   #3 (permalink)
Eating Pie
 
iNod's Avatar
Join Date: Nov 2004
Location: Canada
Posts: 2,272
iNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud of
 


Special Olympics AIDS/HIV Cystic Fibrosis Save The Children Baby Health Cystic Fibrosis
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 Code:
//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']);
????: NamePros.com http://www.namepros.com/showthread.php?t=114938
        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;
}
    }
}
?> 
__________________
I feel old.
iNod is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
WHMCompleteSolution Client Management, Billing & Support System for cPanel & WHM Host thewishbone For Sale / Advertising Board 0 08-08-2005 11:10 AM
Domain Name System in Need of Upgrade Cheapquality Industry News 0 04-06-2005 05:38 PM
Hyperpipe.net webhosting offers hyperpipe Web Hosting Offers 0 03-28-2004 04:56 AM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 11:49 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger