...

View Full Version : PHP forms are nuts....



stephmck990
03-20-2009, 04:14 PM
I am having the worst time with these PHP forms. >.<

So, I got the majority of the code working really well, until my client decides to throw a curve ball my way and wants to add a field for the customer's order number.

I have the code to add the last name into the file name once it's uploaded to the server, but now I need to slap the order number into there as well.

HTML:

<p align="center"><img src="file:///Y|/LOGO/logo-custom%20camera%20collection%20small2a.jpg" alt="CustomCameraCollection" width="576" height="82"></p>
<table width="50%" height="121" border="3" align="center" cellpadding="5" cellspacing="0" bordercolor="#ccefef">
<tr>
<td height="119" bgcolor="#EAF4F4">
<form name="onephotoupload" enctype="multipart/form-data" method="post" action="http://customcameracollection.net/customerphotos/upload_file.php" onsubmit="return validate_form(this)">
<div align="center"> <font size="2" face="Verdana, Arial, Helvetica, sans-serif">

<table width="100%" border="0">
<tr>
<td align="left"> <div align="left"><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
</font>
<p><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<label><font size="1"><strong><font size="2" face="Tahoma, sans-serif">Please
enter your order number</font></strong><font size="2" face="Tahoma, sans-serif">:</font></font></label>
<br />
<input name="ordernumber" type="text" id="ordernumber" size="8" maxlength="6">
<strong><font color="#FF0000" size="1" face="Tahoma, sans-serif">*
Required</font></strong> </font><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<label> </label>
</font></p>
<p>
<label><font color="#003366" size="2" face="Tahoma, sans-serif">
<strong>Please enter the name the order was placed under,
last name first, separated by an underscore.</strong></font><font size="2" face="Tahoma, sans-serif">
<font color="#003366">(ex. Smith_John):</font></font></label>
<br />
<input name="lastname" type="text" id="lastname" size="25">
<strong><font color="#FF0000" size="1" face="Tahoma, sans-serif">*
Required</font></strong> <br /><br />
<font size="1"><strong><font color="#003366" size="2" face="Tahoma, sans-serif">Upload
photo using the box below.</font></strong></font><br />
<input name="uploadedfile" type="file" id="uploadedfile" size="25">
</div></td>
</tr>
<tr>
<td align="right"> <div align="center"><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<input type="submit" name="submit" value="Upload Photo" />
</font> <font color="#003366">&nbsp;</font></div></td>
</tr>
</table>
</font></div>
</form></td>
</tr>
</table>


PHP:

<?php

$target_path = "uploads/";

$target_path = $target_path . rawurlencode( $_POST['ordernumber']['lastname']);

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded.";
} else{
echo "There was an error uploading the file. You can email us your photo as an attachment at cameras@customcameracollection.com.";
}
?>

What I've got going on is not working. Forgive me if I've completely butchered the PHP in the process. :o

Also, if there's any way to put some code in the there to be able to easily separate the order number, name, and file name with an underscore? Greatly appreciated.

TIA. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum