Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Formularz kontaktowy nie dziala.
Forum PHP.pl > Forum > PHP
dirtyhustlaz
Witam.
Stworzylem prosty formularz kontaktowy do rezerwowania spotania w studiu tatuazu. Po wypelnieniu formularza i wyslaniu formularza powinna wyswietlic sie nastepna strona z informacja dla uzytkownika a pojawia sie bialy ekran ze stopka strony ktora powinna sie wyswietlic. Szukalem bledu ale nie moge nic znales. moze mi ktos pomoc z naprawa tego?

To jest kod pliku z formularzem:
  1. <?php session_start();
  2. $expire=time()+60*60*24*30;
  3. date_default_timezone_set('Europe/London');
  4. setcookie("user",$today = date("F j, Y, g:i a") ,$expire);
  5. ?>
  6. <!DOCTYPE html>
  7. <html>
  8. <head>
  9. <meta charset="utf-8">
  10. <meta name="viewport" content="width=device-width, initial-scale=1">
  11. <title>.:Fallen Angels Tatto and Bodypiercing:.</title>
  12. <link rel="stylesheet" href="themes/blackandwhite.min.css" />
  13. <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile.structure-1.3.1.min.css" />
  14. <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  15. <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
  16. </head>
  17. <body>
  18. <div data-role="page" data-theme="a">
  19.  
  20. <div data-role="header">
  21. <h1>Fallen Angels</h1>
  22. <div data-role="navbar">
  23. <ul>
  24. <li><a href="menu.php" data-transition="slide" data-icon="home" data-iconpos="left">Main menu</a></li>
  25.  
  26. </ul>
  27. </div><!-- /navbar -->
  28. </div><!-- /header -->
  29.  
  30. <div data-role="content" align="center">
  31.  
  32.  
  33. <?php
  34. if (isset($_SESSION['username']))
  35.  
  36. {
  37. $user = $_SESSION['username'];
  38. $con = mysql_connect("localhost","uo151818_fallena","pass1234");
  39. if (!$con)
  40. {
  41. die('Could not connect: ' . mysql_error());
  42. }
  43.  
  44. mysql_select_db("uo151818_fallenangels", $con);
  45.  
  46.  
  47. $result=mysql_query('SELECT * FROM users WHERE username="'.$_SESSION['username'].'"');
  48.  
  49. while($row = mysql_fetch_array($result))
  50.  
  51.  
  52. mysql_close($con);
  53. }
  54. else
  55. die("You must be logged in <a href='login.php'>Back</a>");
  56.  
  57.  
  58. ?>
  59.  
  60. <h3>Book an appoiment</h3>
  61.  
  62.  
  63. <form name="bookingform" method="post" action="book_appoiment.php">
  64. <div id="form-content">
  65. <fieldset>
  66. <div class="fieldgroup">
  67. <label for="first_name">First name<small>(This field is required)</small></label>
  68. <input type="text" name="first_name" value="">
  69. </div>
  70.  
  71. <div class="fieldgroup">
  72. <label for="last_name">Surname<small>(This field is required)</small></label>
  73. <input type="text" name="last_name" alue="">
  74. </div>
  75.  
  76. <div class="fieldgroup">
  77. <label for="email">E-mail <small>(This field is required)</small></label>
  78. <input type="text" name="email" alue="">
  79. </div>
  80.  
  81. <div class="fieldgroup">
  82. <label for="telephone">Telephone <small>(This field is required)</small></label>
  83. <input type="text" name="telephone">
  84. </div>
  85.  
  86. <div class="fieldgroup">
  87. <label for="date">Date<small>(This field is required)</small></label>
  88. <input type="text" name="date">
  89. </div>
  90.  
  91. <div class="fieldgroup">
  92. <label for="type" class="select">What do you want?</label>
  93. <select name="type" id="select-choice-1">
  94. <option value="tattoo">Tattoo</option>
  95. <option value="bodypiercing">Bodypiercing</option>
  96. <option value="information">Information</option>
  97. </select>
  98. </div>
  99.  
  100. <div class="fieldgroup">
  101. <label for="comments">Comments:</label>
  102. <textarea cols="40" rows="10" name="comments" id="textarea"></textarea>
  103. </div
  104.  
  105. <div class="fieldgroup">
  106. <input type="submit" value="Book appoiment" class="submit">
  107. </div>
  108.  
  109. </fieldset>
  110. </div>
  111. </form>
  112.  
  113.  
  114. </div><!-- /content -->
  115. <a href="logout.php" data-role="button">Logout</a>
  116. <div data-role="footer" data-position="fixed">
  117. <h4>Fallen Angels 2013. All right reserved.</h4>
  118. </div><!-- /footer -->
  119. </div><!-- /page -->
  120. </body>
  121. </html>


A to jest kod pliku z funkcja wysylania emaila i strona z podziekowaniami:
  1. <?php
  2. $expire=time()+60*60*24*30;
  3. date_default_timezone_set('Europe/London');
  4. setcookie("user",$today = date("F j, Y, g:i a") ,$expire);
  5.  
  6.  
  7. if(isset($_POST['email'])) {
  8.  
  9. // EDIT THE 2 LINES BELOW AS REQUIRED
  10. $email_to = "przystup@gmail.com";
  11. $email_subject = "New appoiment booking form Mobile App";
  12.  
  13.  
  14. function died($error) {
  15. // your error code can go here
  16. echo "We are very sorry, but there were error(s) found with the form you submitted. ";
  17. echo "These errors appear below.<br /><br />";
  18. echo $error."<br /><br />";
  19. echo "Please go back and fix these errors.<br /><br />";
  20. die();
  21. }
  22.  
  23. // validation expected data exists
  24. if(!isset($_POST['first_name']) ||
  25. !isset($_POST['last_name']) ||
  26. !isset($_POST['email']) ||
  27. !isset($_POST['telephone']) ||
  28. !isset($_POST['date']) ||
  29. !isset($_POST['type']) ||
  30. !isset($_POST['comments'])) {
  31. died('We are sorry, but there appears to be a problem with the form you submitted.');
  32. }
  33.  
  34. $first_name = $_POST['first_name']; // required
  35. $last_name = $_POST['last_name']; // required
  36. $email_from = $_POST['email']; // required
  37. $telephone = $_POST['telephone']; // not required
  38. $telephone = $_POST['date']; // not required
  39. $telephone = $_POST['type']; // not required
  40. $comments = $_POST['comments']; // required
  41.  
  42. $error_message = "";
  43. $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  44. if(!preg_match($email_exp,$email_from)) {
  45. $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  46. }
  47. $string_exp = "/^[A-Za-z .'-]+$/";
  48. if(!preg_match($string_exp,$first_name)) {
  49. $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  50. }
  51. if(!preg_match($string_exp,$last_name)) {
  52. $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  53. }
  54. if(!preg_match($string_exp,$telephone)) {
  55. $error_message .= 'The telephone number you entered does not appear to be valid.<br />';
  56. }
  57. if(!preg_match($string_exp,$date)) {
  58. $error_message .= 'The date you entered does not appear to be valid.<br />';
  59. }
  60. if(!preg_match($string_exp,$type)) {
  61. $error_message .= 'The type of bookin you entered does not appear to be valid.<br />';
  62. }
  63. if(strlen($error_message) > 0) {
  64. died($error_message);
  65. }
  66. $email_message = "Form details below.\n\n";
  67.  
  68. function clean_string($string) {
  69. $bad = array("content-type","bcc:","to:","cc:","href");
  70. return str_replace($bad,"",$string);
  71. }
  72.  
  73. $email_message .= "First Name: ".clean_string($first_name)."\n";
  74. $email_message .= "Last Name: ".clean_string($last_name)."\n";
  75. $email_message .= "Email: ".clean_string($email_from)."\n";
  76. $email_message .= "Telephone: ".clean_string($telephone)."\n";
  77. $email_message .= "Date: ".clean_string($date)."\n";
  78. $email_message .= "Booking for: ".clean_string($type)."\n";
  79. $email_message .= "Comments: ".clean_string($comments)."\n";
  80.  
  81.  
  82. // create email headers
  83. $headers = 'From: '.$email_from."\r\n".
  84. 'Reply-To: '.$email_from."\r\n" .
  85. 'X-Mailer: PHP/' . phpversion();
  86. @mail($email_to, $email_subject, $email_message, $headers);
  87.  
  88. ?>
  89.  
  90.  
  91.  
  92. <html>
  93. <head>
  94. <meta charset="utf-8">
  95. <meta name="viewport" content="width=device-width, initial-scale=1">
  96. <title>.:Fallen Angels Tatto and Bodypiercing:.</title>
  97. <link rel="stylesheet" href="themes/blackandwhite.min.css" />
  98. <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile.structure-1.3.1.min.css" />
  99. <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  100. <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
  101. </head>
  102. <body>
  103. <div data-role="page" data-theme="a">
  104.  
  105. <div data-role="header">
  106. <h1>Fallen Angels</h1>
  107. <div data-role="navbar">
  108. <ul>
  109. <li><a href="menu.php" data-transition="slide" data-icon="home" data-iconpos="left">Main menu</a></li>
  110.  
  111. </ul>
  112. </div><!-- /navbar -->
  113. </div><!-- /header -->
  114.  
  115. <div data-role="content" align="center">
  116.  
  117.  
  118.  
  119. <?php
  120. if (isset($_SESSION['username']))
  121.  
  122. {
  123. $user = $_SESSION['username'];
  124. $con = mysql_connect("localhost","uo151818_fallena","pass1234");
  125. if (!$con)
  126. {
  127. die('Could not connect: ' . mysql_error());
  128. }
  129.  
  130. mysql_select_db("uo151818_fallenangels", $con);
  131.  
  132.  
  133. $result=mysql_query('SELECT * FROM users WHERE username="'.$_SESSION['username'].'"');
  134.  
  135. while($row = mysql_fetch_array($result))
  136.  
  137.  
  138. mysql_close($con);
  139. }
  140. else
  141. die("You must be logged in <a href='login.php'>Back</a>");
  142.  
  143.  
  144. ?>
  145.  
  146.  
  147.  
  148. <p> Thanks for booking an appoiment. We will confirm by phone or email in 24h</p>
  149. </div><!-- /content -->
  150. <a href="logout.php" data-role="button">Logout</a>
  151. <div data-role="footer" data-position="fixed">
  152. <h4>Fallen Angels 2013. All right reserved.</h4>
  153. </div><!-- /footer -->
  154. </div><!-- /page -->
  155. </body>
  156. </html>
  157.  
  158.  
  159.  
  160. <?php
  161. }
  162. ?>
erix
Popraw wcięcia, bo kod jest długi, a przez to nieczytelny.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.