Page 8 of 8

Re: Video#3

Posted: Sun May 22, 2011 7:04 pm
by RogueTomboy
Okay I am trying to do Halls videos and when I hit submit to register I get:

Forbidden

You don't have permission to access /tutorial/reguser.php" on this server.

Not sure why I get that :(

EDIT: Okay I got the 403 to go away - I just put in Halls code for Register/Reguser... I get the 'Thanks for registering!' script but then when I go to check my database to make sure it worked - my 'new player' isn't there (i've refreshed, etc).

Re: Video#3

Posted: Sun May 22, 2011 9:18 pm
by hallsofvallhalla
I recommend to all to to watch the videos up to 14 or so then do the code. Trust me. It is far easier.

Re: Video#3

Posted: Sun May 22, 2011 9:20 pm
by RogueTomboy
Okay, I'll do that first then :)

Re: Video#3

Posted: Fri Feb 03, 2012 2:41 pm
by Henning12342
hi guys i have followed the code through out 3a and 3b and i keep getting an error message ill post here

Code: Select all

<?php
include 'connect.php';
?>

<?php
$player=$_POST['player'];
$password=$_POST['password'];
$pass2=$_POST['pass2'];
$player=strip_tags($player);
$email=$_POST['email'];
$email=strip_tags($email);

if ($email == "")
{
echo "You didn't enter a email address!<br>";
echo " <A href='register.php'>Go back</a>";
    exit;
    }
if ($password==$pass2)
{
 
  $isplayer="SELECT * from players where name='$player'";
  $isplayer2=mysql_query($isplayer) or die("Could not query players table");
  $isplayer3=mysql_fetch_array($isplayer2);
  if(!$_POST['password'] || !$_POST['pass2'])
  {
     print "You did not enter a password";
    echo " <A href='register.php'>Go back</a><br>";
    exit;
  }
  else if($isplayer3 || strlen($player)>15 || strlen($player)<1)
  {
     print "There is already a player of that name or the name you specified is over 16 letters or less than 1 letter<br>";
     echo " <A href='register.php'>Go back</a>";
    exit;
  }
  else
  {
    $isaddress="SELECT * from players where email='$email'";
    $isaddress2=mysql_query($isaddress) or die("not able to query for password");
    $isaddress3=mysql_fetch_array($isaddress2);
    if($isaddress3)
    {
      print "There is already a player with that e-mail address<br>";
      echo " <A href='register.php'>Go back</a>";
    exit;
    }
    else
    {
        $password=md5($password);
       
$SQL = "INSERT into players(name, password, email, level, exper) VALUES ('$player','$password','$email','1','0')";
      mysql_query($SQL) or die("could not register");
     
      print "Thank you for registering.";
   
    }
  }
}

else
{
  print "Your password didn't match or you did not enter a password<br>";
   echo " <A href='register.php'>Go back</a>";
    exit;
}
echo "<br><A href='login.php'>Login Page</a>";
?>
and the error is

--------------------------------------------------------------------------------------------------
( ! ) Notice: Undefined index: password in E:\wamp\www\tutorial\reguser.php on line 7
Call Stack
# Time Memory Function Location
1 0.0012 384872 {main}( ) ..\reguser.php:0
--------------------------------------------------------------------------------------------------
( ! ) Notice: Undefined index: pass2 in E:\wamp\www\tutorial\reguser.php on line 8
Call Stack
# Time Memory Function Location
1 0.0012 384872 {main}( ) ..\reguser.php:0
--------------------------------------------------------------------------------------------------
( ! ) Notice: Undefined index: email in E:\wamp\www\tutorial\reguser.php on line 10
Call Stack
# Time Memory Function Location
1 0.0012 384872 {main}( ) ..\reguser.php:0
-------------------------------------------------------------------------------------------------

You didn't enter a email address!
Go back

Re: Video#3

Posted: Fri Feb 03, 2012 2:50 pm
by Henning12342
hey guys ive just copyied some code from the forum and this is it and no problems user regesterd as well

Code: Select all

   <?php
    include 'connect.php';
    ?>

    <?php
    $player=$_POST['player'];
    $password=$_POST['password'];
    $pass2=$_POST['pass2'];
    $player=strip_tags($player);
    $email=$_POST['email'];
    $email=strip_tags($email);

    if ($email == "")
    {
    echo "You didn't enter an email address!<br>";
    echo " <A href='register.php'>Go back</a>";
        exit;
        }
    if ($password==$pass2)
    {
     
      $isplayer="SELECT * from players where name='$player'";
      $isplayer2=mysql_query($isplayer) or die("Could not query players table");
      $isplayer3=mysql_fetch_array($isplayer2);
      if(!$_POST['password'] || !$_POST['pass2'])
      {
         print "You did not enter a password";
        echo " <A href='register.php'>Go back</a><br>";
        exit;
      }
      else if($isplayer3 || strlen($player)>15 || strlen($player)<5)
      {
         print "There is already a player of that name or the name you specified is over 16 letters or less than 5 letter<br>";
         echo " <A href='register.php'>Go back</a>";
        exit;
      }
      else
      {
        $isaddress="SELECT * from players where email='$email'";
        $isaddress2=mysql_query($isaddress) or die("not able to query for password");
        $isaddress3=mysql_fetch_array($isaddress2);
        if($isaddress3)
        {
          print "There is already a player with that e-mail address<br>";
          echo " <A href='register.php'>Go back</a>";
        exit;
        }
        else
        {
            $password=md5($password);
           
    $SQL = "INSERT into players(name, password, email, level, exper) VALUES ('$player','$password','$email','1','0')";
          mysql_query($SQL) or die("could not register");
         
          print "Thank you for registering.";
       
        }
      }
    }

    else
    {
      print "Your password didn't match or you did not enter a password<br>";
       echo " <A href='register.php'>Go back</a>";
        exit;
    }
    echo "<br><A href='login.php'>Login Page</a>";
    ?>

Re: Video#3

Posted: Fri Feb 03, 2012 8:31 pm
by Jackolantern
Those values that are showing in your error messages are not being sent by POST to that script. You probably need to look at the form that came before-hand and make sure you are POSTing those values to the correct script.

Re: Video#3

Posted: Fri Feb 03, 2012 11:32 pm
by Henning12342
hi guys im trying to add acustom button for login and dont know how to do it this is my log in code

<form method="POST" action="authenticate.php">
User Name <input type="text" name="player" size="21">
<br/>
Password <input type="password" name="password" size="21" mask="x">
<br/>
<input type="submit" value="Login" Name="submit">

button i ant to use is in images/login.gif any help would be greatly appreciated thanks in advance

Re: Video#3

Posted: Sat Feb 04, 2012 12:07 am
by Ark
make sure to close that form with and ending tag( </form> ).

As for the image you can use the type attribute of the input tag.

Code: Select all

<input type="image" src="images/login.gif"/>

Re: Video#3

Posted: Sat Feb 04, 2012 12:27 am
by Henning12342
perfect thanks got it working now thanks