okay, now that i have my upload form, and my user database done,
is it possible for me to have the two of them display after i click the submit button.
ex: select user name > find the file you want to upload, then click submit
result: LOSER <username> selected and file.
Here are my code for it, i just need it to show as i describe, thanks!
Process_upload
upload.php
Display_reps this is where i want it to be displayed,
is it possible for me to have the two of them display after i click the submit button.
ex: select user name > find the file you want to upload, then click submit
result: LOSER <username> selected and file.
Here are my code for it, i just need it to show as i describe, thanks!
Process_upload
PHP Code:
<?php
$db = mysql_connect('localhost', 'dangmnne_dangmnx', 'xxxx'); //fill in host, hostname, hostpass with your own
if (!$db)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('dangmnne_test', $db); //fill in DBname with your own
if (!db_selected)
{
die("cant connect");
}
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"], "/home/dangmnne/public_html/hp/upload/" . $_FILES["file"]["name"]);
$replay = "" . $_FILES["file"]["name"];
$replay2 = "<a href=\"http://www.dangmn.net/hp/upload/" .$replay. "\"><img src = \"http://www.dangmn.net/hp/image.jpg\" style=\"border-style: none\"/></a>"; //replace "yoursite" with your own site
$query = "INSERT INTO test (replay)
VALUES ('".$replay2."')";
$result = mysql_query($query) or die(mysql_error());
mysql_close($db);
}
?>
<p>upload was sucessful click<a href="report.php"> here </a>to return</p>
upload.php
PHP Code:
<html>
<body>
<link rel="stylesheet" type="text/css" href="main.css" />
<?php
$host="localhost"; // Host name
$username="dangmnne_dangmnx"; // Mysql username
$password="xxxx"; // Mysql password
$db_name="dangmnne_test"; // Database name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
?>
<div style="width:450px; height:15px; border:1px solid black; background-color: #535353; color: white; padding: 2px;">
<strong>Loser</strong></div>
<div style="width:444px; height:55px; border-left:1px solid black; border-right:1px solid black; border-bottom:1px solid black; background-color: #C0C0C0; color: #000; padding: 5px;">
<p>Please select the correct opponent.</p><br />
<form>
<select name="members">
<?php
$query = mysql_query("SELECT username FROM members");
while($row = mysql_fetch_array($query))
{
echo "<option>".$row['username']."</option>";
}
?>
</select>
</form>
</div>
<br />
<div style="width:221px; height:15px; border:1px solid black; background-color: #535353; color: white; padding: 2px;">
<strong>Replay</strong></div>
<div style="width:215px; height:85px; border-left:1px solid black; border-right:1px solid black; border-bottom:1px solid black; background-color: #C0C0C0; color: #000; padding: 5px;">
<p>Please select the correct replay.</p><br />
<form action="process_upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="Upload" value="Submit" />
</form>
</div>
</body>
</html>
PHP Code:
<?php
$db = mysql_connect('localhost', 'dangmnne_dangmnx', 'xxxx'); //fill in host, hostname, hostpass with your own
if (!$db)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('dangmnne_test', $db); //fill in DBname with your own
if (!db_selected)
{
die("cant connect");
}
$result = mysql_query("SELECT replay FROM test");
echo "<table ALIGN='center' border='1'>
<tr>
<th><FONT COLOR='#000'>Replay</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td ALIGN='CENTER'><FONT COLOR='#000'>" . $row['replay'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($db);
?>