This is the form I have it has been okay with adding info to db but maybe there is something I missed as to why the next page is having so much fun.
PHP Code:
session_start();
error_reporting(E_ALL);
ini_set("display_errors", 1);
include_once ("Connections/connect_to_mysql.php");
$err='';
$username='';
$firstname='';
$lastname='';
$password='';
$country='';
$email='';
$_SESSION['id']='id';
if(isset($_POST["submit"])){
// Validate form data
if($_POST["firstname"]=='') $err.='Please enter First Name<br>';
if($_POST["email"]=='') $err.='Please enter Email<br>';
if($err==''){
// Check if there are duplicate entries in the 'contacts' table
$sql_check = mysql_query("SELECT id FROM `Members` WHERE username='".addslashes($_POST["username"])."' and firstname='".addslashes($_POST["firstname"])."' and Email='".addslashes($_POST["email"])."'");
if($row = mysql_fetch_array($sql_check)){
$err.='Can not add duplicate entry<br>';
}
else{
// adding new record to 'contacts' table
$results = mysql_query("INSERT INTO Members (username,firstname,lastname,password,country,Email)
values ('".mysql_real_escape_string($_POST["username"])."','".mysql_real_escape_string($_POST["firstname"])."','".mysql_real_escape_string($_POST["lastname"])."','".md5($_POST["password"])."','".mysql_real_escape_string($_POST["country"])."','".mysql_real_escape_string($_POST["email"])."')")
or die (mysql_error());
$id = mysql_insert_id();
$userid = mysql_insert_id();
// redirecting to success screen
if($results){
header("Location: login.php");
}else
die(mysql_error());
}
}
}



Reply With Quote



Bookmarks