Please this is very urgent. I have a script that is ment to process a form and then store the result in my database but for some reason, I do not have it working… Here it is:
loggedin.php
<?php
session_start(); // Start the session.
// If no session value is present, redirect the user:
ob_start();
if (!isset($_SESSION['userID'])) {
require_once ('loginFunction.inc.php');
$url = absolute_url();
header("Location: ".$url);
exit();
}
?>
<!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>Welcome to ADesigns: Home</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table id="outerTable">
<tr><td id="logo">
<div>
<img src="./images/logo.png" width="150" height="55" alt="company_logo" />
</div>
</td></tr>
<tr><td id ="nav">
<div>
<a href="home.html">Home</a> |
<a href="participate.html">Participate</a> |
<a href="aboutUs.html">About ADesigns</a> |
<a href="contact.html">Contact Us</a>
</div>
</td></tr>
<tr><td id="banner"> <! -- page banner image -->
<img src="images/home.jpg" width="770" height="" alt="welcome to ADesigns">
</td></tr>
<tr><td>
<table id="contentTable">
<tr>
<td id="topLeft">
<br />
<div id="welcomeBox">
<h1>Advertisments</h1>
<p>This section covers adverts from other companies</p>
</div> <! -- mainContent -->
</td>
<td id="topRight">
<br />
<div id="loginRegBox">
<?php
// Print a customized message:
echo "<h1>Logged In!</h1> <p>You are now logged in, {$_SESSION['fname']}!</p>";
?>
<p><b>Congratualtion</b> on your successful login to our website. Now you can start the
fun part and upload your designs. All you have to do is fill up the blanks appropriately.</p>
<p><b>Note:</b> For each upload, you will need to specify that it is a
logo for your design, a picture of yourself or one of your designs.</p>
<p>For ease of use you need to upload one file each for the following:</p>
<p><b>Photograph:</b> a small picture of yourself for visitors to see. Only need once.</p>
<p><b>Logo:</b> your company logo. Also only need one.</p>
<form method="post" action="loggedin_v2.php" enctype="multipart/form-data" >
<!--<div>
<label for="uploadPhoto">Upload Photograph:</label>
<input type="file" name="uploadPhoto" id="upload"/>
</div> -->
<div>
<label for="uploadLogo">Upload Logo:</label>
<input type="file" name="uploadLogo" id="upload"/>
</div>
<!--
I do not need you at the moment:
<div>
<label for="imgType">Image Type:</label>
<input type="radio" name="imageType" id="logo" value="logo" />Logo
<input type="radio" name="imageType" id="photo" value="photo" />Photo
<input type="radio" name="imageType" id="design" value="design" />Design
</div>
-->
<div>
<label for="brandID">Brand Identity:</label>
<textarea name="brandID" rows="4" cols="40" id="brandID"></textarea>
</div>
<div>
<label for="history">Please tell us about yourself:</label>
<textarea name="history" rows="20" cols="40" id="history"></textarea>
</div>
<div>
<input type="submit" name="btnSubmit" id="btnSubmit" value="Upload" />
</div>
</form>
<p><a href="logout.php">Logout</a></p>
</div> <! -- mainContentRight -->
</tr>
</table>
</td></tr>
<tr><td id="footer"><div id="footerLastRow"><p>© ADesigns <a href="#">Privacy Policy</a> | <a href="#">Terms and Conditions</a></p></div></td></tr>
</table>
</body>
</html>
The processing is done here in loggedin_v2.php:
<?php
/*Upon submission of scriipt from loggedin.html
*the form is sent here for process
*/
session_start(); //start session
ob_start(); //prevent header errors
if (!isset($_SESSION['userID']) ) {
require_once ('loginFunction.inc.php');
$url = absolute_url();
header("loaction: " .$url);
exit();
}
$page_title = 'Welcome to ADesigns: Logged In!';
include ('includes/header.html');
if(isset($_POST['btnSubmit']))
{
$error=array();
//Check brand Identity
if (empty($_POST['brandID']))
{
$error[] ='You have no brand identity.';
}
else
{
$brandID =trim($_POST['brandID']);
}
//Check history
if (empty($_POST['history']))
{
$error[] ='You have no history.';
}
else
{
$history =trim($_POST['history']);
}
if (isset($_FILES['upload']) )
{
// Bail out if the file isn't really an upload.
if (!is_uploaded_file($_FILES['upload']['tmp_name']))
{
exit('There was no file uploaded!');
}
$uploadfile = $_FILES['upload']['tmp_name'];
$uploadname = $_FILES['upload']['name'];
$uploadtype = $_FILES['upload']['type'];
$uploadBrandID = $_POST['brandID'];
$uploadHistory = $_POST['history'];
// Open file or binary reading ('rb')
$tempfile = fopen($uploadfile, 'rb');
// Read the entire file into memory using PHP's
// filesize fucntion to get the size.
$filedata = fread($tempfile, filesize($uploadfile));
// Prepare for database insert by adding backslashes
// before special characters.
$filedata = addslashes($filedata);
if(!empty($error) )
{
//If all goes according to plan:
require_once('mysql_connect.php');
// Create the SQL query.
$sql = "INSERT INTO logo SET
filename = '$uploadname',
mimetype = '$uploadtype',
description = '$uploaddesc',
filedata = '$filedata',
brandIdentity = '$uploadBrandID',
history = '$uploadHistory'";
// Perform the insert.
$ok = @mysql_query($sql);
if(!$ok)
{
exit('Database error storing file: ' . mysql_error());
}
header('location: ' . $_SERVER['PHP_SELF']);
exit();
}
}
}
?>
Please I urgently need assistance with this.