[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 08-12-2005, 01:14 AM   #1 (permalink)
Barru.
 
Barrucadu's Avatar
 
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,731
78.50 NP$ (Donate)

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>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>&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, 01:30 AM   #2 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services


 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
PHP Code:
    $users[] = fopen('users.log', 'w');
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, 04:59 AM   #3 (permalink)
Eating Pie
 
iNod's Avatar
 
Join Date: Nov 2004
Location: Canada
Posts: 2,289
126.05 NP$ (Donate)

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']);
        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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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 10:10 AM
Domain Name System in Need of Upgrade Cheapquality Industry News 0 04-06-2005 04:38 PM
Hyperpipe.net webhosting offers hyperpipe Web Hosting Offers 0 03-28-2004 03:56 AM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 11:50 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85