Jump to content

register.php HELP!


phpwiz

Recommended Posts

ok, i have made a register script on my localhost and i made an IP variable so that it inserts the users IP when they register but when i tested it it dosent show the IP it says

::1

in the database PLEASE HELP!!!!

 

here is tthe code:

<?php

//connect to database
$connect = mysql_connect("localhost","root","");
mysql_select_db("members");

$submit = $_POST['submit'];
// form data
$username = (strip_tags($_POST['username']));
$password = (strip_tags($_POST['password']));
$repeatpassword = (strip_tags($_POST['repeatpassword']));
$date = date("Y-m-d");
$IP = $_SERVER['REMOTE_ADDR']; 
$avatar = "http://www.pokemonelite2000.com/sprites/frlgemtr/frlgemtr113.png";
$money = 250;
$sig = "No Signature";
$title = (strip_tags($_POST['title']));
$email = (strip_tags($_POST['email']));
$group = 0;
$form = 1;
$gender1 = @$_POST['gender'];
$gender = $_POST['gender'];

if ($submit)
{
   $namecheck = mysql_query("SELECT username FROM users WHERE username='$username'");
   $count = mysql_num_rows($namecheck);
   
   if ($count!=0)
   {
      die("This username has already been taken! <a href='register.php'>Back?</a>");
   }

   //check for existance
   if ($username&&$password&&$repeatpassword&&$email&&$title)
   {      
      if($password==$repeatpassword)
      {
         //check char length of username and name
         if (strlen($username)>35||strlen($email)>255||strlen($title)>55)
         {
            echo "Length of username,email or Title is too long! <a href='register.php'>Back?</a>";
         }
         else
         {
            //check password length
            if (strlen($password)>100||strlen($password)<6)
            {
               echo "Password must be between 6 and 35 characters <a href='register.php'>Back?</a>";
            }
            else
            {
               //register the user
               switch ($gender)
  								{	
  								 case "Male";
  								 $gender_db = "M";
  								 break;
  								 case "Female";
  								 $gender_db = "F";
  								 break;	
  								}
               //encrypt password
               $password = md5($password);
               $repeatpassword = md5(repeatpassword);

               $queryreg = mysql_query("INSERT INTO users VALUES('','$username','$password','$title','$sig','$gender_db','$email','$group','$date','$avatar','$credits','$IP')
                     ");
                                             
               die ("You have Successfully been registered! <a href='login.php'>login</a>");      
            }
         }
      }
      else
         echo "Your passwords do not match! <a href='register.php'>Back?</a>";

   }
   else
      echo "Please fill in <b>all</b> fields! <a href='register.php'>Back?</a>";
}

?>
<form action="<?php echo $PHP_SELF ?>" method="POST">
<table>
<tr>
<td><font size='2' face='arial'>Username:</td>
<td><input type="text" name="username" value="<?php echo $username ?>"></td>
</tr>
<tr>
<td><font size='2' face='arial'>Password:</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td><font size='2' face='arial'>Confirm:</td>
<td><input type="password" name="repeatpassword"></td>
</tr>
<tr>
<td><font size='2' face='arial'>Email:</td>
<td><input type='text' name='email'></td>
</tr>
<tr>
<td><font size='2' face='arial'>Trainer Title</td>
<td><input type='text' name='title'></td>
</tr>
<tr>
<td><font size='2' face='arial'>Gender:</td>
<td><font size='2' face='arial'><select name='gender'>
					<option>Male</option>
					<option>Female</option>
			</select></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" value="Register"></td>
</tr>
</table></font>
</form>
</td>
</tr>
</table>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.