Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post

    confused about this code + ip adress

    i have the following code:

    Code:
            <?
    
    $u = $_POST['u'];
    $p = $_POST['p'];
    $e = $_POST['e'];
    $country = $_POST['country'];
    $g = $_POST['gender'];
    $a = $_POST['age'];
    $ref = $_POST['ref'];
    
    $u = htmlspecialchars($u);
    $p = htmlspecialchars($p);
    $e = htmlspecialchars($e);
    $g = htmlspecialchars($g);
    $d = htmlspecialchars($d);
    $ref = htmlspecialchars($ref);
    
    if($u && $p && $e && $a && $g) {
    $check = mysql_num_rows(mysql_query("SELECT * FROM `members` WHERE `username`=\"$u\""));
    
    if($check==0) {
    
    		$month = $_POST['month'];
    		$day = $_POST['day'];
    		$year = $_POST['year'];
    		$sign = $_POST['sign'];
    		
    		$month = htmlspecialchars($month);
    		$day = htmlspecialchars($day);
    		$year = htmlspecialchars($year);
    		$sign = htmlspecialchars($sign);
    		
    			 $date = date("m/d/y");
    			 
    			// remove spaces
    			// $uu = str_replace (" ", '$u', $uu);
    			// echo $uu;
    			// echo $u;
    			// die;
    			 
    			 	$insert = mysql_query("INSERT INTO `members` (`country`, `gender`, `age`, `date`, `dob`, `username`, `password`, `email`, `ref`) VALUES('$country', '$g', '$a', '$date', '$month/$day/$year', \"$u\", \"$p\", \"$e\", \"$ref\")");
    $msg = mysql_query("INSERT INTO `messages` (`to`, `from`, `subject`, `message`, `status`, `date`) VALUES(\"$u\", 'admin', 'Welcome', '$mess', 'unread', '$date')");
    			 	
    			 	
    				 	
    						$_SESSION['Board'] = $u;
    			 			if (session_register('Board')) {
    				 		 	print "You have been registered. You are now able
    							  to access all of the features on this site.<p>
    							  <a href=\"index.php\">Click here to continue</a>";
    				 		 	print "";
    				 		}
    				 		else {
    				 		 	print "Cant set session!";
    				 		}
    and the thing is, i have NO clue whats going on, but what im trying to do is add a $_SERVER['REMOTE_ADDR'] into 'ip'. i have it on the form page as

    Code:
        <tr>
          <td bgcolor="#10d305"><input type="hidden" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" size="10" /></td>
        </tr>
    Last edited by markman641; 08-19-2011 at 06:08 AM.

  • #2
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post
    basically what im trying to do is insert the users IP address into mysql but the code is confusing me beyond belief.

  • #3
    Regular Coder
    Join Date
    Jul 2011
    Posts
    272
    Thanks
    63
    Thanked 1 Time in 1 Post
    Figured it out, closed

  • #4
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    Please don't post in a public forum asking for help and then NOT post the solution. Others may benefit from a solution being posted if they have a similar problem to yours.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •