Problem with PHP script?

  • remon479
  • Novice
  • Novice
  • remon479
  • Posts: 19

Post 3+ Months Ago

Hi all,

I have been trying to implement a booking reservation form for a restaurant business. I receive booking confirmations via email just fine, however, after pressing the submit button in the booking form, a blank page opens in a new window and it says 'undefined' at the top corner of the webpage.

My guess is the script is not executing properly and it's getting blocked somewhere :|

I don't have privileges to post URLs on ozzu, otherwise it would have been a lot easier to demonstrate the problem

Reservation form:
Code: [ Select ]
<form action="sendeail.php" method="POST">
       <p><label>Name </label>
              <input type="text" name="visitor" value="" /></p>
        <p><label>Email </label>
        <input type="text" name="visitormail" value="" /></p>
        <p><label>Contact Number</label>
        <input type="text" name="number" value="" /></p>
 <p><label>Booking Date</label>
        <input type="text" name="date" value="" placeholder="D D.M M.YYYY" /></p>       
        
         
          <p>
         
          <label>Booking Time</label> <select name="time">
          <option value="">--Please Select--</option>
          <option value="" disabled="disabled">--Afternoon--</option>
          <option value="12:00">12:00pm</option>
          <option value="12:30">12:30pm</option>
          <option value="13:00">1:00pm</option>
          <option value="13:30">1:30pm</option>         
          <option disabled="disabled">&nbsp;</option>

          <option disabled="disabled">--Evening--</option>
          <option value="18:00">06:00pm</option>
          <option value="18:30">06:30pm</option>
          <option value="19:00">07:00pm</option>
          <option value="19:30">07:30pm</option>
          <option value="20:00">08:00pm</option>

          <option value="20:30">08:30pm</option>
          <option value="21:00">09:00pm</option>
          <option value="21:30">09:30pm</option>
          <option value="22:00">10:00pm</option>
          <option value="22:30">10:30pm</option>
          </select> </p>
        
                <p><label>No. Of People</label>
            
          <select name="people">
                <option value="">--Please Select--</option>
                 <option value="1">1</option>
                 <option value="2">2</option>
                 <option value="3">3</option>
                 <option value="4">4</option>
                  <option value="5">5</option>
              <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
              <option value="10+">10+</option>
         </select></p>
        
        <p><label>Special Instructions</label><textarea name="notes"></textarea></p>
      
<input type="submit" value="Submit" />      
     </form>
  1. <form action="sendeail.php" method="POST">
  2.        <p><label>Name </label>
  3.               <input type="text" name="visitor" value="" /></p>
  4.         <p><label>Email </label>
  5.         <input type="text" name="visitormail" value="" /></p>
  6.         <p><label>Contact Number</label>
  7.         <input type="text" name="number" value="" /></p>
  8.  <p><label>Booking Date</label>
  9.         <input type="text" name="date" value="" placeholder="D D.M M.YYYY" /></p>       
  10.         
  11.          
  12.           <p>
  13.          
  14.           <label>Booking Time</label> <select name="time">
  15.           <option value="">--Please Select--</option>
  16.           <option value="" disabled="disabled">--Afternoon--</option>
  17.           <option value="12:00">12:00pm</option>
  18.           <option value="12:30">12:30pm</option>
  19.           <option value="13:00">1:00pm</option>
  20.           <option value="13:30">1:30pm</option>         
  21.           <option disabled="disabled">&nbsp;</option>
  22.           <option disabled="disabled">--Evening--</option>
  23.           <option value="18:00">06:00pm</option>
  24.           <option value="18:30">06:30pm</option>
  25.           <option value="19:00">07:00pm</option>
  26.           <option value="19:30">07:30pm</option>
  27.           <option value="20:00">08:00pm</option>
  28.           <option value="20:30">08:30pm</option>
  29.           <option value="21:00">09:00pm</option>
  30.           <option value="21:30">09:30pm</option>
  31.           <option value="22:00">10:00pm</option>
  32.           <option value="22:30">10:30pm</option>
  33.           </select> </p>
  34.         
  35.                 <p><label>No. Of People</label>
  36.             
  37.           <select name="people">
  38.                 <option value="">--Please Select--</option>
  39.                  <option value="1">1</option>
  40.                  <option value="2">2</option>
  41.                  <option value="3">3</option>
  42.                  <option value="4">4</option>
  43.                   <option value="5">5</option>
  44.               <option value="6">6</option>
  45.             <option value="7">7</option>
  46.             <option value="8">8</option>
  47.             <option value="9">9</option>
  48.             <option value="10">10</option>
  49.               <option value="10+">10+</option>
  50.          </select></p>
  51.         
  52.         <p><label>Special Instructions</label><textarea name="notes"></textarea></p>
  53.       
  54. <input type="submit" value="Submit" />      
  55.      </form>



PHP script (sendeail.php):

Code: [ Select ]
<?php

$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$date = $_POST['date'];
$time = $_POST['time'];
$people = $_POST['people'];
$number = $_POST['number'];


if (eregi('http:', $notes)) {
die ("Do NOT try that!");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Please enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Please Go back!");
}

if(empty($visitor) || empty($number) || empty($date) || empty($time) || empty($people)) {
echo "<h2>Use Back - Please fill in all fields</h2>\n";
die ("Use back!");
}

$notes = stripcslashes($notes);
$subject = "Booking";

$message = "
From: $visitor ($visitormail), $number \n
Date Booked: $date \n
Time: $time \n
No. of people: $people \n
Message: $notes \n
";

$from = "From: $visitormail\r\n";


mail("EMAIL-HERE" , $subject, $message, $from);

?>
<title>Booking Confirmation</title>

<div>
<p align="center">
Name: <strong><?php echo $visitor?>
</strong><br />
<br />
Date booked: <strong><?php echo $date?></strong> <br />
<br />
Time: <strong><?php echo $time ?></strong> <br />
<br />
No. of people: <strong><?php echo $people ?></strong> <br />
<br/>
Additonal Information:<br /><br/>
<strong>
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
</strong> <br />
<a href="app.html"> <strong>
<h3 align="center">*Click to finish*</h3></strong></a></p>
<p align="center"><strong>*</strong> Please note that we will get back to you within 24 hours of receiving this submission.</p>
</div>
 
 
  1. <?php
  2. $visitor = $_POST['visitor'];
  3. $visitormail = $_POST['visitormail'];
  4. $notes = $_POST['notes'];
  5. $date = $_POST['date'];
  6. $time = $_POST['time'];
  7. $people = $_POST['people'];
  8. $number = $_POST['number'];
  9. if (eregi('http:', $notes)) {
  10. die ("Do NOT try that!");
  11. }
  12. if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
  13. {
  14. echo "<h2>Use Back - Please enter valid e-mail</h2>\n";
  15. $badinput = "<h2>Feedback was NOT submitted</h2>\n";
  16. echo $badinput;
  17. die ("Please Go back!");
  18. }
  19. if(empty($visitor) || empty($number) || empty($date) || empty($time) || empty($people)) {
  20. echo "<h2>Use Back - Please fill in all fields</h2>\n";
  21. die ("Use back!");
  22. }
  23. $notes = stripcslashes($notes);
  24. $subject = "Booking";
  25. $message = "
  26. From: $visitor ($visitormail), $number \n
  27. Date Booked: $date \n
  28. Time: $time \n
  29. No. of people: $people \n
  30. Message: $notes \n
  31. ";
  32. $from = "From: $visitormail\r\n";
  33. mail("EMAIL-HERE" , $subject, $message, $from);
  34. ?>
  35. <title>Booking Confirmation</title>
  36. <div>
  37. <p align="center">
  38. Name: <strong><?php echo $visitor?>
  39. </strong><br />
  40. <br />
  41. Date booked: <strong><?php echo $date?></strong> <br />
  42. <br />
  43. Time: <strong><?php echo $time ?></strong> <br />
  44. <br />
  45. No. of people: <strong><?php echo $people ?></strong> <br />
  46. <br/>
  47. Additonal Information:<br /><br/>
  48. <strong>
  49. <?php $notesout = str_replace("\r", "<br/>", $notes);
  50. echo $notesout; ?>
  51. </strong> <br />
  52. <a href="app.html"> <strong>
  53. <h3 align="center">*Click to finish*</h3></strong></a></p>
  54. <p align="center"><strong>*</strong> Please note that we will get back to you within 24 hours of receiving this submission.</p>
  55. </div>
  56.  
  57.  
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9086
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Please go ahead and post the URL so we can see this in action, like you mentioned that would probably make it easier. I enabled your account to be able to post URLs.
  • remon479
  • Novice
  • Novice
  • remon479
  • Posts: 19

Post 3+ Months Ago

Here is the URL: http://www.therajasthan.co.uk/webapp/app.html#page4

After submitting a booking, a new window opens with a message 'undefined' on the top left corner of the page (please go ahead and try for yourself to see what i mean). Instead of this it should show the following info:

Quote:
Name:

Date booked:

Time:

No. of people:

Additional Information:




*Click to finish*

* Please note that we will get back to you within 24 hours of receiving this submission.
  • remon479
  • Novice
  • Novice
  • remon479
  • Posts: 19

Post 3+ Months Ago

I have resolved the problem :D

the html and php are running from one .php file rather than two separate HTML and PHP files...also with a little bit of code editing.. it is now working as it should be :)

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 69 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.