Author Topic: Alright... one more question ;)  (Read 617 times)

Offline lxdpep

  • Level 10
  • *
  • Posts: 55
  • Reputation: +0/-0
    • View Profile
Alright... one more question ;)
« on: February 21, 2009, 06:59:45 PM »
Alright. I got everything working now.. Just my register.php script is acting weird, as well as my login.php script. When I first installed the scripts, all the info submitted from register.php went into the database I created via mysql. Now.. the info I submit from register.php won't even go into the database! Also this part of the code won't work either...

<?php
if ($action == "register") {
   if (!$user || !$pass || !$email || !$vpass ) {
      print "You must fill out all fields.";
      include("foot.php");
      exit;
   }
   $dupe1 = mysql_num_rows(mysql_query("select * from players where user='$user'"));
   if ($dupe1 > 0) {
      print "Someone already has that username.";
      include("foot.php");
      exit;
   }
   $dupe2 = mysql_num_rows(mysql_query("select * from players where email='$email'"));
   if ($dupe1 > 0) {
      print "Someone already has that email.";
      include("foot.php");
      exit;
   }
   if ($pass != $vpass) {
      print "The passwords do not match.";
      include("foot.php");
      exit;
   }
   $ref = strip_tags($ref);
   $user = strip_tags($user);
   $pass = strip_tags($pass);
   if ($ref) {
      mysql_query("update players set refs=refs+1 where id=$ref");
   }
   mysql_query("insert into players (user, email, pass) values('$user','$email','$pass')") or die("Could not register.");
   print "You are now registered to play, $user. Please login now.";
}
?>


I don't know why and I'm starting to get a headache O_o.



Here's the login.php code

<?php
if (!$email || !$pass) {
   include("head.php");
   print "Please fill out all fields.";
   include("foot.php");
   exit;
}
include("head.php");
$logres = mysql_num_rows(mysql_query("select * from players where email='$email' and pass='$pass'"));
if ($logres <= 0) {
   print "Login failed. If you have not already, please signup. Otherwise, check your spelling and login again.";
   include("foot.php");
   exit;
} else {
   session_register("email");
   session_register("pass");
   print "&nbsp;<br>Welcome back. Please click <a href=updates.php>here</a> to continue..";
}
include("foot.php");
?>





Offline lxdpep

  • Level 10
  • *
  • Posts: 55
  • Reputation: +0/-0
    • View Profile
Re: Alright... one more question ;)
« Reply #1 on: February 21, 2009, 07:00:19 PM »
Here's the whole register.php file...

<?php include("head.php"); ?>

<?php
$nump = mysql_num_rows(mysql_query("select * from players"));
print " <b>$nump</b> people already have.";
?>

<form method=post action=register.php?action=register>
<table>
<tr><td>Username:</td><td><input type=text name=user></td></tr>
<tr><td>Email:</td><td><input type=text name=email></td></tr>
<tr><td>Pass:</td><td><input type=password name=pass></td></tr>
<tr><td>Verify Pass:</td><td><input type=password name=vpass></td></tr>
<?php
print "<tr><td>Referral ID:</td><td><input type=text name=ref readonly value=$reff> <i>If you don't know what this is, leave it blank.</i></td></tr>";
?>
<tr><td colspan=2 align=center><input type=submit value=Register></td></tr>
</table>
</form>

<?php
if ($action == "register") {
   if (!$user || !$pass || !$email || !$vpass ) {
      print "You must fill out all fields.";
      include("foot.php");
      exit;
   }
   $dupe1 = mysql_num_rows(mysql_query("select * from players where user='$user'"));
   if ($dupe1 > 0) {
      print "Someone already has that username.";
      include("foot.php");
      exit;
   }
   $dupe2 = mysql_num_rows(mysql_query("select * from players where email='$email'"));
   if ($dupe1 > 0) {
      print "Someone already has that email.";
      include("foot.php");
      exit;
   }
   if ($pass != $vpass) {
      print "The passwords do not match.";
      include("foot.php");
      exit;
   }
   $ref = strip_tags($ref);
   $user = strip_tags($user);
   $pass = strip_tags($pass);
   if ($ref) {
      mysql_query("update players set refs=refs+1 where id=$ref");
   }
   mysql_query("insert into players (user, email, pass) values('$user','$email','$pass')") or die("Could not register.");
   print "You are now registered to play, $user. Please login now.";
}
?>

<?php include("foot.php"); ?>


Thanks in advance for the help =D

Offline toxin

  • Level 21
  • *
  • Posts: 231
  • Reputation: +4/-2
    • View Profile
    • Encore Montreal
Re: Alright... one more question ;)
« Reply #2 on: February 21, 2009, 07:54:04 PM »
The only thing I can see is that you have not defined the  variables.

Offline xBleuWolfx

  • Level 17
  • *
  • Posts: 158
  • Reputation: +3/-2
    • View Profile
Re: Alright... one more question ;)
« Reply #3 on: February 21, 2009, 11:58:49 PM »
I tested this out and couldn't get it to work.

I'm not slacking off. My code's compiling.


Offline raestlyn

  • Level 29
  • **
  • Posts: 463
  • Reputation: +9/-5
    • View Profile
Re: Alright... one more question ;)
« Reply #4 on: February 22, 2009, 03:19:08 AM »
Ah, thats easy to solve! Just turn Register_globals on!

Or just edit this line:
if ($action == "register") {
to this:
if(isset($_GET[action]){
   if ($_GET[action] == "register") {

and add the needed } in the end.

Oh, and add _GET[] in your $ref, $user, $pass, $email and $vpass.


I can send you pics of my cocks if you want reference.


 


SimplePortal 2.3.3 © 2008-2010, SimplePortal