...

View Full Version : PHP Quote Script Help



DCXtreme
03-24-2007, 12:43 AM
Hi There, I have a question about a script I have written for http://www.dirtydragon.co.uk/customquote.php.

After the user fills selects the activities and times and clicks submit they are taken to a page which lists all the information, including a list of all the activities they have chosen. The script works by looking for the checked tick boxes next to the activity name and if they are ticked that activity is listed, this works on a loop.

However the user is also supposed to get an e-mail confirming the activities, this does not work, the user only gets the first activity picked up by the script. My question is, is there a way of storing the values of selected activities? bear in mind the user can select any number of activities!

Code attached, any help VERY much welcome!


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<title>Your Quote : Dirty Dragon Adventure Company</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="keywords" content="stag, weekends, hen, nights, do, Pembrokeshire, adventure, bcn, Wales, organisers, planners, event organisers, activity, activities karting, outdoor, indoor, paintballing, paintball, quad, biking, mountain, strippers" />
<meta name="description" content="Leading Welsh Stag and Hen weekend specialists for stag do's & stag nights in Wales " />
<meta name="expires" content="never" />
<meta name="distribution" content="Global" />
<meta name="robots" content="INDEX,FOLLOW" />
<meta name="email" content="enquiries@dirtydragon.co.uk" />
<script type="text/javascript" src="js/scripts.js"></script>
<link rel="stylesheet" type="text/css" href="css/styles.css">
<style type="text/css">
<!--
.style1 {font-size: 14px}
-->
</style>
</head>
<body class="default">
<div id="frame">

<div class="logo"><a href="index.php"></a></div>
<div id="header">
<div class="banner"> <br>
<div><a href="index.php"><img src="images/writing.jpg" alt="Call us direct on 01994 453588" width="288" height="48"></a><br>
<a href="customquote.php"><img src="images/instaquote_0.gif" alt="Get a quote now" border="0" ></a><br>
<a href="contact.php"><img src="images/callus_0.gif" alt="Contact us" border="0" ></a> </div>
</div><div class="menu"><a href="adrenaline.php" title="Adrenaline Activities" class="" ><img src="images/nav/actadren_0.gif" border="0" ></a><img src="images/nav/dot.gif"><a href="chilled.php" title="Chillout Activities" class="" ><img src="images/nav/actchill_0.gif" border="0" ></a><img src="images/nav/dot.gif"><a href="nightlife.php" title="Nightlife" class="" ><img src="images/nav/nightlife_0.gif" border="0" ></a><img src="images/nav/dot.gif"><a href="accommodation.php" title="Hotels" class="" ><img src="images/nav/hotels_0.gif" border="0" ></a><img src="images/nav/dot.gif"><a href="testimonials.php" title="Testimonials" class="" ><img src="images/nav/testimonials_0.gif" border="0" ></a><img src="images/nav/dot.gif"><a href="links.php" title="Links" class="" ><img src="images/nav/links_0.gif" border="0" ></a><img src="images/nav/dot.gif"><a href="photos.php" title="Photos" class="" ><img src="images/nav/photos_0.gif" border="0" ></a><img src="images/nav/dot.gif"><a href="index.php" title="Home" class="sel" ><img src="images/nav/home_0.gif" border="0" ></a></div>
</div>
<div id="container"> <div id="panel"><div><img src="images/pages/instaquote.gif" width="350" height="83" class="title">
<div class="title">
<!-- Couldn't find the file : contact_en_quote.txt -->

<P><?php require( "quote.php" ); ?></P>
</div></div><br clear="all"></div> <div id="navbar">
<a href="chilled.php" title="Chillout Activities"><img src="images/inside_top.gif" border="0"><img src="images/inside_chill.gif"></a><img src="images/inside_adren.gif"><a href="adrenaline.php"><img src="images/inside_bot.gif" border="0"></a>
<br clear="all">
</div> <div id="content"><div class="element">






<div class="contactform">
<p>
<?php
//DEFINING CONSTANTS VALUES ********* ADDED 13/01/2007
define("BED_AND_BREAKFAST_PRICE", 25);
define("SELF_CATERING_PRICE", 20);
// GET FORM VALUES ********* ADDED 13/01/2007
//GET THE VALUE FOR THE TEXTBOXES
$fullname = $_POST['fullname'];
$email = $_POST['email'];
$startDate = $_POST['startDate'];
$phoneNo = $_POST['phoneNo'];
$comments = $_POST['comments'];
//GET THE VALUES FOR THE LIST/MENU
$noofnights = 2;
$noofPeople = $_POST['noofPeople'];
$mnu_accommodation = $_POST['mnu_accommodation'];
$publicitySource = $_POST['publicitySource'];
$chkActivity = $_POST['chkActivity'];
//GET AM-PM CHECKBOX VALUES
$a_1_Q = $_POST['a_1_Q'];
$a_2_Q = $_POST['a_2_Q'];
$a_3_Q = $_POST['a_3_Q'];
$a_4_Q = $_POST['a_4_Q'];
$a_5_Q = $_POST['a_5_Q'];
$a_6_Q = $_POST['a_6_Q'];
$a_7_Q = $_POST['a_7_Q'];
$a_8_Q = $_POST['a_8_Q'];
$a_9_Q = $_POST['a_9_Q'];
$a_10_Q = $_POST['a_10_Q'];
$a_11_Q = $_POST['a_11_Q'];
$a_12_Q = $_POST['a_12_Q'];
$a_13_Q = $_POST['a_13_Q'];
$a_14_Q = $_POST['a_14_Q'];
$a_15_Q = $_POST['a_15_Q'];
$a_16_Q = $_POST['a_16_Q'];
$a_17_Q = $_POST['a_17_Q'];
$a_18_Q = $_POST['a_18_Q'];
$a_19_Q = $_POST['a_19_Q'];
$a_20_Q = $_POST['a_20_Q'];
$a_21_Q = $_POST['a_21_Q'];
$a_22_Q = $_POST['a_22_Q'];
$a_23_Q = $_POST['a_23_Q'];
$a_24_Q = $_POST['a_24_Q'];
$a_25_Q = $_POST['a_25_Q'];

$a_1_sun = $_POST['a_1_sun'];
$a_2_sun = $_POST['a_2_sun'];
$a_3_sun = $_POST['a_3_sun'];
$a_4_sun = $_POST['a_4_sun'];
$a_5_sun = $_POST['a_5_sun'];
$a_6_sun = $_POST['a_6_sun'];
$a_7_sun = $_POST['a_7_sun'];
$a_8_sun = $_POST['a_8_sun'];
$a_9_sun = $_POST['a_9_sun'];
$a_10_sun = $_POST['a_10_sun'];
$a_11_sun = $_POST['a_11_sun'];
$a_12_sun = $_POST['a_12_sun'];
$a_13_sun = $_POST['a_13_sun'];
$a_14_sun = $_POST['a_14_sun'];
$a_15_sun = $_POST['a_15_sun'];
$a_16_sun = $_POST['a_16_sun'];
$a_22_sun = $_POST['a_22_sun'];
$a_23_sun = $_POST['a_23_sun'];
$a_24_sun = $_POST['a_24_sun'];
$a_25_sun = $_POST['a_25_sun'];



$a_1_am = $_POST['a_1_am'];
$a_1_pm = $_POST['a_1_pm'];
$a_2_am = $_POST['a_2_am'];
$a_2_pm = $_POST['a_2_pm'];
$a_3_am = $_POST['a_3_am'];
$a_3_pm = $_POST['a_3_pm'];
$a_4_am = $_POST['a_4_am'];
$a_4_pm = $_POST['a_4_pm'];
$a_5_am = $_POST['a_5_am'];
$a_5_pm = $_POST['a_5_pm'];
$a_6_am = $_POST['a_6_am'];
$a_6_pm = $_POST['a_6_pm'];
$a_7_am = $_POST['a_7_am'];
$a_7_pm = $_POST['a_7_pm'];
$a_8_am = $_POST['a_8_am'];
$a_8_pm = $_POST['a_8_pm'];
$a_9_am = $_POST['a_9_am'];
$a_9_pm = $_POST['a_9_pm'];
$a_10_am = $_POST['a_10_am'];
$a_10_pm = $_POST['a_10_pm'];
$a_11_am = $_POST['a_11_am'];
$a_11_pm = $_POST['a_11_pm'];
$a_12_am = $_POST['a_12_am'];
$a_12_pm = $_POST['a_12_pm'];
$a_13_am = $_POST['a_13_am'];
$a_13_pm = $_POST['a_13_pm'];
$a_14_am = $_POST['a_14_am'];
$a_14_pm = $_POST['a_14_pm'];
$a_15_am = $_POST['a_15_am'];
$a_16_pm = $_POST['a_16_pm'];
$a_16_am = $_POST['a_16_am'];
$a_16_pm = $_POST['a_16_pm'];
$a_17_pm = $_POST['a_17_pm'];
$a_18_pm = $_POST['a_18_pm'];


// SET AUOTMATIC, UNIQUE QUOTE GENERATION VARIABLE
$time = time();
$qn = rand(1, 99);
$quote_num = $time . ' ' . $qn;

//CALCULATING ACCOMODATION PRICE ****** ADDED 16/01/2007
switch($mnu_accommodation){
case "Bed & Breakfast":
$accom_name = "Bed & Breakfast";
$accom_price = BED_AND_BREAKFAST_PRICE;
break;
case "Self Catering":
$accom_name = "Self Catering";
$accom_price = SELF_CATERING_PRICE;
break;
case "I have my own accommodation":
$accom_name = "I have my own accommodation";
$accom_price = 0;
break;
}

?>
<p><strong>Quote reference:</span></strong> <?php echo $quote_num; ?></p>
<hr>
<p><span class="style1"><strong>Details:</strong></span> </span><br>
<br>
<strong>Name:</strong></span> <?php echo $fullname; ?><br>
<strong>Email:</strong></span> <?php echo $email; ?><br>
<strong>Telephone:</span></strong> <?php echo $phoneNo; ?><br>
</p>

<p><?php
//IF HAS IS OWN ACCOMODATION, HIDE THE ACCOMODATION INFORMATION
if($mnu_accommodation == "I have my own accommodation"){

$rooms = round($noofPeople / 2);
$accomcost = 0;
$accomcost_and_room = 0;
echo $mnu_accommodation;
}
else{
echo "Your group consist of <span class='style4'><b>$noofPeople</span> people</b> arriving on <span class='style4'><b>$startDate</b></span> staying for <span class='style4'><b>$noofnights</span> night(s)</b><br><hr>
<br>
<p class='style1'><b>Accommodation:</b></span><br></p>
<p>";
$rooms = round($noofPeople / 2);
$accomcost = ($accom_price*$noofPeople)*$noofnights;
echo "<span class='style4'>$noofPeople</span> people staying for <span class='style4'>$noofnights</span> night(s)<br>
Type of accomodation: <span class='style4'>$accom_name</span>";
}
?>
</p>
<hr>
<p class="style1"><strong>Your Activities:</strong></p>
<p>Please find your activities below in order, the first 3 activities will take place on Saturday Morning, Saturday Afternoon and finally Sunday Morning <br>
<br>

<?php
// SET ACTIVITIES VALUES ********** ADDED 13/10/2007
//LOOP IN TO THE ACTIVITY CHECKBOX ARRAY
while (list ($key,$val) = @each ($chkActivity)) {
//CHECK IN THE LOOP FOR THE NAME OF THE ACTIVITY
switch($val){
//IF THE NAME MATCH, APPLY THIS VALUES FOR THAT ACTIVITY
case "Coasteering":
$activity_name = "Coasteering";
$activity_price = 40.00;
$activity_peopleNum = $a_1_Q;//VALUES FROM LIST/MENU
$time_activity_am = $a_1_am;//VALUES FROM AM-PM CHECKBOXES
$time_activity_pm = $a_1_pm;
$time_activity_sun = $a_1_sun;
break;
case "Gorge Walking":
$activity_name = "Gorge Walking";
$activity_price = 40.00;
$activity_peopleNum = $a_2_Q;
$time_activity_am = $a_2_am;
$time_activity_pm = $a_2_pm;
$time_activity_sun = $a_2_sun;
break;
case "High Ropes & Zip Line":
$activity_name = "High Ropes & Zip Line";
$activity_name2 = "High Ropes & Zip Line";
$activity_name3 = "High Ropes & Zip Line";
$activity_price = 30.00;
$activity_peopleNum = $a_3_Q;
$time_activity_am = $a_3_am;
$time_activity_pm = $a_3_pm;
$time_activity_sun = $a_3_sun;
break;
case "High Ropes & Quary Abseil":
$activity_name = "High Ropes & Quary Abseil";
$activity_price = 30.00;
$activity_peopleNum = $a_4_Q;
$time_activity_am = $a_4_am;
$time_activity_pm = $a_4_pm;
$time_activity_sun = $a_4_sun;
break;
case "Sumo Wrestling & Assault Course":
$activity_name = "Sumo Wrestling & Assault Course";
$activity_price = 30.00;
$activity_peopleNum = $a_5_Q;
$time_activity_am = $a_5_am;
$time_activity_pm = $a_5_pm;
$time_activity_sun = $a_5_sun;
break;
case "Sumo Wrestling & Archery":
$activity_name = "Sumo Wrestling & Archery";
$activity_price = 30.00;
$activity_peopleNum = $a_6_Q;
$time_activity_am = $a_6_am;
$time_activity_pm = $a_6_pm;
$time_activity_sun = $a_6_sun;
break;
case "Assault Course & Archery":
$activity_name = "Assault Course & Archery";
$activity_price = 30.00;
$activity_peopleNum = $a_7_Q;
$time_activity_am = $a_7_am;
$time_activity_pm = $a_7_pm;
$time_activity_sun = $a_7_sun;
break;
case "Mountain Biking":
$activity_name = "Mountain Biking";
$activity_price = 30.00;
$activity_peopleNum = $a_8_Q;
$time_activity_am = $a_8_am;
$time_activity_pm = $a_8_pm;
$time_activity_sun = $a_8_sun;
break;
case "Surf Skiing & Archery":
$activity_name = "Surf Skiing & Archery";
$activity_price = 30.00;
$activity_peopleNum = $a_9_Q;
$time_activity_am = $a_9_am;
$time_activity_pm = $a_9_pm;
$time_activity_sun = $a_9_sun;
break;
case "Surf Skiing & Assault Course":
$activity_name = "Surf Skiing & Assault Course";
$activity_price = 30.00;
$activity_peopleNum = $a_10_Q;
$time_activity_am = $a_10_am;
$time_activity_pm = $a_10_pm;
$time_activity_sun = $a_10_sun;
break;
case "Quad Biking":
$activity_name = "Quad Biking";
$activity_price = 30.00;
$activity_peopleNum = $a_11_Q;
$time_activity_am = $a_11_am;
$time_activity_pm = $a_11_pm;
$time_activity_sun = $a_11_sun;
break;
case "Go Karting":
$activity_name = "Go Karting";
$activity_price = 30.00;
$activity_peopleNum = $a_12_Q;
$time_activity_am = $a_12_am;
$time_activity_pm = $a_12_pm;
$time_activity_sun = $a_12_sun;
break;
case "Paint Balling":
$activity_name = "Paint Balling";
$activity_price = 25.00;
$activity_peopleNum = $a_13_Q;
$time_activity_am = $a_13_am;
$time_activity_pm = $a_13_pm;
$time_activity_sun = $a_13_sun;
break;
case "Clay Pigeon Shooting":
$activity_name = "Clay Pigeon Shooting";
$activity_price = 35.00;
$activity_peopleNum = $a_14_Q;
$time_activity_am = $a_14_am;
$time_activity_pm = $a_14_pm;
$time_activity_sun = $a_14_sun;
break;
case "Surfing":
$activity_name = "Surfing";
$activity_price = 30.00;
$activity_peopleNum = $a_15_Q;
$time_activity_am = $a_15_am;
$time_activity_pm = $a_15_pm;
$time_activity_sun = $a_15_sun;
break;
case "Health Spa":
$activity_name = "Health Spa";
$activity_price = 30.00;
$activity_peopleNum = $a_16_Q;
$time_activity_am = $a_16_am;
$time_activity_pm = $a_16_pm;
$time_activity_sun = $a_16_sun;
break;
case "Karaoke in Local Pub (Fri Night)":
$activity_name = "Karaoke in Local Pub (Friday Night)";
$activity_price = 00.00;
$activity_peopleNum = $a_17_Q;

$time_activity_pm = $a_17_pm;
break;
case "Minibus to Tenby (Sat Night)":
$activity_name = "Minibus to Tenby (Saturday Night)";
$activity_price = 10.00;
$activity_peopleNum = $a_18_Q;

$time_activity_pm = $a_18_pm;
break;

case "Stripper":
$activity_name = "Stripper (Friday Night)";
$activity_price = 200.00;
$activity_peopleNum = $a_19_Q;
$time_activity_am = $a_19_am;

break;

case "Stag & Hen Meal":
$activity_name = "Stag & Hen Meal (Saturday Night";
$activity_price = 20.00;
$activity_peopleNum = $a_20_Q;
$time_activity_am = $a_20_am;

break;

case "Pub Tour":
$activity_name = "Pub Tour (Saturday Night)";
$activity_price = 20.00;
$activity_peopleNum = $a_21_Q;
$time_activity_am = $a_21_am;

break;

case "Golf":
$activity_name = "Golf";
$activity_price = 35.00;
$activity_peopleNum = $a_22_Q;
$time_activity_am = $a_22_am;
$time_activity_pm = $a_22_pm;
$time_activity_sun = $a_22_sun;
break;

case "Horse Riding":
$activity_name = "Horse Riding";
$activity_price = 25.00;
$activity_peopleNum = $a_23_Q;
$time_activity_am = $a_23_am;
$time_activity_pm = $a_23_pm;
$time_activity_sun = $a_23_sun;
break;

case "Fly Fishing":
$activity_name = "Fly Fishing";
$activity_price = 35.00;
$activity_peopleNum = $a_24_Q;
$time_activity_am = $a_24_am;
$time_activity_pm = $a_24_pm;
$time_activity_sun = $a_24_sun;
break;

case "Mountain Walk":
$activity_name = "Mountain Walk";
$activity_price = 20.00;
$activity_peopleNum = $a_25_Q;
$time_activity_am = $a_25_am;
$time_activity_pm = $a_25_pm;
$time_activity_sun = $a_25_sun;
break;

default:
$activity_name = "None";
$activity_price = 0;
break;
}
//PRICE THE ACTIVITY X NUMBER OF PERSON
$activities_totalprice =+ $activity_price*$activity_peopleNum;
//TOTAL COST OF ALL THE ACTIVITIES
$all_activities_total +=$activities_totalprice;
//CALCULATING PRICES ****** ADDED 13/10/2007
$price_per_person = ($accomcost + $all_activities_total) / $noofPeople;
//TOTAL VACATION COST
$vacation_cost = $accomcost + $all_activities_total;

echo "<span class='style10'><b>$activity_name</b></span> <br>For $activity_peopleNum people<br/>" ;} ?>
</p>
<hr>
<p><span class="contactform style1"><strong>Total cost of your adventure weekend:</strong></span><br>
The total cost of your adventure weekend will be: <?php echo "<span class='style4'>&pound;" . number_format($vacation_cost,2)."</span>";?>
<br>
<br>
That works out at <strong><?php echo "<span class='style4'>&pound;" . number_format($price_per_person,2)."</span>"; ?> per perso</strong><span class='style12'><strong>n</strong></span>, assuming every one is taking part in the same activities.
</p>
<p>A copy of this quote has been e-mailed to the e-mail address you specified, if you wish to call us regarding this quote please have the quote reference ready so we can bring up your details. </p>
</div>

</div>
<div class="cbr"><div></div>
</div>
<br clear="all"></div>
<br clear="all"></div><!-- end container -->
<div class="end"><br clear="all"></div>

</div>
<div id="footer">
<p align="center">Content Copyright 2007, Dirty Dragon. Design by <a href="http://design.jmrcomputers.co.uk" target="_blank">JMR Design</a></p>
</p>
</div>
<?php
$body ="========================\nRequest Quotation\n========================\n
Here is a copy of your quotation, as requested, from DirtyDragon.co.uk. If you would like to follow up on this quotation then give us an e-mail: Enquiries@DirtyDragon.co.uk, or call 01994 453610.\n\n
Name: $fullname\n
=========================================\n
E-mail address: $email\n
=========================================\n
Phone Number: $phoneNo\n
=========================================\n
Weekend start date: $startDate (For 2 Nights)\n
=========================================\n
Activities: $activity_name For $activity_peopleNum people\n
=========================================\n
Accommodation Price (Per Person): $accomcost ($accom_price Per Person)\n
=========================================\n
Total Cost: $vacation_cost ($price_per_person Per Person)\n
=========================================\n
Comments: $comments\n
=========================================";
$subject = $quote_num;
$to = $email; // <<--FOR TESTING PURPOSE -- CHANGE WITH CUSTOMER EMAIL ADDRESS
mail($to, $subject, $body, "From: quotes@dirtydragon.co.uk", "-froot@dirtydragon.co.uk");
?>

<?php
$body ="========================\nRequest Quotation\n========================\n
You have recieved a new quotation from a potential customer, below you will be able to see their details so that you may get in touch with them to take the enquiry further.\n\n
Name: $fullname\n
=========================================\n
E-mail address: $email\n
=========================================\n
Phone Number: $phoneNo\n
=========================================\n
How Did They Hear About You?: $publicitySource\n
=========================================\n
Weekend start date: $startDate (For 2 Nights)\n
=========================================\n
Activities: $activity_name For $activity_peopleNum people\n
=========================================\n
Accommodation Price (Per Person): $accomcost ($accom_price Per Person)\n
=========================================\n
Total Cost: $vacation_cost ($price_per_person Per Person)\n
=========================================\n
Comments: $comments\n
=========================================";
$subject = $quote_num;
$to = 'quotes@dirtydragon.co.uk';
mail($to, $subject, $body, "From: quotes@dirtydragon.co.uk", "-froot@dirtydragon.co.uk");
?>

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-1386248-1";
urchinTracker();
</script>
</body>
</html>

iLLin
03-24-2007, 05:13 AM
Some small suggestions. Move all your activities to the database and create a function to output your check boxes. Setup and Planning makes things so much easier and a lot less code. I know your looking for an answer to your issue but your code is just way to bulky.

iLLin
03-24-2007, 05:25 AM
I would also run a loop and all your checkboxes. From what you have I would do something like this:



for($i = 1; $i >= 25; $i++) {
$activity[$i] = array("Q" => $_POST['a_'.$i.'_Q'], "sun" => $_POST['a_'.$i.'_sun'], "am" => $_POST['a_'.$i.'_am'], "pm" => $_POST['a_'.$i.'_pm']);
}



And then you can just call them up like this echo $activity['2']['Q'];

Cut down on alot of code. Just some thoughts to get you started :)

DCXtreme
03-24-2007, 10:52 AM
There is no way I can just duplicate a loop into my e-mail script at the end of the page to mirror how the activities are displayed on the website?

I have done this site as a favour for a friend and I simply dont have the time to move all the information into a database or re-code huge parts of it :(



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum