Posting a Thank You and Confirmation

Hello,

I recently took over development for a non-profit organization that has had some PHP programming in place for a couple of years. I’m pretty positive the developer prior to me spliced a number of code snippets together to create the DB management tools and form elements. In trying to help them clean it up I am running in to a recurring error where after a client posts their information to be collected by the DB there is a message that displays telling them that the reservation has been received and asks if they would like to make another. This message only displays after I refresh the page. When I submit a test entry all I get is a blank page and then once I refresh the message then displays.
This is the code I am working with -
[php]} elseif ($_GET[‘confirm’] == “yes”){
if ($indb != “0”){
echo “<div style=“font-size:14px;”>Your reservation is confirmed.

<a href=“reservations.php?tab=1”>Make another one?”;
}else{
$sql=“INSERT INTO pf_reservations (id, email, date, month, day, year, tour_1, tour_2, tour_3, tour_4, organization, contact_name, contact_number, grade, students, teachers, parents, lunch, toppings, note, payment) VALUES (null, '”.$_SESSION[email]."’, ‘".$_SESSION[ds]."’, ‘".$_SESSION[month]."’, ‘".$_SESSION[day]."’, ‘".$_SESSION[year]."’, ‘".$_SESSION[tour1]."’, ‘".$_SESSION[tour2]."’, ‘".$_SESSION[tour3]."’, ‘".$_SESSION[tour4]."’, ‘".$_SESSION[organization]."’, ‘".$_SESSION[name]."’, ‘".$_SESSION[phone]."’, ‘".$_SESSION[grade]."’, ‘".$_SESSION[students]."’, ‘".$_SESSION[teachers]."’, ‘".$_SESSION[parents]."’, ‘".$_SESSION[lunch]."’, ‘".$_SESSION[toppings]."’, ‘".$_POST[note]."’, null)";

	$result=mysql_query($sql) or die('Error, query failed. ' . mysql_error());

if($_SESSION[‘id’] != “”){[/php]

Notice the echo statement is what creates the thank you.

In turn, after submission the client is supposed to receive an email including their itinerary for their visit and the admin responsible for overseeing these visits should receive a mail as well. Here is the mail code I am currently working with -
[php]$subject = “Pizza Farm Reservation Info”;
$message = "
Dear $_SESSION[name],


Thanks for scheduling a Pizza Farm tour at Harvest Farm!

Date of reservation: $emaildate

Time: $ctour

Group size: $total_num

Your Tour Itinerary:

$itin


Upon your arrival at Harvest Farm, please check in at the front office. We will accept payment at that time.


See you soon!


Sincerely,


Harvest Farm

<img src=“http://www.harvestfarm.net/pizza_farm/images/emaillogo.jpg”>

<a href=“http://www.harvestfarm.net”>www.harvestfarm.net | <a href=“http://www.harvestfarm.net/pizza_farm/reservations.php?echeck=$_SESSION[email]&tab=2”>View Reservation";

mail( “$_SESSION[email]”, “$subject”, “$message”, “From: [email protected]\n” . “MIME-Version: 1.0\n” . “Content-type: text/html; charset=iso-8859-1”);

$subject2= “Pizza Farm Reservation”;
$message2= "
Date of reservation: $emaildate

Time: $ctour

Group size: $total_num

Your Tour Itinerary:

$itin

$_SESSION[organization];

$_SESSION[name];
$_SESSION[phone];

$_SESSION[email];

$_SESSION[grade];

$_SESSION[students];

$_POST[note];
";

mail( "[email protected]", "$subject2", "$message2", "From: $_SESSION[email]\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1");

echo "
<div style=“font-size:14px;”>Your reservation has been confirmed and an email with the details of your reservation has been sent to you (it may be in the Bulk folder of your email account).

See you soon!



View Guidelines | View Reservations "; } }[/php]

I appreciate any and all help, this is the best PHP forum I have been a part of.

off hand, i’d say that it probably has something to do with $indb, or where the processing script is. For messages to appear, the php needs to be above the asking variable. I can only assume that they’re on different pages, given that most of the sql fields are filled in from sessions. I’m not sure why your confirmation message is above the sql insert though, because it’ll confirm that the reservation is there even if the query fails, leaving the potential client in a bind when they get to the event.

I would just look at redoing the code from scratch. I can tell you from personal experience that its not easy to clean up other’s code, specially when its not their own. Its incredibly hard to adapt code to fix your needs. So unless there’s a real need to take on this project, i’d just leave it alone. Why fix what’s not broken?

Thank you for your help and feedback. I will try to re-work what’s there before starting completely from scratch. I t is one of those instances where too many people have had their hands in it and they’re unwilling to budget for a complete redesign, even though a proposal has been submitted. Thank you for you time!

Glad to help. That kind of thing can get pretty expensive really fast. For that kind of thing, i’d charge at leat $5,000. Maybe less depending on how many pages and how much it would be. Just saying…

If you need any more help, feel free to post more questions, i’ll be here.

Thanks for the response, that will help in my future with this client if they choose to continue with me as a web manager/developer. I do have another question. In the midst of all that mumbo jumbo up there I originally posted there was a mail function in there that isn’t being triggered and I wondered if you could see what could be limiting it to sending. I feel like it’s stuck somewhere in the midst of transferring information from one place to another and not being processed. Also, since their server is running on PLESK would I need to check their PHP config file to see if they have limitations on mail being send?

Thanks again!

[php]

Attach note to reservation?  (Please notify us if any attendees will need special accommodations)
<?php } elseif ($_GET['confirm'] == "yes"){ $sql="INSERT INTO pf_reservations (id, email, date, month, day, year, tour_1, tour_2, tour_3, tour_4, organization, contact_name, contact_number, grade, students, teachers, parents, lunch, toppings, note, payment) VALUES (null, '".$_SESSION[email]."', '".$_SESSION[ds]."', '".$_SESSION[month]."', '". $_SESSION[day]."', '".$_SESSION[year]."', '".$_SESSION[tour1]."', '".$_SESSION[tour2]."', '".$_SESSION[tour3]."', '".$_SESSION[tour4]."', '".$_SESSION[ organization]."', '".$_SESSION[name]."', '".$_SESSION[phone]."', '".$_SESSION[grade]."', '".$_SESSION[students]."', '".$_SESSION[teachers]."', '".$_SESSION [parents]."', '".$_SESSION[lunch]."', '".$_SESSION[toppings]."', '".$_POST[note]."', null)"; $result=mysql_query($sql) or die('Error, query failed. ' . mysql_error()); if($_SESSION['id'] != ""){ $sql2="UPDATE pf_reservations SET tour_1 = '".$_SESSION[tour1]."', tour_2 = '".$_SESSION[tour2]."', tour_3 = '".$_SESSION[tour3]."', tour_4 = '". $_SESSION[tour4]."' WHERE id = '".$_SESSION[id]."'"; $result2=mysql_query($sql2) or die('Error, query failed. ' . mysql_error()); } $snum = $_SESSION['students']; $pnum = $_SESSION['parents']; $tnum = $_SESSION['teachers']; $total_num = $snum + $tnum + $pnum; echo "
Your reservation has been confirmed! Currently our email service is being worked on to optimize performance and to make your experience with us as fluid as possible. You can view the details of your reservation at the View Reservations link below.

See you soon!

View Guidelines | View Reservations | Make A New Reservation
"; $tour = "$_SESSION[tour1].$_SESSION[tour2].$_SESSION[tour3].$_SESSION[tour4]"; $emaildate = date("l, F j",$_SESSION['ds']); include "includes/tour_times.php"; include "includes/itineraries.php"; $subject = "Pizza Farm Reservation Info"; $message = "TEST"; mail("$_SESSION[email]", "$subject", "$message", "From: [email protected]\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1"); } else { [/php] and so on and so forth...
Sponsor our Newsletter | Privacy Policy | Terms of Service