Store and Retrieve image from a directory using php: Part 1
If you are having trouble with the manipulation of image in php these series of tutorials are for you.
I have noticed that many people are having problem with this operation in php.
Please I hate long speeches , lets go straight to the point.
In this tutorial you will store user information in the database and the picture of user in a directory and load the information.
Mysql table:
I stop here, please read the next part 2.
If you are having trouble with the manipulation of image in php these series of tutorials are for you.
I have noticed that many people are having problem with this operation in php.
Please I hate long speeches , lets go straight to the point.
In this tutorial you will store user information in the database and the picture of user in a directory and load the information.
Mysql table:
CREATE TABLE IF NOT EXISTS `testimonial` (Create a file: db.inc
`testid` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`pers_name` varchar(50) NOT NULL,
`country` varchar(25) NOT NULL,
`department` varchar(5) NOT NULL,
`message` text NOT NULL,
`pics_name` varchar(20) NOT NULL,
PRIMARY KEY (`testid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=23 ;
<?phpCreate a file: index.php
// Mysql configurations
$hostName = "localhost";
$username = "root";
$password = "";
// Show an error and stop the script
function showerror()
{
if (mysql_error())
die("Error " . mysql_errno() . " : " . mysql_error());
else
die("Could not connect to mysql");
}
?>
<html>
<body>
<table>
<tr>
<form action="upload_file_save.php" method="post" enctype="multipart/form-data">
</tr>
<tr>
<td>
<label for="file">Filename:</label>
</td>
<td>
<input type="file" name="file" id="file"><br>
</td>
</tr>
<tr>
<td>
<label for="persname">Student Name:</label>
</td>
<td>
<input type="text" name="persname">
</td>
</tr>
<tr>
<td>
<label for="country">Country Name:</label>
</td>
<td>
<input type="text" name="country">
</td>
</tr>
<tr>
<td>
<label for="department">Department:</label>
</td>
<td>
<input type="text" name="department">
</td>
</tr>
<tr>
<td>
<label for="message">Message:</label>
</td>
<td>
<textarea cols="40" rows="5" name="message">Write something here</textarea>
</td>
</tr>
<tr>
<td>
<input type="submit" name="submit" value="Submit">
</td>
<tr>
</form>
</table>
<?php echo '<a href="view.php">View all the picture </a><br> '; ?>
</body>
</html>
I stop here, please read the next part 2.
No comments:
Post a Comment