I had a friend of mine make this php code for me. Im still trying to learn all of the ends and outs of it. What I am looking to do is #1, ad a code to allow the information provided to be emailed to me after the submitter has completed the form, and #2, change the code for looking for identical ip’s to block submitters, to looking for identical GLVAR numbers to block submitters. Im not 100% sure where to make these changes in the lines of code without messing everything up. Any help would be greatly appreciated.
[php]<?php
include(‘database/config.php’);
include(‘database/database.php’);
$err = '';
if(isset($_POST['submit'])){
$first = addslashes(trim($_POST['first']));
$last = addslashes(trim($_POST['last']));
$glvar = addslashes(trim($_POST['glvar']));
$ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
//echo $ip;
if(($first!='')&& ($last!='')&& ($glvar!='')){
$database = new Database(HOST, DATEBASE, USERNAME, PASSWORD);
$allUsers = $database->select('user','ip','*',"ip = '".$ip."'");
//echo $ip;
$checkIp = 0;
$checkIp = count($allUsers);
$userData = array(
'first_name' => $first,
'last_name' => $last,
'glvar_id' => $glvar,
'ip' => $ip,
);
if(!$checkIp) {
$database->insert('user',$userData);
header('location:thank-you.html');
} else {
$err.='<p style="color:red">Ooops! You have already signed the petition</p>';
} else {
if($first=='') $err.='<p style="color:red">Your first name not empty</p>';
if($last=='') $err.='<p style="color:red">Your last name not empty</p>';
if($glvar=='') $err.='<p style="color:red">Your GLVAR ID not empty</p>';
}
}
?>[/php]