Insert an image from a Database
Hi - I am trying to insert an image from a database into a webpage. Basically when clients register on the site they upload their logo which i want to come up when they look at their account details and when they post a job. When I test the file upload the file name is in an "image" field in my database and the image is in the website files on the server but I am having problems trying to get the logo to shop up on the webpage. I have one table called Recruiters where all the client's contact details (and logo upload goes) and a table called jobs where all the job details go when they post a job (this does not hold the logo upload).
At the moment i am trying to insert the image into the Recruiter account Details page where all the clients contact details are and all this information comes from the Recruiter table (including the image) but the image does not appear. the query in my recordset is:-
SELECT *
FROM recruiters
WHERE RecruiterID = colname
(colname = $_GET['RecruiterID'])
<?php require_once('../Connections/laura.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "../index.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "Recruiter";
$MM_donotCheckaccess = "false";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "../Unavailablepage.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_rsAccountDetails = "-1";
if (isset($_GET['RecruiterID'])) {
$colname_rsAccountDetails = $_GET['RecruiterID'];
}
mysql_select_db($database_laura, $laura);
$query_rsAccountDetails = sprintf("SELECT * FROM recruiters WHERE RecruiterID = %s", GetSQLValueString($colname_rsAccountDetails, "int"));
$rsAccountDetails = mysql_query($query_rsAccountDetails, $laura) or die(mysql_error());
$row_rsAccountDetails = mysql_fetch_assoc($rsAccountDetails);
$totalRows_rsAccountDetails = mysql_num_rows($rsAccountDetails);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Nursery and Childcare Jobs in the UK</title>
<link href="../CSS/Global.css" rel="stylesheet" type="text/css" />
<script src="../SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<link href="../SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
<!-- google adwords -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-6435415-4']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div class="container">
<div class="header"><!-- end .header --><a href="../index.php"><img src="../Images/Logo.png" width="900" height="200" alt="Logo" /></a></div>
<ul id="MenuBar1" class="MenuBarHorizontal">
<li><a href="../index.php">Home</a> </li>
<li><a href="#" class="MenuBarItemSubmenu">Recruiters</a>
<ul>
<li><a href="recruiterbenefits.php">Benefits</a></li>
<li><a href="recruiterfees.php">Fees</a></li>
<li><a href="recreg.php">Register</a></li>
<li><a href="reclogin.php">Login </a></li>
</ul>
</li>
<li><a class="MenuBarItemSubmenu" href="#">Jobseekers</a>
<ul>
<li><a href="../Jobseekerarea/jobseekerbenefits.php">Benefits</a> </li>
<li><a href="../Jobseekerarea/jobseekerreg1.php">Register</a></li>
<li><a href="../Jobseekerarea/jslogin.php">Login</a></li>
</ul>
</li>
<li><a href="../contactus.php">Contact Us</a></li>
</ul>
<div class="sidebar1">
<p> </p>
<div class="recruitsidebar">
<ul id="MenuBar2" class="MenuBarVertical">
<li><a href="postajob.php">Post a Job</a></li>
<li><a href="recruiterjobs1.php">My Jobs</a></li>
<li><a href="recAccdetails.php?RecruiterID=<?php echo $row_rsAccountDetails['RecruiterID']; ?>">My Details</a></li>
<li><a href="Saferrecruitment.php">Safer Recruitment</a></li>
<li><a href="Interview1.php" class="MenuBarItemSubmenu">Interviewing Staff</a>
<ul>
<li><a href="recInterviewquestions.php">Nursery Staff Interview Questions</a></li>
</ul>
</li>
<li><a href="Nurseryjobsdescriptions.php">Nursery Job Descriptions</a></li>
<li><a href="recruiterarea.php">Recruiter Home</a></li>
<li><a href="<?php echo $logoutAction ?>">Log Out</a></li>
</ul>
<p> </p>
</div>
</div>
<div class="content">
<h1>Account Details</h1>
<p>Below are the details you have provided us with about your nursery/setting.</p>
<p> </p>
<form id="accountdetailsform" name="accountdetailsform" method="post" action="recUpdate.php?RecruiterID=<?php echo $row_rsAccountDetails['RecruiterID']; ?>">
<table width="580" border="0" cellpadding="3" cellspacing="3" id="accountdetails">
<tr>
<td width="212" scope="col">Nursery/Setting Name</td>
<td width="347" scope="col"><?php echo $row_rsAccountDetails['client']; ?></td>
</tr>
<tr>
<td>Contact Name</td>
<td><?php echo $row_rsAccountDetails['contactname']; ?></td>
</tr>
<tr>
<td>Setting Type</td>
<td><?php echo $row_rsAccountDetails['settingtype']; ?></td>
</tr>
<tr>
<td>Nursery/Setting</td>
<td><?php echo $row_rsAccountDetails['Setting']; ?></td>
</tr>
<tr>
<td>Building Name/Number</td>
<td><?php echo $row_rsAccountDetails['buildingnumber']; ?></td>
</tr>
<tr>
<td>Street Name</td>
<td><?php echo $row_rsAccountDetails['streetname']; ?></td>
</tr>
<tr>
<td>Address</td>
<td><?php echo $row_rsAccountDetails['address3']; ?></td>
</tr>
<tr>
<td>Town/City</td>
<td><?php echo $row_rsAccountDetails['town']; ?></td>
</tr>
<tr>
<td>Post Code</td>
<td><?php echo $row_rsAccountDetails['postcode']; ?></td>
</tr>
<tr>
<td>Region</td>
<td><?php echo $row_rsAccountDetails['region']; ?></td>
</tr>
<tr>
<td>Telephone</td>
<td><?php echo $row_rsAccountDetails['telephone']; ?></td>
</tr>
<tr>
<td>Email</td>
<td><?php echo $row_rsAccountDetails['email']; ?></td>
</tr>
<tr>
<td>Website</td>
<td><?php echo $row_rsAccountDetails['WebAddress']; ?></td>
</tr>
<tr>
<td>Password</td>
<td> </td>
</tr>
<tr>
<td>Logo</td>
<td><img src="<?php echo $row_rsAccountDetails['Image']; ?>" alt="Logo" /></td>
</tr>
<tr>
<td>Date Registered</td>
<td><?php echo $row_rsAccountDetails['dateregistered']; ?></td>
</tr>
</table>
<p>
<input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $row_rsAccountDetails['RecruiterID']; ?>" />
</p>
<p>
<input type="submit" name="Update" id="Update" value="Update Details" />
</p>
<p> </p>
</form>
<p> </p>
<table width="600" border="0" cellpadding="3" cellspacing="3" class="postform">
<tr> </tr>
<tr> </tr>
<tr> </tr>
</table>
<p> </p>
<p> </p>
</div>
<div class="sidebar2">
<h4> </h4>
<!-- end .sidebar2 --></div>
<div class="footer">
<p><a href="../index.php">Home</a> | <a href="../contactus.php">Contact us</a> | <a href="../PrivacyPolicy.php">Privacy</a> | <a href="../termsandconditions.php">Terms of Business</a></p>
<p>© theNurseryJobSite.com 2011</p>
<!-- end .footer --></div>
<!-- end .container --></div>
<script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
var MenuBar2 = new Spry.Widget.MenuBar("MenuBar2", {imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
</script>
</body>
</html>
<?php
mysql_free_result($rsAccountDetails);
?>
