I'm new to php so this question might be really lame. I'm trying to upload images to my database and have been able to do that but I also want to add the title that I add on the first page and i have no clue how to go about that:
here's the code:
addform.php
<?php
$dbhost = 'localhost';
$dbuser = 'user';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'imagegal';
mysql_select_db($dbname);
?>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Multiple image upload script from plus2net.com</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<?
$max_no_img=5; // Maximum number of images value to be set here
echo "<form method=post action=addimg.php enctype='multipart/form-data'>";
echo "<table border='0' width='550' cellspacing='0' cellpadding='0' align=center>";
for($i=1; $i<=$max_no_img; $i++){
echo "<tr><td>Images $i</td><td>
<input type=file name='images[]' class='bginput'></td>
<td>
<td><label>Image title</label></td><td>
<input type=text name='title[]' class='bginput'></td></tr>";
}
echo "<tr><td colspan=6 align=center><input type=submit value='Add Image'></td></tr>";
echo "</form> </table>";
?>
</body>
</html>
addimg.php
<?
//***************************************
// This is downloaded from
www.plus2net.com //
/// You can distribute this code with the link to
www.plus2net.com ///
// Please don't remove the link to
www.plus2net.com ///
// This is for your learning only not for commercial use. ///////
//The author is not responsible for any type of loss or problem or damage on using this script.//
/// You can use it at your own risk. /////
//*****************************************
?>
<?php
$dbhost = 'localhost';
$dbuser = 'user;
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'imagegal';
$table = 'gallery';
mysql_select_db($dbname);
?>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<?
while(list($key,$value) = each($_FILES['images']['name']))
{
if(!empty($value))
{
$filename = $value;
$image_name=time().$extension;
$filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line
$filename=$image_name.$filename;
$add = "upimg/$filename";
//echo $_FILES['images']['type'][$key];
// echo "<br>";
copy($_FILES['images']['tmp_name'][$key], $add);
chmod("$add",0777);
mysql_query("INSERT INTO {$table}
SET data='$add'");
}
}
?>
</body>
</html>
I'm adding the path as text and not longblob since i'll need the physical path of the file later. So any ideas how i can add the title with the image.
Thanks in advance for any help.