jeganathan
11-23-2010, 09:32 AM
Here i update my query. My problem is i want to open my attachments directly in HTML output.
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="open.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="box" value="100000">
<table width="500" border="1">
<tr><td><b><label for='Uname'>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="userfile" /></td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="Submit" name="submit" onClick="return validate();"> <input type="reset" value="Reset" name="reset"> </td></tr>
</table>
</form>
</body>
</html>
open.php
<?php
$con = mysql_connect("localhost","root");
mysql_select_db("connect_db", $con);
$Uname = $_POST['Uname'];
$mail = $_POST['mail'];
error_reporting(0);
$Updated_file = $_POST['Updated_file'];
$target_path = $target_path . basename( $_FILES['Updated_file']['name']);
move_uploaded_file($_FILES['Updated_file']['tmp_name'], $target_path);
$eBanner = basename( $_FILES['Updated_file']['name']);
$query = "INSERT INTO details (Name, Email, Attachements) VALUES ('".$Uname."', '".$mail."', '".$Updated_file."')";
mysql_query($query, $con) or die(mysql_error());
$result = mysql_query("SELECT * FROM details");
while($row = mysql_fetch_array($result))
{
echo "<font color='red'>Name :</font> ".$row['Name'].",<br />";
echo "<font color='blue'>Email :</font>".$row['Email'].",<br />";
echo "<font color='green'>Attachements :</font>".'"<a href="http://localhost/" > Download "Updated_file"</a>"'.".<br />";
echo "<br />";
}
mysql_close($con);
?>
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="open.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="box" value="100000">
<table width="500" border="1">
<tr><td><b><label for='Uname'>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="userfile" /></td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="Submit" name="submit" onClick="return validate();"> <input type="reset" value="Reset" name="reset"> </td></tr>
</table>
</form>
</body>
</html>
open.php
<?php
$con = mysql_connect("localhost","root");
mysql_select_db("connect_db", $con);
$Uname = $_POST['Uname'];
$mail = $_POST['mail'];
error_reporting(0);
$Updated_file = $_POST['Updated_file'];
$target_path = $target_path . basename( $_FILES['Updated_file']['name']);
move_uploaded_file($_FILES['Updated_file']['tmp_name'], $target_path);
$eBanner = basename( $_FILES['Updated_file']['name']);
$query = "INSERT INTO details (Name, Email, Attachements) VALUES ('".$Uname."', '".$mail."', '".$Updated_file."')";
mysql_query($query, $con) or die(mysql_error());
$result = mysql_query("SELECT * FROM details");
while($row = mysql_fetch_array($result))
{
echo "<font color='red'>Name :</font> ".$row['Name'].",<br />";
echo "<font color='blue'>Email :</font>".$row['Email'].",<br />";
echo "<font color='green'>Attachements :</font>".'"<a href="http://localhost/" > Download "Updated_file"</a>"'.".<br />";
echo "<br />";
}
mysql_close($con);
?>