Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- $hostname = "localhost";
- $db_user = "username";
- $db_password = "passwd";
- $database = "databse";
- $db_table = "voter_info";
- $db = mysql_connect($hostname, $db_user, $db_password);
- mysql_select_db($database,$db);
- function check_email($email, $optional)
- {
- if ( (strlen($email) == 0) && ($optional === true) ) {
- return true;
- } elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) {
- return true;
- } else {
- return false;
- }
- }
- if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
- $ClientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
- } else {
- $ClientIP = $_SERVER['REMOTE_ADDR'];
- }
- $name = $_POST['voter-name'];
- $email = $_POST['voter-email'];
- $county = $_POST['voter-county'];
- $why = $_POST['voter-why'];
- // validate email using fn above
- // validate other form fields, and echo error if validations fail
- if (get_magic_quotes_gpc) {
- $name = stripslashes($name);
- $email = stripslashes($email);
- $county = stripslashes($county);
- $why = stripslashes($why);
- }
- $sql = "INSERT INTO $db_table(voter_name,voter_email, voter_county, voter_why) values ('".mysql_real_escape_string($name)."','".mysql_real_escape_string($email)."','".mysql_real_escape_string($county)."','".mysql_real_escape_string($why)."';
- ?>
Add Comment
Please, Sign In to add comment