limits

Thread Solved

Join Date: Feb 2008
Posts: 22
Reputation: jinchiruki is an unknown quantity at this point 
Solved Threads: 0
jinchiruki jinchiruki is offline Offline
Newbie Poster

limits

 
0
  #1
Feb 26th, 2008
already put the validation..it will prompt user the errors..but it query into database also how can i solved it??
  1.  
  2. <table width="1000" height="95" border="1">
  3.  
  4. <tr>
  5.  
  6. <td bgcolor="#0000FF">&nbsp;</td>
  7.  
  8. </tr>
  9.  
  10. </table>
  11.  
  12. <?php
  13.  
  14.  
  15. include("connect.php");
  16.  
  17. //this is your validation in the form,put it here....
  18.  
  19. if (empty($_POST['name']))
  20.  
  21. {
  22.  
  23. $errors[] = 'Please enter a name';
  24.  
  25. }
  26.  
  27. if (empty($_POST['email']))
  28.  
  29. {
  30.  
  31. $errors[] = 'Please enter a valid e-mail address';
  32.  
  33. }
  34.  
  35. else if (!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$",
  36.  
  37. $_POST['email']))
  38.  
  39. {
  40.  
  41. $errors[] = 'Please enter a valid e-mail address';
  42.  
  43. }
  44.  
  45. if (empty($_POST['contact']))
  46.  
  47. {
  48.  
  49. $errors[] = 'Please enter a valid contact with numeric value';
  50.  
  51. }
  52.  
  53. else if (!is_numeric($_POST['contact']))
  54.  
  55. {
  56.  
  57. $errors[] = 'Please enter a valid contact with a numeric value';
  58.  
  59. }
  60.  
  61. if (empty($_POST['person_attend']))
  62.  
  63. {
  64.  
  65. $errors[] = 'Please enter some word for person attend';
  66.  
  67. }
  68.  
  69.  
  70.  
  71.  
  72.  
  73. else if (strlen ($_POST['person_attend']) > 255)
  74.  
  75. {
  76.  
  77. $errors[] = 'person attend';
  78.  
  79. }
  80.  
  81.  
  82. if (empty($_POST['comment']))
  83.  
  84. {
  85.  
  86. $errors[] = 'Please enter some comment';
  87.  
  88. }
  89.  
  90. else if (strlen ($_POST['comment']) > 255)
  91.  
  92. {
  93. $errors[] = 'comment ';
  94.  
  95. }
  96. $name = $_POST['name'];
  97. $email = $_POST['email'];
  98.  
  99. $contact = $_POST['contact'];
  100. $person_attend = $_POST['person_attend'];
  101.  
  102. $comment = $_POST['comment'];
  103.  
  104. if($name="" && $email="" && $contact="" && $person_attend="" && $comment="" )
  105.  
  106. $name = $_POST['name'];
  107. $email = $_POST['email'];
  108. $contact = $_POST['contact'];
  109. $person_attend = $_POST['person_attend'];
  110. $comment = $_POST['comment'];
  111.  
  112. $query = "INSERT INTO rsvp (id, name, email, contact, person_attend, comment)
  113. VALUES ('', '$name', '$email', '$contact', '$person_attend', '$comment')";
  114.  
  115. $results = mysql_query($query) or die
  116. ("Could not execute query : $query." . mysql_error());
  117.  
  118. {
  119.  
  120. if(isset($errors))
  121. {
  122. foreach($errors as $val)
  123. {
  124. echo "Error: $val <br>";
  125. }
  126. }
  127. {
  128. echo "Thanks for join us.";
  129. }
  130. }
  131.  
  132.  
  133.  
  134. {
  135.  
  136. mysql_close();
  137. }
  138.  
  139. ?>
  140.  
  141.  
  142. <a href="Index.php">View list attend</a>
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,747
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: limits

 
0
  #2
Feb 26th, 2008
Try this.
  1. <table width="1000" height="95" border="1">
  2.  
  3. <tr>
  4.  
  5. <td bgcolor="#0000FF">&nbsp;</td>
  6.  
  7. </tr>
  8.  
  9. </table>
  10.  
  11. <?php
  12.  
  13.  
  14. include("connect.php");
  15.  
  16. //this is your validation in the form,put it here....
  17.  
  18. if (empty($_POST['name']))
  19.  
  20. {
  21.  
  22. $errors[] = 'Please enter a name';
  23.  
  24. }
  25.  
  26. if (empty($_POST['email']))
  27.  
  28. {
  29.  
  30. $errors[] = 'Please enter a valid e-mail address';
  31.  
  32. }
  33.  
  34. else if (!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$",
  35.  
  36. $_POST['email']))
  37.  
  38. {
  39.  
  40. $errors[] = 'Please enter a valid e-mail address';
  41.  
  42. }
  43.  
  44. if (empty($_POST['contact']))
  45.  
  46. {
  47.  
  48. $errors[] = 'Please enter a valid contact with numeric value';
  49.  
  50. }
  51.  
  52. else if (!is_numeric($_POST['contact']))
  53.  
  54. {
  55.  
  56. $errors[] = 'Please enter a valid contact with a numeric value';
  57.  
  58. }
  59.  
  60. if (empty($_POST['person_attend']))
  61.  
  62. {
  63.  
  64. $errors[] = 'Please enter some word for person attend';
  65.  
  66. }
  67.  
  68.  
  69.  
  70.  
  71.  
  72. else if (strlen ($_POST['person_attend']) > 255)
  73.  
  74. {
  75.  
  76. $errors[] = 'person attend';
  77.  
  78. }
  79.  
  80.  
  81. if (empty($_POST['comment']))
  82.  
  83. {
  84.  
  85. $errors[] = 'Please enter some comment';
  86.  
  87. }
  88.  
  89. else if (strlen ($_POST['comment']) > 255)
  90.  
  91. {
  92. $errors[] = 'comment ';
  93.  
  94. }
  95. $name = $_POST['name'];
  96. $email = $_POST['email'];
  97.  
  98. $contact = $_POST['contact'];
  99. $person_attend = $_POST['person_attend'];
  100.  
  101. $comment = $_POST['comment'];
  102.  
  103. if($name="" && $email="" && $contact="" && $person_attend="" && $comment="" ) {
  104. if(isset($errors))
  105. {
  106. foreach($errors as $val)
  107. {
  108. echo "Error: $val <br>";
  109. }
  110. }
  111. } else {
  112.  
  113. $name = $_POST['name'];
  114. $email = $_POST['email'];
  115. $contact = $_POST['contact'];
  116. $person_attend = $_POST['person_attend'];
  117. $comment = $_POST['comment'];
  118.  
  119. $query = "INSERT INTO rsvp (id, name, email, contact, person_attend, comment)
  120. VALUES ('', '$name', '$email', '$contact', '$person_attend', '$comment')";
  121.  
  122. $results = mysql_query($query) or die
  123. ("Could not execute query : $query." . mysql_error());
  124. echo "Thanks for join us.";
  125. mysql_close();
  126. }
  127. ?>
  128.  
  129.  
  130. <a href="Index.php">View list attend</a>

One suggestion. Look at how loops, conditions, { } works. You have { } all over the place.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC