Hi all,
I have a problem I have been trying to work out, wonder if anyone could shed some light?
I have an include file with an unordered list:
I also have a php file with a sendmail form:Code:<ul> <li><a href="quotation_request.php">Turf supplied to order</a></li> <li><a href="quotation_request.php">Lawn preparation and turf laying</a></li> <li><a href="quotation_request.php">Stonewalling</a></li> <li><a href="quotation_request.php">Brick-paved driveways</a></li> <li><a href="quotation_request.php">Hedge laying</a></li> <li><a href="quotation_request.php">Garden planning</a></li> <li><a href="quotation_request.php">Garden sheds and benches</a></li> </ul> </div> <div class="btmritnav"> <ul> <li><a href="quotation_request.php">Timber fences</a></li> <li><a href="quotation_request.php">Rockery creation</a></li> <li><a href="quotation_request.php">Water features and ponds</a></li> <li><a href="quotation_request.php">Raised decking</a></li> <li><a href="quotation_request.php">Grass seeding and plant selections</a></li> <li><a href="quotation_request.php">Garden clearances</a></li> <li><a href="quotation_request.php">Retaining wall systems</a></li> </ul>
What I would like to try and achieve is when the user selects a list item from the included file, I would like the link to go to the php file with the form, and from the option select box, php selects the appropriate option from the list that relates from the list item.Code:<?php // process the email if (array_key_exists('submit', $_POST)) { ini_set("sendmail_from", "info@test.com"); $to = 'john@test.com'; // use your own email address $subject = 'Quotation request from website!'; // list expected fields $expected = array('turfselectbox', 'turfarea', 'radioturf', 'radiodel', 'serviceselectbox', 'name', 'postaddress', 'pcode', 'tel', 'email','notes'); // set required fields $required = array('turfselectbox', 'serviceselectbox', 'name', 'postaddress', 'pcode', 'tel', 'email'); // create empty array for any missing fields $missing = array(); // process the $_POST variables foreach ($_POST as $key => $value) { // assign to temporary variable and strip whitespace if not an array $temp = is_array($value) ? $value : trim($value); // if empty and required, add to $missing array if (empty($temp) && in_array($key, $required)) { array_push($missing, $key); } // otherwise, assign to a variable of the same name as $key elseif (in_array($key, $expected)) { ${$key} = $temp; } } // validate the email address if (!empty($email)) { // regex to ensure no illegal characters in email address $checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/'; // reject the email address if it doesn't match if (!preg_match($checkEmail, $email)) { array_push($missing, 'email'); } } // go ahead only if all required fields OK if (empty($missing)) { // build the message $message = "Selected turf required: $turfselectbox\n\n"; $message .= "Area to apply turf: $turfarea\n\n"; $message .= "Soil required: $radioturf\n\n"; $message .= "Delivery required: $radiodel\n\n"; $message .= "Service required: $serviceselectbox\n\n"; $message .= "Name/Business: $name\n\n"; $message .= "Postal address: $postaddress\n\n"; $message .= "Post code: $pcode\n\n"; $message .= "Telephone no.: $tel\n\n"; $message .= "Email address: $email\n\n"; $message .= "Message: $notes\n\n"; // limit line length to 70 characters $message = wordwrap($message, 200); // send it $sendmail_from = mail($to, $subject, $message); if ($sendmail_from) { // $missing is no longer needed if the email is sent, so unset it unset($missing); } } } ?> <?php if ($_POST && isset($missing)) { ?> <p class="main_warning">Please complete the missing item(s) indicated. Your message has not been sent.</p> <?php } elseif ($_POST && !$sendmail_from) { ?> <p class="main_warning">Sorry, there was a problem sending your message. Please try later.</p> <?php } elseif ($_POST && $sendmail_from) { ?> <span class="confmsg"><h2>Thank you for your quotation request. We will reply to you as soon as possible.</h2></span> <?php } ?> <form id="quoteform" name="contactform" method="post" action=""> <?php if (isset($missing) && in_array('turfselectbox', $missing)) { ?> <span class="warning">Enter turf if required.</span> <?php } ?> <label><abbr title="Select turf required."><font color="#FF0000" size="1"><sup>*</sup></font>Select turf required:</abbr> <select name="turfselectbox" id="turfselectbox" size="1"> <option selected="selected">Please Select</option> <option>Premium turf</option> <option>None</option> </select> </label> <label> <abbr title="Area to apply turf:">Area to apply turf:</abbr> <input type="text" name="turfarea" id="turfarea" maxlength="40"/> M<sup>2</sup> <a href="javascript:popUp('turf_calculator.php')"><img src="img/calculator.jpg" width="16" height="16" title="Turf Calculator" alt="Turf Calculator" /></a></label> <label><abbr title="Do you require soil?">Do you require soil?</abbr></label> <label><input id="radiosoil" name="radioturf" type="radio" value="Yes" checked="checked"></input>Yes</label> <label><input id="radiosoilb" name="radioturf" type="radio" value="No"></input>No</label> <label><abbr title="Do you require delivery?">Do you require delivery?</abbr></label> <label><input id="radiodel" name="radiodel" type="radio" value="Yes" checked="checked"></input>Yes</label> <label><input id="radiodelb" name="radiodel" type="radio" value="No"></input>No</label> <?php if (isset($missing) && in_array('serviceselectbox', $missing)) { ?> <span class="warning">Enter the type of service you require.</span> <?php } ?> <label> <abbr title="What type of service do you require?"><font color="#FF0000" size="1"><sup>*</sup></font>What service do you require?</abbr> //Service select box relates to the ul menu. <select name="serviceselectbox" id="serviceselectbox" size="1"> <option selected="selected">Please select</option> <option>Turf supplied to order</option> <option>Lawn preparation and turf laying</option> <option>Stonewalling</option> <option>Brick-paved driveways</option> <option>Hedge laying</option> <option>Garden planning</option> <option>Garden sheds and benches</option> <option>Timber fences</option> <option>Rockery creation</option> <option>Water features and ponds</option> <option>Raised decking</option> <option>Grass seeding and plant selections</option> <option>Garden clearances</option> <option>Retaining wall systems</option> <option>None</option> </select> </label> <?php if (isset($missing) && in_array('name', $missing)) { ?> <span class="warning">Enter your name.</span> <?php } ?> <label><abbr title="Enter your name."><font color="#FF0000" size="1"><sup>*</sup></font>Name/Business:</abbr> <input type="text" name="name" id="name" maxlength="35" /></label> <?php if (isset($missing) && in_array('postaddress', $missing)) { ?> <span class="warning">Enter your postal address.</span> <?php } ?> <label><abbr title="Enter your postal address."><font color="#FF0000" size="1"><sup>*</sup></font>Postal address:</abbr></label> <label><textarea name="postaddress" id="postaddress" cols="0" rows="7"></textarea></label> <?php if (isset($missing) && in_array('pcode', $missing)) { ?> <span class="warning">Enter your postal code.</span> <?php } ?> <label> <abbr title="Enter your post code."><font color="#FF0000" size="1"><sup>*</sup></font>Post code:</abbr> <input type="text" name="pcode" id="pcode" maxlength="25" /></label> <?php if (isset($missing) && in_array('tel', $missing)) { ?> <span class="warning">Enter your contact telephone no.</span> <?php } ?> <label> <abbr title="Enter your contact telephone no."><font color="#FF0000" size="1"><sup>*</sup></font>Telephone no.:</abbr> <input type="text" name="tel" id="tel" maxlength="25" /></label> <?php if (isset($missing) && in_array('email', $missing)) { ?> <span class="warning">Enter your email address.</span> <?php } ?> <label> <abbr title="Enter your email address."><font color="#FF0000" size="1"><sup>*</sup></font>Email address:</abbr> <input type="text" name="email" id="email" maxlength="25" /></label> <label><abbr title="Enter your message.">Message:</abbr></label> <label><textarea name="notes" id="notes" cols="0" rows="7"></textarea></label> <input type="submit" name="submit" id="submit" class="submit" value="Request Quotation" title="Request Quotation" /> <input type="reset" name="reset" id="reset" class="reset" value="Reset" title="Reset" /> </form>
I hope it makes sense on what I’m trying to do.
Any help or suggestions greatly appreciated.
Many thanks, John.



Reply With Quote
Bookmarks