PHP ID Card Printing

Hello everyone, this may be a long shot but I have to ask anyways. I am writting an internal php/MSSQL site to handle visitors that come and go at our department. I wrote it out to where we can get all their information, and check them in and out.

I have two features that I want to add to it and they are

1: Visitor Image (And Thumbnail)
2: Printing an ID card with image and certain information

Adding images to the site I found a few tutorials on for MySQL so I am seeing if I can convert that to MSSQL. But the printing is something I am clueless on this and not sure even if it is possible. I would want to be able to have a ‘ID card Print Page’ that would show the image and certain data in a certain format to be printed.

So long story short…is this even possible? If so, any sugegstions?

Thank you guys for all your time and help so far.

You just build the ID card in HTML and the browser handles the printing - unless I’m missing something?

Yea, your right sir. It is pretty much that simple, I was thinking there was possibly some better way through SQL Reporting and PHP, but we are good to go now so thank you sir. By the way, I’m really not very good at this, so if my logic is flawed or im just asking a dumb question, feel free to let me know im being dumb.

Onto a new issue with it though. Here is my code for the index/insert visitor page:
[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'])) { $aAllowed = array( 'Visitor_Name_Prefix', 'Visitor_Name_First', 'Visitor_Name_Middle', 'Visitor_Name_Last', 'Visitor_Name_Suffix', '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
SPD ID Number:


Visit Information

Date:

Purpose:

Time of Meeting:

Escort Status:
Escorted Un-Escorted
Visted Department:

Visited Prefix:

Visited First Name:

Visited Last Name:


[/php]

I was just wondering if the was a way to redirect after submitting this form to a ‘print id’ page with the record you just entered showing?

I am not familiar with MSSQL functions but I did find this:

http://social.msdn.microsoft.com/Forums/en-US/sqldriverforphp/thread/3eeb9539-4cb6-473c-8f53-562b7054f94a/

Sponsor our Newsletter | Privacy Policy | Terms of Service