[SOLVED] Submitting a file to another page via a form...
Posted: Fri Jul 09, 2004 1:43 pm
Do you have to do anything special to submit a file to another page?
I have my form on one page, then it submits to another page which checks for errors and such and displays them. It also stores the file on the server if there are no errors.
Problem is, I submit it to the new page and it gives me an error.
My file uploading script was originally written as a self submitting form, but I didn't change anything except the fact it submits to a new page and not itself.
What should I do, here is my code:
This is for the form first page. I will post the second pages code in another post in a second.
I have my form on one page, then it submits to another page which checks for errors and such and displays them. It also stores the file on the server if there are no errors.
Problem is, I submit it to the new page and it gives me an error.
My file uploading script was originally written as a self submitting form, but I didn't change anything except the fact it submits to a new page and not itself.
What should I do, here is my code:
Code: Select all
<?
include("dbconnection/connect_db.inc.php");
session_start();
if ($_SESSION['logged'] == 1){
$query = "SELECT * FROM members where username='".$_SESSION['user']."'";
$mysql_stuffg = mysql_query($query, $mysql_link);
while($roc = mysql_fetch_row($mysql_stuffg)){
$memberID = $roc[0];
}
$query = "SELECT * FROM games where gameID='$gameID'";
$mysql_stuffg = mysql_query($query, $mysql_link);
while($roc = mysql_fetch_row($mysql_stuffg)){
$gameID = $roc[0];
$game_title = $roc[1];
}
$query = "SELECT * FROM misc";
$mysql_stuff = mysql_query($query, $mysql_link);
while($roc = mysql_fetch_row($mysql_stuff)){
$faqsize = $roc[3];
}
print("<html>
<head>
<title>Bolt 3 - FAQs</title>
</head>
<link href="css.php" rel="stylesheet" type="text/css">
<body bgcolor="#DAD6B0" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">"); include('header.php'); print("</td>
</tr>
<tr>
<td>
<div align="center">
<table width="778" class="contenttable" cellpadding="0" cellspacing="0">
<tr>
<td>
<div align="center">
<table width="100%" height="100%" class="contentinside">
<tr>
<td>
<div align="center">
<form action="submit-faqsfinal.php" enctype="multipart/form-data" name="submitcode" method="GET">
<table width="768" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<div align="center">
<table width="598" border="0" cellpadding="0" cellspacing="0">
<tr>
<td border="0"><img src="siteimages/gamefaqstop.jpg"></td>
</tr>
<tr>
<td>
<div align="center">
<table class="regpart1" cellpadding="0" cellspacing="0">
<tr>
<td>
<div align="center">
<table width="596" border="1" cellpadding="0" cellspacing="0" bordercolor="#86846B" bgcolor="#9F9C7E">
<tr>
<td colspan="2"><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif"><b>Submit a FAQ</b></font></div></td>
</tr>
<tr>
<td><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Game Name:</font></div></td>
<td><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">$game_title<input type="hidden" name="gameID" value="$gameID"></font></div></td>
</tr>
<tr>
<td><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">FAQ Title:</font></div></td>
<td><div align="center"><input type="text" name="faq_title" class="form" size="40"></div></td>
</tr>
<tr>
<td><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">What type of FAQ are you submitting: </font></div></td>
<td><div align="center"><select name="faq_type" class="form">
<option value="" selected>Choose a Type</option>");
$query = "SELECT * FROM game_faq_types";
$mysql_stuff = mysql_query($query, $mysql_link);
while($roc = mysql_fetch_row($mysql_stuff)){
$faq_type = $roc[1];
print("<option value="$faq_type" class="dropdownc">$faq_type</option>");
}
print("</select></div></td>
</tr>
<tr>
<td><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">FAQ Version:</font></div></td>
<td><div align="center"><input type="text" name="faq_ver" class="form" size="5"></div></td>
</tr>
<tr>
<td><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Select your FAQ:</font></div></td>
<td><div align="center"><input type="file" name="file" class="form"></div></td>
</tr>
<tr>
<td colspan="2"><div align="center"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Only .TXT files are allowed for FAQs.<br>
The maximum size your FAQ can be is <b>$faqsize</b> bytes.</font></div></td>
</tr>
<tr>
<td><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Submitted By:</font></div></td>
<td><div align="center"><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">$_SESSION[user]<input type="hidden" name="memberID" value="$memberID"></font></div></td>
</tr>
<tr>
<td colspan="2"><div align="center"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">All faqs submitted must be approved before they will appear on the site.<br>
Only submit your faq once.</font></div></td>
</tr>
<tr>
<td colspan="2"><div align="center"><input type="submit" name="Submit" value="Submit FAQ" class="submitbutton"></div></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#6D6B57"><div align="left"><img src="siteimages/tf-left.gif"></div></td>
<td bgcolor="#6D6B57"><div align="right"><img src="siteimages/tf-right.gif"></div></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td>"); include('footer.php'); print("</td>
</tr>
</table>
</body>
</html>");
} elseif (empty($gameID)){
print("<html>
<head>
<title>Bolt 3 - Error</title>
</head>
<body bgcolor="#DAD6B0" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<link href="css.php" rel="stylesheet" type="text/css">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">"); include('header.php'); print("</td>
</tr>
<tr>
<td valign="top">
<div align="center">
<table width="778" class="contenttable" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="100%" height="100%" class="contentinside">
<tr>
<td valign="top">
<div align="center">
<br>
<table class="regpart1" cellpadding="0" cellspacing="0">
<tr>
<td>
<div align="center">
<br>
You did not specify a game.<br>
<br>
</div>
</table>
</div>
<br>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td>"); include('footer.php'); print("</td>
</tr>
</table>
</body>
</html>");
} else {
print("<html>
<head>
<title>Bolt 3 - Error</title>
</head>
<body bgcolor="#DAD6B0" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<link href="css.php" rel="stylesheet" type="text/css">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">"); include('header.php'); print("</td>
</tr>
<tr>
<td valign="top">
<div align="center">
<table width="778" class="contenttable" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="100%" height="100%" class="contentinside">
<tr>
<td valign="top">
<div align="center">
<br>
<table class="regpart1" cellpadding="0" cellspacing="0">
<tr>
<td>
<div align="center">
<br>
Sorry, only registered users of Bolt 3 can contribute.<br>
If you are registered, please login first.<br>
<br>
</div>
</table>
<br>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td>"); include('footer.php'); print("</td>
</tr>
</table>
</body>
</html>");
}
?>