discourse-legacysite-perl/site/slowtwitch.com/www/adio/create_X.php
2024-06-17 22:30:36 +10:00

77 lines
2.5 KiB
PHP

<?PHP
if (!$_POST){ header('Location: '.$site_url); }
/*
FIELD NAMES:
account_id
account_user_id_fk
account_advertiser
account_contact
account_phone
account_email
account_other
account_invoice
account_notes
*/
/* Need to ltrim and rtrim commas before insertion */
//Insert into database
//$pass = 'abc123';
$errmsg = NULL;
$insert_success = NULL;
//Check for blank fields
if ((!$_POST[advertiser])) $errmsg = $errmsg."Account Name, ";
if ((!$_POST[contact])) $errmsg = $errmsg."Primary Contact, ";
if ((!$_POST[forumid])) $errmsg = $errmsg."Forum ID #, ";
if (!$_POST[city]) $errmsg = $errmsg."City, ";
if (!$_POST[state]) $errmsg = $errmsg."State, ";
if (!$_POST[address]) $errmsg = $errmsg."Address, ";
if (!$_POST[phone]) $errmsg = $errmsg."Phone, ";
if (!$_POST[email]) $errmsg = $errmsg."Email, ";
if (!$_POST[invoice]) $errmsg = $errmsg."Invoice, ";
if (isset($errmsg)) {
$errmsg = "The following fields cannot be left blank: ".$errmsg."<br />";
$errmsg = rtrim($errmsg, ", ");
}
// begin error message check
if(!$errmsg){
$advertiser = trim($_POST[advertiser]);
$contact = trim($_POST[contact]);
$forumid = trim($_POST[forumid]);
$address = mysql_escape_string(trim($_POST[address]));
if (isset($_POST['address_two'])) { $address_two = mysql_escape_string(trim($_POST[address_two])); } else { $address_two = NULL; }
$city = mysql_escape_string(trim($_POST[city]));
$state = $_POST[state];
$state_tag = strtolower(str_replace(" ","", $state));
$zip = mysql_escape_string(trim($_POST[zip]));
$phone = trim($_POST[phone]);
$email = mysql_escape_string(trim($_POST[email]));
$other = mysql_escape_string(trim($_POST[other]));
$invoice = mysql_escape_string($_POST[invoice]);
$notes = mysql_escape_string(nl2br(substr(trim($_POST[notes]), 0, 4096)));
$submitted_by = $_POST[submitted_by];
// begin boolean check to see if we should insert the account into the dbase
if($_POST[insert_account] == true){
$sql = "INSERT INTO io_account (account_advertiser, account_user_id_fk, account_contact, account_address, account_address_two, account_city, account_state, account_zip, account_phone, account_email, account_other, account_invoice, account_notes) VALUES ('$advertiser', '$forumid', '$contact', '$address', '$address_two', '$city', '$state', '$zip', '$phone', '$email', '$other', ',$invoice,', '$notes')";
//echo("account entered!");
//echo($sql);
mysql_query($sql) OR die(mysql_error());
//exit();
$insert_success = true;
}else{
//echo("shop NOT entered.");
$confirm_account = true;
}
// end insert check
}
// end error message check
?>