session_start();
// Check if the referring page is not index.php, accountCreationForm.php, or if the referrer is blank
if(!isset($_SERVER['HTTP_REFERER']) || (strpos($_SERVER['HTTP_REFERER'], 'index.php') === false && strpos($_SERVER['HTTP_REFERER'], 'accountCreationForm.php') === false)) {
// Redirect back to index.php
header('Location: index.php');
exit; // Ensure that no further code is executed after redirection
}
$referrer = $_SERVER['HTTP_REFERER'];
//echo"
$referrer
";
$_SESSION['signupAuth']="Yes";
include"../master_inc.php";
$action=$_REQUEST['action'];
$lastUN = $_SESSION['lastUN'];
$lastPW = $_SESSION['lastPW'];
if($action=="pt1Save"){
$_SESSION['signupPhase']="2";
$accessionNew=date("YmdHis");
$email=$_REQUEST['email'];
//echo"
email: $email
";
$query = "SELECT * FROM agents WHERE `email` = '$email'";
$result = $conn->query($query);
$numrows = $result->num_rows;
//echo"
Numrows: $numrows
";
if($numrows<1){
$query = "INSERT INTO `organization` (
`accession`,
`oName`,
`oSID`,
`oLogoImage`,
`oUrl`,
`oAddress1`,
`oAddress2`,
`oCity`,
`oState`,
`oZip`,
`oCountry`,
`oPhone`,
`oEmail`,
`oBizType`,
`oStatus`,
`oGateway`,
`oGatewayUN`,
`oGatewayPW`,
`oGatewayKey`,
`smsReplyPhone`,
`holdHarmess`,
`commissionsOn`,
`whatsItCalled`,
`signupPhase`
)
VALUES
(
'$accessionNew',
'$oName',
'$oSID',
'$oLogoImage',
'$oUrl',
'$oAddress1',
'$oAddress2',
'$oCity',
'$oState',
'$oZip',
'$oCountry',
'$oPhone',
'$oEmail',
'$oBizType',
'$oStatus',
'$oGateway',
'$oGatewayUN',
'$oGatewayPW',
'$oGatewayKey',
'$smsReplyPhone',
'$holdHarmess',
'$commissionsOn',
'Job',
'2')";
if (mysqli_query($conn, $query)) {
/*echo "
New record created successfully
";*/
} else {
echo "Error: " . $query . "" . mysqli_error($conn);
}
$query = "SELECT * FROM organization WHERE `accession` = '$accessionNew'";
$result = $conn->query($query);
$numrows = $result->num_rows;
//echo"Numrows: $numrows";
while($row = $result->fetch_assoc()) {
$oIDDB= $row["oID"];
$signupPhase= $row["signupPhase"];
}
//echo"oIDDB: $oIDDB
";
$password=$_REQUEST['password'];
// Generate MD5 hash variables
$user_encrypted = md5($email);
$pw_encrypted = md5($password);
$query = "INSERT INTO `agents` (
`accession`,
`firstName`,
`lastName`,
`title`,
`company`,
`email`,
`password`,
`phone`,
`address`,
`city`,
`state`,
`zip`,
`country`,
`notes`,
`permissions`,
`compPlan`,
`user_encrypted`,
`pw_encrypted`,
`status`,
`vehicleAssignment`,
`trailerAssignment`,
`organization`,
`market`,
`oID`,
`emailValidated`
)
VALUES
(
'$accessionNew',
'$firstName',
'$lastName',
'$title',
'$company',
'$email',
'$password',
'$phone',
'$address',
'$city',
'$state',
'$zip',
'$country',
'$notes',
'superAdmin',
'$compPlan',
'$user_encrypted',
'$pw_encrypted',
'1',
'$vehicleAssignment',
'$trailerAssignment',
'$oIDDB',
'$market',
'$oIDDB',
'0')";
if (mysqli_query($conn, $query)) {
/*echo "
New record created successfully
";*/
} else {
echo "Error: " . $query . "" . mysqli_error($conn);
}
$_SESSION['accession'] = $accessionNew;
header("location:accountCreationForm2.php");
}else{
//Check Signup Phase
if($signupPhase>1){
header("location:accountCreationForm2.php");
}else{
$warning = "

Step 1 of 4