[insert_php]
// This function will run within each post array including multi-dimensional arrays
function ExtendedAddslash(&$params)
{
foreach ($params as &$var) {
// check if $var is an array. If yes, it will start another ExtendedAddslash() function to loop to each key inside.
is_array($var) ? ExtendedAddslash($var) : $var = addslashes($var);
unset($var);
}
}
// Initialize ExtendedAddslash() function for every $_POST variable
ExtendedAddslash($_POST);
//If statement checks to make sure array index is valid, and then pulls the value from that index into a variable
if (isset($_POST[‘companyname’])) {
$companyname = $_POST[‘companyname’];
}
if (isset($_POST[‘firstname’])) {
$firstname = $_POST[‘firstname’];
}
if (isset($_POST[‘lastname’])) {
$lastname = $_POST[‘lastname’];
}
if (isset($_POST[‘positionid’])) {
$positionid = $_POST[‘positionid’];
}
//see which level dropdown was chosen
if (isset($_POST[‘level16’])) {
//if its L1-L3
$level = $_POST[‘level16’];
} elseif (isset($_POST[‘level15’])) {
//if its L1-L4
$level = $_POST[‘level15’];
} elseif (isset($_POST[‘level14’])) {
//if its L1-L5
$level = $_POST[‘level14’];
} else {
if (isset($_POST[‘level’])) {
$level = $_POST[‘level’];
}
}
if (isset($_POST[‘candidateresume’])) {
$resume = $_POST[‘candidateresume’][0];
}
//capture the date of submission
$timezone = date_default_timezone_get();
date_default_timezone_set($timezone);
$date = date(‘m/d/Y h:i:s a’, time());
//Variables for database info
$db_host = ‘dstrickland’;
$db_username = ‘internal_partners’;
$db_password = ‘D0m!n!c1!@’;
$db_name = ‘internal_partners’;
//Connects to the database
mysql_connect($db_host, $db_username, $db_password) or die(mysql_error());
mysql_select_db($db_name);
// This checks for duplicate submissions, but for our use, duplicates are allowed.
//$query = “SELECT * FROM `table_name` WHERE `submission_id` = ‘$submission_id'”;
//$sqlsearch = mysql_query($query);
//$resultcount = mysql_numrows($sqlsearch);
//if ($resultcount > 0) {
// mysql_query(“UPDATE `table_name` SET
// `name` = ‘$name’,
//`email` = ‘$email’,
//`phone` = ‘$phonenumber’,
//`subject` = ‘$subject’,
//`message` = ‘$message’
//WHERE `submission_id` = ‘$submission_id'”)
//or die(mysql_error());
//} else {
//Inserts the form data into the database
mysql_query(“INSERT INTO `partners` (Position, Company, Level, First_Name, Last_Name,
Date_of_Submission, Resume_Location)
VALUES (‘$positionid’, ‘$companyname’, ‘$level’, ‘$firstname’, ‘$lastname’,
‘$date, ‘$candidateresume’) “)
or die(mysql_error());
[/insert_php]