/    Sign up×
Community /Pin to ProfileBookmark

Can someone edit this script so that it logs the users IP address into the Database??

I would like the following script to log the users ip address into the database when the submit their registration… The IP address would be entered into the same table as the information filled out in the form (sl18_users) and would go into the field urip

Any assistance with this issue is greatly appreciated
Thank you
APR911

The script is as follows:

<table border=’0′ width=’100%’>
<tr>
<td class=’cleardis’>
<?

if ( !$_POST[“regsubmit”] ) {

?>
<p><b>IMPORTANT NOTICE!</b><br> For security purposes lost passwords will be sent only to the email address that you type in the following section. Passwords will not be given to anyone requesting them that is not using the email address listed on the account. No Exceptions!</p>
<form method=’post’ action=’register.php’>
<table border=’0′ width=’100%’ cellspacing=’4′>
<tr>
<td width=’20%’>User Name</td> <td> <input type=’text’ name=’regusername’ maxlength=’11’></td>
</tr><tr>
<td width=’20%’>Pen Name</td> <td> <input type=’text’ name=’regpenname’ maxlength=’11’></td>
</tr><tr>
<td width=’20%’>Password</td> <td> <input type=’text’ name=’regpassword’ maxlength=’10’></td>
</tr><tr>
<td width=’20%’>Email</td> <td> <input type=’text’ name=’regemail’></td>
</tr><tr>
<td colspan=’2′><input type=’submit’ name=’regsubmit’ value=’register’></td>
</tr>
</table>
</form>

<?

} else {
$_POST[“regusername”] = trim($_POST[“regusername”]);
$_POST[“regpenname”] = trim($_POST[“regpenname”]);
$_POST[“regpassword”] = strip_tags(trim($_POST[“regpassword”]));
$_POST[“regemail”] = trim($_POST[“regemail”]);

if (!$_POST[“regpassword”] || !$_POST[“regemail”])
print “Error: Please go back and fill in every field”;

elseif (strlen($_POST[“regusername”]) > 11 || strlen($_POST[“regusername”]) < 3)
print “Error: Please give a username greater than 3 characters, and less than 11.”;

elseif (strlen($_POST[“regpenname”]) > 11 || strlen($_POST[“regpenname”]) < 3)
print “Error: Please give a penname greater than 3 characters, and less than 11.”;

elseif (!eregi(‘^[A-Z0-9]+@([A-Z0-9-]+.)+([A-Z0-9]){2,4}$’,$_POST[“regemail”]))
print “Error: Please give a valid email address.”;

elseif (!eregi(“^[A-Z]*$”,$_POST[“regusername”]) || !eregi(“^[A-Z]*$”,$_POST[“regpenname”]))
print “Error: User names and Pen names can contain alpha characters only.”;

else {
$dl = new TheDB();
$dl->connect() or die($dl->getError());
$dl->debug=false;

$table = $dl->select(“*”,”sl18_users”,array(‘urealname’=>$_POST[“regusername”]));
if ( !empty($table) )
print “The user name is already taken, please choose another”;
else {
$ins = array(
array(
‘urealname’=>$_POST[“regusername”],
‘upenname’=>$_POST[“regpenname”],
‘uemail’=>$_POST[“regemail”],
‘ustart’=>date(“Y-m-d”),
‘upass’=>$_POST[“regpassword”])
);

foreach($ins as $val) {
$dl->insert(“sl18_users”,$val) or die($dl->getError());
}

?>
<table border=’0′ width=’100%’ cellspacing=’4′>
<tr>
<td width=’20%’>User Name</td> <td> <?=$_POST[“regusername”]?></td>
</tr><tr>
<td width=’20%’>Pen Name</td> <td> <?=$_
POST[“regpenname”]?></td>
</tr><tr>
<td width=’20%’>Password</td> <td> <?=$_POST[“regpassword”]?></td>
</tr><tr>
<td width=’20%’>Email</td> <td> <?=$_
POST[“regemail”]?></td>
</tr><tr>
<td colspan=’2′>You have registered successfully! Go to the userpanel to log in and upload your work.</td>
</tr>
</table>
<?
}
}
}

