I need help with this php registration form. The registration form works but I recently noticed I have been getting a bunch of bogus registered accounts. Is there a way to add the registered users ip address so that when I view the new registered accounts it will show their ip address.
I have added the ip value to the database as ip char (45) utf8_unicode_ci null=yes default=null but can’t seem to figure out what I need to add to this code to get the ip value to show. Any help is much appreciated.
[php]if(ereg(“register.php”,$_SERVER[‘PHP_SELF’])){
@header(“Location:index.php”);
die(“”); //js redirect backup
}
//If form post => process form
if(isset($_POST['name']) && $_POST['name'] != ""){
//Validate Form Fields
require_once("classes/vImage.php");
$vImage = new vImage();
$vImage->loadCodes();
$error = array();
//verify image text
if($vImage->sessionCode != $vImage->postCode){
$error[] = "Image Verification Text is Invalid\n";
}
//verify name
if(!isset($_POST['name']) || $_POST['name'] == ""){
$error[] = "Enter Name\n";
}
//verify phone
if(!isset($_POST['phone']) || $_POST['phone'] == ""){
$error[] = "Enter Phone\n";
}
//verify email
if(!validEmail($_POST['email'])){
$error[] = "Enter Valid Email\n";
}
//verify confirm email
if(!isset($_POST['confirmemail']) || $_POST['confirmemail'] == ""){
$error[] = "Enter Confirm Email\n";
}
//verify email equals confirm email
if($_POST['email'] != $_POST['confirmemail']){
$error[] = "Confirm Email does not match\n";
}
//verify password
if(!isset($_POST['password']) || $_POST['password'] == ""){
$error[] = "Enter Password\n";
}
//verify confirm password
if(!isset($_POST['confirmpassword']) || $_POST['confirmpassword'] == ""){
$error[] = "Enter Confirm Password\n";
}
//verify password equals confirm password
if($_POST['password'] != $_POST['confirmpassword']){
$error[] = "Confirm Password does not match\n";
}
//Verify email is not already registered
$sql = sprintf("select * from members where email LIKE '%s'", mysql_real_escape_string($_POST['email'], $mysql->conn));
$result = $mysql->exSql($sql) or die($mysql->debugPrint());
if(mysql_num_rows($result)>0){
$error[] = "Email address already registered\n";
}
//Display Error (if needed)
if(sizeof($error)>0){
for($i=0;$i<sizeof($error);$i++){
$xtpl->assign('error',$error[$i]);
$xtpl->parse('main.register.error');
}
}else{ //else no error => register member
$node = new sqlNode();
$node->table = "members";
$node->push("text","name",$_POST['name']);
$node->push("text","phone",$_POST['phone']);
$node->push("text","address",$_POST['address']);
$node->push("text","city",$_POST['city']);
$node->push("text","state",$_POST['state']);
$node->push("text","zip",$_POST['zip']);
$node->push("text","email",$_POST['email']);
$node->push("text","password",$_POST['password']);
$node->push("text","active","Yes"); //default
$node->push("defined","created","NOW()");
$result = $mysql->insert($node) or die($mysql->debugPrint());
$xtpl->parse('main.thankyou');
$xtpl->parse('main');
$xtpl->out('main');[/php]