Jump to content

Dynamic Image and Data Upload Simultaneously


ivoilic

Recommended Posts

Ok so I have a form to submits to a .php file that creates an image.  This works fine, but I also want the info from the form to be sent to MySQL database.  The problem is that something in a script I "required" called core.inc.php is interfering and so no image is output.  Here is core.inc.php:

<?php
ob_start();
session_start();
$current_file = $_SERVER['SCRIPT_NAME'];

if(isset($_SERVER['HTTP_REFERER'])&&!empty($_SERVER['HTTP_REFERER'])) {
$http_referer = $_SERVER['HTTP_REFERER'];
}

function loggedin() {
if(isset($_SESSION['user_id'])&&!empty($_SESSION['user_id'])) {
	return true;
} else {
	return false;
}
}

function getuserfield($field) {
$query="SELECT `$field` FROM `Users` WHERE `id`='".$_SESSION['user_id']."'";
if($query_run=mysql_query($query)) {
	if($query_result = mysql_result($query_run, 0, $field)) {
		return $query_result;	
	}
}
}

?>

 

Here is the code for the image creating .php file:

<?php
require 'connect.inc.php';
require 'core.inc.php';
$title = $_REQUEST['title'] ;
$user_id = getuserfield('id');
$query = "INSERT INTO `---` VALUES ('".mysql_real_escape_string($title)."','".mysql_real_escape_string($user_id)."')";
$query_run = mysql_query($query);
//There is some more code in here obviously, but it's irrelevant 
header('Content-type: image/png');
imagepng($image_f);
imagedestroy($image_f)

 

Can anybody give me some idea of what is conflicting or what I can do to fix it?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.