Page 2 of 2
Re: PHP Form with "Add Item", need help...
Posted: Fri Jul 24, 2009 4:18 pm
by jackpf
You don't need to.
If you put [] on the end of the name of the input, PHP will put it into an array for you.
Re: PHP Form with "Add Item", need help...
Posted: Fri Jul 24, 2009 4:50 pm
by WithHisStripes
Glorious, problem solved. Here's my final code for those who are interested:
Code: Select all
<?php
if (isset($_REQUEST['email'])) {
$customer = $_REQUEST['customer'];
$attention = $_REQUEST['attention'];
$address = $_REQUEST['address'];
$city = $_REQUEST['city'];
$phone = $_REQUEST['phone'];
$fax = $_REQUEST['fax'];
$email = $_REQUEST['email'];
$inches = $_REQUEST['inches'];
$number_of_colors = $_REQUEST['number-of-colors'];
$material = $_REQUEST['material'];
$copy_other_colors = $_REQUEST['copy-other-colors'];
$message = "
Customer Name: " . $customer . "
Attention: " . $attention . "
Address: " . $address . "
City: " . $city . "
Phone: " . $phone . "
Fax: " . $fax . "
Email: " . $email . "
Inches: " . implode(', ', $inches) . "
Number of Colors: " . implode(', ', $number_of_colors) . "
Material: " . implode(', ', $material) . "
Copy/Other Colors: " . implode(', ', $copy_other_colors);
mail( "spencerhill@theportlandco.com", "Someone has requested a quote.", $message, "From: $email" );
echo "<p style='width: inherit;'>Thank you, we'll be in touch with you shortly.</p>";
} else {
?>
<form action="?" name="quote_request_form" method="post">
<table>
<tr>
<td colspan="12"><h1>Customer Information:</h1></td>
</tr>
<tr>
<td style="width: 15px;">*Customer:</td>
<td colspan="4"><input type="text" maxlength="45" name="customer" style="width: 200px; color: #666" value="Clif Overhault" onFocus="clearText(this)" onBlur="clearText(this)" onclick="javascript:getIt(this)" /></td>
</tr>
<tr>
<td style="width: 15px;">Attention</td>
<td colspan="4"><input type="text" maxlength="45" style="width: 200px;" name="attention" /></td>
</tr>
<tr>
<td style="width: 15px;">*Address</td>
<td colspan="4"><input type="text" maxlength="45" name="address" style="width: 200px; color: #666" value="123 Your Street" onFocus="clearText(this)" onBlur="clearText(this)" onclick="javascript:getIt(this)" /></td>
</tr>
<tr>
<td style="width: 15px;">*City</td>
<td colspan="4"><input type="text" maxlength="45" name="city" style="width: 200px;" /></td>
</tr>
<tr>
<td style="width: 15px;">*Phone</td>
<td><input type="text" maxlength="13" id="phone" name="phone" style="width: 200px; color: #666" value="(503)288-5885" onFocus="clearText(this)" onBlur="clearText(this)" onclick="javascript:getIt(this)" /></td>
</tr>
<tr>
<td style="width: 15px;">Fax</td>
<td colspan="4"><input type="text" maxlength="13" name="fax" style="width: 200px; color: #666" value="(503)288-5885" onFocus="clearText(this)" onBlur="clearText(this)" onclick="javascript:getIt(this)" /></td>
</tr>
<tr>
<td style="width: 15px;">*Email</td>
<td colspan="4"><input type="text" maxlength="35" name="email" style="width: 200px; color: #666" value="Us@ProAdCo.com" onFocus="clearText(this)" onBlur="clearText(this)" onclick="javascript:getIt(this)" /></td>
</tr>
</table>
<br />
<br />
<br />
<table>
<tr>
<td style="width: 30px"><h2>Item</h2></td>
<td style="width: 75px"><h2>Size</h2></td>
<td style="width: 210px"><h2>Description &/or Part Name & Part Number </h2></td>
<td style="width: 100px"><h2>Material</h2></td>
<td style="width: 150px"><h2>Copy/Other Colors</h2></td>
</tr>
</table>
<table id="item-information">
<tr>
<td style="width: 30px">1</td>
<td style="width: 75px">
<select name="inches[]">
<option>Inches...</option>
</select>
</td>
<td style="width: 210px">
<select name="number-of-colors[]">
<option>Number of Colors...</option>
</select>
</td>
<td style="width: 100px">
<select name="material[]">
<option>Material...</option>
</select>
</td>
<td style="width: 150px">
<select name="copy-other-colors[]">
<option>Copy/Other Colors...</option>
</select>
</td>
</tr>
</table>
<input type="button" onclick="insRow()" value="Add Item">
<br />
<br />
<br />
<table>
<tr>
<td colspan="12"><h1>Check if applicable:</h1></td>
</tr>
<tr>
<td colspan="2"><input type="checkbox" name="screen-print" value="Screen Print" />
<p>Screen Print</p></td>
<td colspan="2"><input type="checkbox" name="back-scored" value="Back Scored" />
<p>Back Scored</p></td>
<td colspan="2"><input type="checkbox" name="face-scored" value="Face Scored" />
<p>Face Scored</p></td>
<td colspan="2"><input type="checkbox" name="singles" value="Singles" />
<p>Singles</p></td>
<td colspan="2"><input type="checkbox" name="sheet" value="Sheet" />
<p>Sheet</p></td>
<td colspan="2"><input type="checkbox" name="contour" value="Contour" />
<p>Contour</p></td>
</tr>
<tr>
<td colspan="2"><input type="checkbox" name="application-tape" value="Application Tape" />
<p>Application Tape</p></td>
<td colspan="2"><input type="checkbox" name="protect-rite" value="Protec Rite" />
<p>Protec Rite</p></td>
<td colspan="2"><input type="checkbox" name="rounded-corners" value="Rounded Corners" />
<p>Rounded Corners</p></td>
<td colspan="2"><input type="checkbox" name="holes" value="Holes" />
<p>Holes</p></td>
<td colspan="2"><input type="checkbox" name="clear-coat" value="Clear Coat" />
<p>Clear Coat</p></td>
<td colspan="2"><input type="checkbox" name="back-printed" value="Back Printed" />
<p>Back Printed</p></td>
</tr>
<tr>
<td colspan="2"><input type="checkbox" name="laminate" value="Laminate" />
<p>Laminate</p></td>
<td colspan="2"><input type="checkbox" name="adhesive-467" value="Adhesive 467" />
<p>Adhesive 467</p></td>
<td colspan="2"><input type="checkbox" name="adhesive-468" value="Adhesive 468" />
<p>Adhesive 468</p></td>
<td colspan="2"><input type="checkbox" name="polyester-1-mil" value="Polyester 1 Mil" />
<p>Polyester 1 Mil</p></td>
<td colspan="2"><input type="checkbox" name="polyester-2-mil" value="Polyester 2 Mil" />
<p>Polyester 2 Mil</p></td>
<td colspan="2"><input type="checkbox" name="die-cut" value="Die Cut" />
<p>Die Cut</p></td>
</tr>
<tr>
<td colspan="2"><input type="checkbox" name="kiss-cut" value="Kiss Cut" />
<p>Kiss Cut</p></td>
<td colspan="2"><input type="checkbox" name="serial-numbered" value="Serial Numbered" />
<p>Serial Numbered</p></td>
<td colspan="2"><input type="checkbox" name="special-packaging" value="Special Packaging" />
<p>Special Packaging</p></td>
<td colspan="2"><input type="checkbox" name="circle" value="Circle" />
<p>Circle</p></td>
<td colspan="2"><input type="checkbox" name="oval" value="Oval" />
<p>Oval</p></td>
<td colspan="2"><input type="checkbox" name="square-rectangle" value="Square/Rectangle" />
<p>Square/Rectangle</p></td>
</tr>
</table>
<br />
<br />
<table>
<tr>
<td><p>Quantity</p></td>
<td>
<select name="quantity">
<option>1-10</option>
<option>25</option>
<option>50</option>
<option>125</option>
<option>250</option>
<option>500</option>
<option>1000</option>
<option>2500</option>
<option>5000</option>
<option>10,000</option>
<option>Other</option>
</select>
</td>
<td style="padding: 0 25px 0 75px;"><p><b>If you have a file of what you want printed (such as a sketch or graphic) you may upload it here.</b></p></td>
<td><input type="file" value="Upload" /></td>
</tr>
</table>
<br />
<br />
<input type="submit" value="Submit Quote Request" />
<br />
<br />
<br />
<br />
</form>
<?php } ?>
Re: PHP Form with "Add Item", need help...
Posted: Fri Jul 24, 2009 5:17 pm
by jackpf
Cool.