...

View Full Version : confused about this code + ip adress



markman641
08-19-2011, 06:47 AM
i have the following 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


<tr>
<td bgcolor="#10d305"><input type="hidden" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" size="10" /></td>
</tr>

markman641
08-19-2011, 07:39 AM
basically what im trying to do is insert the users IP address into mysql but the code is confusing me beyond belief.

markman641
08-19-2011, 07:46 AM
Figured it out, closed

guelphdad
08-19-2011, 05:01 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum