Hi
I'm new in php.I have created a Form to insert data into the database its working fine. The other is to show all records from the database its too fine. I don't know where to start, Want i want is to edit one record at a time when i click edit I want the form to appear with Name,Email and Attachments filled with the data of that record and be able to edit it and save. Here I update my codding briefly.
complete.php
<!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>My First Project in PHP</title>
</head>
<body bgcolor=tan>
<h1><font color="firebrick">PHP MySQL </font></h1>
<form action="success.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="box" value="100000">
<table width="500" border="1">
<tr><td><b><label for='name'>Name :</b></label></td> <td><input type="text" name="Uname" size="20" /></td></tr>
<tr><td><b><label for='mail'>Email :</b></label></td><td><input type="text" name="mail" size="20" /></td></tr>
<tr><td><b> <label for='Updated_file'>Attachements:</b></label></td> <td> <input type="file" name="Updated_file" id="Updated_file" /></td></tr>
<tr><td colspan="2" align="center"><input type="Submit" value="Submit" name="Submit" id="Submit" onClick="return validate();"> <input type="reset" value="Reset" name="reset"> </td></tr>
</table>
</form>
<p>
<a href="output.php">See all Attachment files</a>
</p></body>
</html>
**success.php**
$con = mysql_connect("localhost", "root");
mysql_select_db("connect_db", $con);
/*$sql = "CREATE TABLE upload1 (
id INT NOT NULL AUTO_INCREMENT,
User_Name VARCHAR(30) NOT NULL,
Email VARCHAR(30) NOT NULL,
name VARCHAR(30) NOT NULL,
type VARCHAR(30) NOT NULL,
size INT NOT NULL,
content MEDIUMBLOB NOT NULL,
PRIMARY KEY(id)
)";
mysql_query($sql,$con);*/
$Uname = $_POST['Uname'];
$mail = $_POST['mail'];
error_reporting(0);
$fileName = $fileName . basename ($_FILES['Updated_file']['name']);
$tmpName = move_uploaded_file($_FILES['Updated_file']['tmp_name'], $fileName);
$fileSize = $_FILES['Updated_file']['size'];
$fileType = $_FILES['Updated_file']['type'];
$query = "INSERT INTO upload1 (User_Name, Email, name, size, type, content) VALUES ('".$Uname."', '".$mail."', '".$fileName."', '".$fileSize."', '".$fileType."', '".$content."' )";
mysql_query($query) or die("Error, query failed");
if($query)
{
echo 'Success! Your file was successfully added in database!';
}
else
{
echo 'Error! Failed to insert the file'. "<pre>{$dbLink->error}</pre>";
}
echo '<p>Click <a href="complete.php">here</a> to go back</p>';
mysql_close($con);
?>
output.php
<?php
$con = mysql_connect("localhost", "root");
mysql_select_db("connect_db", $con);
error_reporting(0);
$fileName = $fileName . basename ($_FILES['Updated_file']['name']);
$tmpName = move_uploaded_file($_FILES['Updated_file']['tmp_name'], $fileName);
$fileSize = $_FILES['Updated_file']['size'];
$fileType = $_FILES['Updated_file']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
$result = mysql_query("SELECT * FROM upload1");
while($row = mysql_fetch_array($result))
{
echo "<font color='red'>Name :</font> ".$row['User_Name'].",<br >";
echo "<font color='blue'>Email :</font>".$row['Email'].",<br >";
echo "<font color='green'>Attachements :</font>"."<a href='{$row['name']}' > 'Download'</a>".".<br />";
echo "<br/>";
}
mysql_close($con);
?>
Plz help me.