...

View Full Version : Form with upload problem



blackwolf
02-13-2009, 06:52 PM
I have an upload form (http://www.blackwolf-graphics.co.uk/test.html) thats works great with my php script. When I add other fields such as customers name, email address etc, it doesn't work. Is there a script that "post" both text fields and upload together.

php Script

<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;

//This is our size condition
if ($uploaded_size > 350000)
{
echo "Your file is too large.<br>";
$ok=0;
}

//This is our limit file type condition
if ($uploaded_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}

//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}

//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file, please try again.";
}
}
?>

Form

<form method='post' action='http://blackwolf-graphics.co.uk/cgi-bin/FormMail.pl'>
<input type='hidden' name='recipient' value='support@blackwolf-graphics.co.uk'>
<input type='hidden' name='subject' value='E-form - Returns'>
<input type='hidden' name='redirect' value='http://blackwolf-graphics.co.uk/thankyou.html'>
<table cellpadding="2" cellspacing="0" border="0" bgcolor="#000000">
<tr>
<td>
<font face="Verdana" size="2" color="#9bd2f1"></font>
<div style="" id="mainmsg"> </div>

</td>
</tr>
</table>

<br>

<table cellpadding="2" cellspacing="0" border="0" bgcolor="#000000">

<tr valign="top">
<td nowrap><font face="Verdana" size="2" color="#9bd2f1">First Name / Last Name</font></td>
<td>
<input type="text" name="name" value="" maxlength="100" size="30"> </td>
</tr>

<tr valign="top">
<td nowrap><font face="Verdana" size="2" color="#9bd2f1">Your Email Address</font></td>
<td>
<input type="text" name="email" value="" maxlength="100" size="30"> </td>
</tr>

<tr valign="top">
<td nowrap><font face="Verdana" size="2" color="#9bd2f1">House Name / Number</font></td>
<td>
<input type="text" name="house number" value="" maxlength="100" size="20"> </td>
</tr>

<tr valign="top">
<td nowrap><font face="Verdana" size="2" color="#9bd2f1">Postal Code</font></td>
<td>
<input type="text" name="post code" value="" maxlength="100" size="7"> </td>
</tr>

<tr valign="top">
<td nowrap><font face="Verdana" size="2" color="#9bd2f1">Date Purchased (DD/MM/YY)</font></td>
<td>
<input type="text" name="date purchased" value="" maxlength="100" size="8"> </td>
</tr>

<tr valign="top">
<td nowrap><font face="Verdana" size="2" color="#9bd2f1">Paypal Transaction No</font></td>
<td>
<input type="text" name="paypal transaction no" value="" maxlength="100" size="20"> </td>
</tr>

<tr valign="top">
<td nowrap><font face="Verdana" size="2" color="#9bd2f1">No of items returning</font></td>
<td>
<select name="items"><option value="01">01</option><option value="02">02</option><option value="03">03</option><option value="04">04</option><option value="05">05</option><option value="06">06</option><option value="07">07</option><option value="08">08</option><option value="09">09</option><option value="10">10</option><option value="11+">11+</option></select> </td>
</tr>

<tr valign="top">
<td nowrap><font face="Verdana" size="2" color="#9bd2f1">Item Description</font></td>
<td>
<textarea name="description" cols="60" rows="10"></textarea><br> </td>
</tr>

<tr valign="top">
<td nowrap><font face="Verdana" size="2" color="#9bd2f1">What is required?</font></td>
<td>
<input type=radio name="What is Required" value="Refund (less postage and any ebay fees)" id="radio80"><font face="Verdana" size="2" color="#9bd2f1"><label for="radio80">Refund (less postage and any ebay fees)</label></font><br><input type=radio name="What is Required" value="Replacement item" id="radio81"><font face="Verdana" size="2" color="#9bd2f1"><label for="radio81">Replacement item</label></font><br> </td>
</tr>

<tr valign="top">
<td nowrap><font face="Verdana" size="2" color="#9bd2f1">Damaged Item? Any pictures?</font></td>
<td>
<input type="file" name="attachment" value="" size="60"> </td>
</tr>

<tr valign="top">
<td nowrap><font face="Verdana" size="2" color="#9bd2f1">Message to BWG</font></td>
<td>
<textarea name="message" cols="60" rows="10"></textarea><br> <div style="position: absolute; left: 1800px; top: 20px;"></div></td>
</tr>
<tr>
<td align="left">
<input type="text" name="hida2" value="" maxlength="100" size="3" style="display : none;">
<input type="submit" class="btn" value="Submit Form" name="Submit"> <input type="reset" class="btn" value=" Reset Form " name="Clear"></td>
</tr>
<tr>
<td colspan=2 align="center">
<br>
</td>
</tr>
</table>

</form>

Pepe, the bull
02-13-2009, 11:37 PM
That sounds like a question for the PHP forum.

abduraooft
02-14-2009, 09:02 AM
When I add other fields such as customers name, email address etc, it doesn't work. Is there a script that "post" both text fields and upload together.


That sounds like a question for the PHP forum. ... though the issue might be due to the errors in your markup (http://validator.w3.org/check?uri=http%3A%2F%2Fwww.blackwolf-graphics.co.uk%2Ftest.html&charset=%28detect+automatically%29&doctype=Inline&group=0).

PS: Never use tables to layout your form, think about accessible forms (http://www.alistapart.com/articles/prettyaccessibleforms).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum