Sorry about that last post. I really messed that up. Same problem for the most part though. But when I hit submit I get this error:
Array ( [0] => 42S22 [SQLSTATE] => 42S22 [1] => 207 [code] => 207 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid column name ‘front’. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid column name ‘front’. ) )
but front is a column in the DB.
[php]
var _debug = false;
var _placeholderSupport = function() {
var t = document.createElement(“input”);
t.type = “text”;
return (typeof t.placeholder !== “undefined”);
}();
window.onload = function() {
var arrInputs = document.getElementsByTagName(“input”);
for (var i = 0; i < arrInputs.length; i++) {
var curInput = arrInputs[i];
if (!curInput.type || curInput.type == “” || curInput.type == “text”)
HandlePlaceholder(curInput);
else if (curInput.type == “password”)
ReplaceWithText(curInput);
}
if (!_placeholderSupport) {
for (var i = 0; i < document.forms.length; i++) {
var oForm = document.forms[i];
if (oForm.attachEvent) {
oForm.attachEvent("onsubmit", function() {
PlaceholderFormSubmit(oForm);
});
}
else if (oForm.addEventListener)
oForm.addEventListener("submit", function() {
PlaceholderFormSubmit(oForm);
}, false);
}
}
};
function PlaceholderFormSubmit(oForm) {
for (var i = 0; i < oForm.elements.length; i++) {
var curElement = oForm.elements[i];
HandlePlaceholderItemSubmit(curElement);
}
}
function HandlePlaceholderItemSubmit(element) {
if (element.name) {
var curPlaceholder = element.getAttribute(“placeholder”);
if (curPlaceholder && curPlaceholder.length > 0 && element.value === curPlaceholder) {
element.value = “”;
window.setTimeout(function() {
element.value = curPlaceholder;
}, 100);
}
}
}
function ReplaceWithText(oPasswordTextbox) {
if (_placeholderSupport)
return;
var oTextbox = document.createElement(“input”);
oTextbox.type = “text”;
oTextbox.id = oPasswordTextbox.id;
oTextbox.name = oPasswordTextbox.name;
//oTextbox.style = oPasswordTextbox.style;
oTextbox.className = oPasswordTextbox.className;
for (var i = 0; i < oPasswordTextbox.attributes.length; i++) {
var curName = oPasswordTextbox.attributes.item(i).nodeName;
var curValue = oPasswordTextbox.attributes.item(i).nodeValue;
if (curName !== “type” && curName !== “name”) {
oTextbox.setAttribute(curName, curValue);
}
}
oTextbox.originalTextbox = oPasswordTextbox;
oPasswordTextbox.parentNode.replaceChild(oTextbox, oPasswordTextbox);
HandlePlaceholder(oTextbox);
if (!_placeholderSupport) {
oPasswordTextbox.onblur = function() {
if (this.dummyTextbox && this.value.length === 0) {
this.parentNode.replaceChild(this.dummyTextbox, this);
}
};
}
}
function HandlePlaceholder(oTextbox) {
if (!_placeholderSupport) {
var curPlaceholder = oTextbox.getAttribute(“placeholder”);
if (curPlaceholder && curPlaceholder.length > 0) {
Debug(“Placeholder found for input box '” + oTextbox.name + "’: " + curPlaceholder);
oTextbox.value = curPlaceholder;
oTextbox.setAttribute(“old_color”, oTextbox.style.color);
oTextbox.style.color = “#c0c0c0”;
oTextbox.onfocus = function() {
var _this = this;
if (this.originalTextbox) {
_this = this.originalTextbox;
_this.dummyTextbox = this;
this.parentNode.replaceChild(this.originalTextbox, this);
_this.focus();
}
Debug(“input box '” + _this.name + “’ focus”);
_this.style.color = _this.getAttribute(“old_color”);
if (_this.value === curPlaceholder)
_this.value = “”;
};
oTextbox.onblur = function() {
var _this = this;
Debug(“input box '” + _this.name + “’ blur”);
if (_this.value === “”) {
_this.style.color = “#c0c0c0”;
_this.value = curPlaceholder;
}
};
}
else {
Debug(“input box '” + oTextbox.name + “’ does not have placeholder attribute”);
}
}
else {
Debug(“browser has native support for placeholder”);
}
}
function Debug(msg) {
if (typeof _debug !== “undefined” && _debug) {
var oConsole = document.getElementById(“Console”);
if (!oConsole) {
oConsole = document.createElement(“div”);
oConsole.id = “Console”;
document.body.appendChild(oConsole);
}
oConsole.innerHTML += msg + “
”;
}
}
</script
<?php
include 'includes/db/connect.php';
error_reporting(E_ALL);
ini_set("display_errors", "on");
if (isset($_POST['Visitor_Name_Prefix'])) {
if(is_uploaded_file($_FILES['front']['tmp_name']))
{
$name = $_FILES['front']['name'];
$tmp_name = $_FILES['front']['tmp_name'];
$location = "front/$name";
move_uploaded_file($tmp_name,$location);
}
else{$location = 'front/default.jpg';}
$aAllowed = array( 'Visitor_Name_Prefix',
'Visitor_Name_First',
'Visitor_Name_Middle',
'Visitor_Name_Last',
'Visitor_Name_Suffix',
'front',
'Visitor_Agency',
'local_history',
'Visitor_ID_Type',
'Visitor_ID_Issue_Agency',
'Visitor_ID_Number',
'Surrendered_Own_ID',
'Spd_ID_Number',
'Date_Of_Visit',
'Purpose_Of_Visit',
'Time_Of_Visit',
'Individual_Visit_Department',
'Individual_Visit_Name_Prefix',
'Individual_Visit_Name_First',
'Individual_Visit_Name_Last',
'Escort_Status',
); // all the allowed items.
function removeUnknowns(&$item, $key, array $aAllowed)
{
if (!in_array($key, $aAllowed))
{
$item = "";
}
}
$aSubmitted = $_POST;
array_walk($aSubmitted, 'removeUnknowns', $aAllowed);
$aSubmitted = array_filter($aSubmitted);
$sFields = implode('], [', array_keys($aSubmitted));
$sReplacement = rtrim(str_repeat('?, ', count($aSubmitted)), ', ');
$sQry = "INSERT INTO [VisitorLog] ([$sFields]) VALUES ($sReplacement)";
if (false === ($stmt = sqlsrv_query($conn, $sQry, array_values($aSubmitted))))
{
die(print_r(sqlsrv_errors(), true));
}
}
?>
<?php
if (isset($_GET['submit_msg']))
{
echo "
";
echo $_GET['submit_msg'];
echo "
";
}
?>
<?php include 'includes/head/head_main.php'; ?>
<?php include 'includes/header/header_main.php'; ?>
SPD: Visitor Check In
Visitor Personal Information
Prefix:
Mr.
Mrs
Miss
Dr.
Det.
Ptlm.
Ptlw.
Cpl.
SrCpl.
Sgt.
MSgt.
Lt.
Capt.
Maj.
Col.
Chief.
|
First Name:
|
Middile Name:
|
Last Name:
|
Suffix:
Sr
Jr
III
IV
V
|
Visitor Agency:
|
History:
Yes
No
|
Visitor ID Information
Type:
|
Issuing Agency:
|
Number:
|
ID Surrendered:
Yes
No
|
Escort Status:
Escorted
Un-Escorted
|
SPD ID Number:
01
02
03
04
05
06
07
08
09
10
|
Visit Information
Date:
|
Purpose:
Interview Board
Interview Criminal
Testing
Polygraph
Fingerprints
Scheduled Meeting
Scrap Metal
Background Check
Employment
Visitor
Other
|
Check In Time:
|
Visted Department:
|
Visited Prefix:
|
Visited First Name:
|
Visited Last Name:
|
[/php][/code]