?>

</td>
</tr>

</table>

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@zachzachJun 19.2004 — This will inseart the user's current IP address into the database as 'uip'=(user's IP address)

[code=php]
<table border='0' width='100%'>
<tr>
<td class='cleardis'>
<?

if ( !$_POST["regsubmit"] ) {

?>
<p><b>IMPORTANT NOTICE!</b><br> For security purposes lost passwords will be sent only to the email address that you type in the following section. Passwords will not be given to anyone requesting them that is not using the email address listed on the account. No Exceptions!</p>
<form method='post' action='register.php'>
<table border='0' width='100%' cellspacing='4'>
<tr>
<td width='20%'>User Name</td> <td> <input type='text' name='regusername' maxlength='11'></td>
</tr><tr>
<td width='20%'>Pen Name</td> <td> <input type='text' name='regpenname' maxlength='11'></td>
</tr><tr>
<td width='20%'>Password</td> <td> <input type='text' name='regpassword' maxlength='10'></td>
</tr><tr>
<td width='20%'>Email</td> <td> <input type='text' name='regemail'></td>
</tr><tr>
<td colspan='2'><input type='submit' name='regsubmit' value='register'></td>
</tr>
</table>
</form>

<?

} else {
$_POST["regusername"] = trim($_POST["regusername"]);
$_POST["regpenname"] = trim($_POST["regpenname"]);
$_POST["regpassword"] = strip_tags(trim($_POST["regpassword"]));
$_POST["regemail"] = trim($_POST["regemail"]);


if (!$_POST["regpassword"] || !$_POST["regemail"])
print "Error: Please go back and fill in every field";

elseif (strlen($_POST["regusername"]) > 11 || strlen($_POST["regusername"]) < 3)
print "Error: Please give a username greater than 3 characters, and less than 11.";

elseif (strlen($_POST["regpenname"]) > 11 || strlen($_POST["regpenname"]) < 3)
print "Error: Please give a penname greater than 3 characters, and less than 11.";

elseif (!eregi('^[A-Z0-9]+@([A-Z0-9-]+.)+([A-Z0-9]){2,4}$',$_POST["regemail"]))
print "Error: Please give a valid email address.";

elseif (!eregi("^[A-Z]*$",$_POST["regusername"]) || !eregi("^[A-Z]*$",$_POST["regpenname"]))
print "Error: User names and Pen names can contain alpha characters only.";

else {
$dl = new TheDB();
$dl->connect() or die($dl->getError());
$dl->debug=false;

$table = $dl->select("*","sl18_users",array('urealname'=>$_POST["regusername"]));
if ( !empty($table) )
print "The user name is already taken, please choose another";
else {
$ins = array(
array(
'urealname'=>$_POST["regusername"],
'upenname'=>$_POST["regpenname"],
'uemail'=>$_POST["regemail"],
'ustart'=>date("Y-m-d"),
'upass'=>$_POST["regpassword"]),
'uip'=>$_SERVER["REMOTE_ADDR"]
);

foreach($ins as $val) {
$dl->insert("sl18_users",$val) or die($dl->getError());
}

?>
<table border='0' width='100%' cellspacing='4'>
<tr>
<td width='20%'>User Name</td> <td> <?=$_POST["regusername"]?></td>
</tr><tr>
<td width='20%'>Pen Name</td> <td> <?=$_POST["regpenname"]?></td>
</tr><tr>
<td width='20%'>Password</td> <td> <?=$_POST["regpassword"]?></td>
</tr><tr>
<td width='20%'>Email</td> <td> <?=$_POST["regemail"]?></td>
</tr><tr>
<td colspan='2'>You have registered successfully! Go to the userpanel to log in and upload your work.</td>
</tr>
</table>
<?
}
}
}

?>

</td>
</tr>
</table>
[/code]
Copy linkTweet thisAlerts:
@APR911authorJun 19.2004 — This problem has been solved.

Thank you very much

APR911
×

Success!

Help @APR911 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...