Hi,
This is the complete code. Does the code need to be placed at the top of the page?
The code has this in it but I dont have a header on the index.php page. Im not sure what a header is to be honest.
Code:
header("Location: index.php");
Code:
<?php
if(isset($_POST['submit'])){
$companyname = mysql_real_escape_string(trim($_POST['companyname']));
$password = trim($_POST['password']);
$password1 = mysql_real_escape_string(trim($_POST['password1']));
$emailaddress = mysql_real_escape_string(trim($_POST['emailaddress']));
if(!isset($companyname) || empty($companyname)) {
$error = "You need to enter a Company Name.";
}
if((!isset($password) || empty($password)) && !$error) {
$error = "You need to enter a password.";
}
if((!isset($password1) || empty($password1)) && !$error) {
$error = "You need to enter your password twice.";
}
if($password != $password1 && !$error) {
$error = "The passwords you entered did not match.";
}
if((!isset($emailaddress) || empty($emailaddress)) && !$error) {
$error = "You need to enter an email.";
}
if(preg_match("/[a-zA-Z0-9-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $emailaddress) == 0 && !$error) {
$error = "The email you entered is not valid.";
}
$query = mysql_query("SELECT userid FROM organisermembers WHERE emailaddress = '".$emailaddress."' LIMIT 1");
if(mysql_num_rows($query) > 0 && !$error) {
$error = "Sorry, that email is already in use!";
}
if(!$error) {
$query = mysql_query("INSERT INTO organisermembers (companyname, password, emailaddress) VALUES ('".$companyname."', '".mysql_real_escape_string(md5($password))."', '".$emailaddress."')");
if($query) {
$message = "Hello ".$_POST['companyname'].",\r\n\r\nThanks for registering! We hope you enjoy your stay.\r\n\r\nThanks,\r\nJohn Doe";
$headers = "From: ".$website['name']." <".$website['emailaddress'].">\r\n";
mail($_POST['emailaddress'], "Welcome", $message, $headers);
setcookie("user", mysql_insert_id(), $time);
setcookie("pass", mysql_real_escape_string(md5($password)), $time);
header("Location: index.php");
} else {
$error = "There was a problem with the registration. Please try again.";
}
}
}
?>
Bookmarks