943,958 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 781
  • PHP RSS
Dec 7th, 2008
0

Adding validation after form finished

Expand Post »
Hi Gurus,
I have a form that works well. But there is no validation. Can validation be added on after the fact? I'm sure it's not ideal but can it be done. General suggestion appreciated on how.

Here's the code
php Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. if(isset($_POST["Submit"]))
  4. {
  5. require("c:\php\includes\class.phpmailer.php");
  6.  
  7. $mail = new PHPMailer();
  8.  
  9. $toaddress = "rocky@airedale911.org"; //Change this to the email address you will be receiving your notices.
  10. $mailhost = "mail.airedale911.org"; //Change this to your actual Domain name.
  11. $fromaddress = "rocky@airedale911.org"; //Change this to the email address you will use to send and authenticate with.
  12. $frompwd = "notarealpassword"; //Change this to the above email addresses password.
  13. $subject = "Airedale 911 Application Form"; //Change this to your own email message subject.
  14.  
  15.  
  16. $referredby = $_POST["Referredby"];
  17. $fromname = $_POST["Name"];
  18. $street = $_POST["Street"] ;
  19. $city = $_POST["City"];
  20. $state = $_POST["State"];
  21. $zip = $_POST["Zip"];
  22. $homephone = $_POST["Homephone"] ;
  23. $workphone = $_POST["Workphone"];
  24. $cellphone = $_POST["Cellphone"];
  25. $rplyto = $_POST["Email"];
  26. $family = $_POST["Family"] ;
  27. $sex = $_POST["Sex"] ;
  28. $previouslyowned = $_POST["Previouslyowned"] ;
  29. $whenpreviouslyowned = $_POST["Whenpreviouslyowned"] ;
  30. $sexpreviouslyowned = $_POST["Sexpreviouslyowned"] ;
  31. $otherbreeds = $_POST["Otherbreeds"] ;
  32. $fateoflastdog = $_POST["Fateoflastdog"] ;
  33. $lostadog = $_POST["Lostadog"] ;
  34. $movegiveupdog = $_POST["Movegiveupdog"] ;
  35. $otherpets = $_POST["Otherpets"] ;
  36. $otherpetsages = $_POST["Otherpetsages"] ;
  37. $otherpetsspayedneutered = $_POST["Otherpetsspayedneutered"] ;
  38. $otherpetscurrentlylicensed = $_POST["Otherpetscurrentlylicensed"] ;
  39. $fencedinyard = $_POST["Fencedinyard"] ;
  40. $kindoffence = $_POST["Kindoffence"] ;
  41. $howhighfence = $_POST["Howhighfence"] ;
  42. $sizeoffencedinarea = $_POST["Sizeoffencedinarea"] ;
  43. $runofhouse = $_POST["Runofhouse"] ;
  44. $allowedonfurniture = $_POST["Allowedonfurniture"] ;
  45. $havebedandblanket = $_POST["Havebedandblanket"] ;
  46. $dogbedinwhatroom = $_POST["Dogbedinwhatroom"] ;
  47. $wherewillairedalesleep = $_POST["Wherewillairedalesleep"] ;
  48. $hoursnoonehome = $_POST["Hoursnoonehome"] ;
  49. $daysaweekalone = $_POST["Daysaweekalone"] ;
  50. $whatroomabovetimes = $_POST["Whatroomabovetimes"] ;
  51. $travelingwherewilldogstay = $_POST["Travelingwherewilldogstay"] ;
  52. $familiardogcrate = $_POST["Familiardogcrate"] ;
  53. $whenwheredogcrate = $_POST["Whenwheredogcrate"] ;
  54. $reference1 = $_POST["Reference1"] ;
  55. $reference2 = $_POST["Reference2"] ;
  56. $vetinfo = $_POST["Vetinfo"] ;
  57. $comments = $_POST["Comments"] ;
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. $msgbody = "Referred by = " . $referredby
  66. ."<br>"
  67. ."Your Full Name = " . $fromname
  68. ."<br>"
  69. ."Your Street Address = " . $street
  70. ."<br>"
  71. ."City = " . $city
  72. ."<br>"
  73. ."State = " . $state
  74. ."<br>"
  75. ."Zip Code = " . $zip
  76. ."<br>"
  77. ."Your home telephone number (xxx-xxx-xxxx) = " . $homephone
  78. ."<br>"
  79. ."Your work number = " . $workphone
  80. ."<br>"
  81. ."Your cell phone number = " . $cellphone
  82. ."<br>"
  83. ."Email = " . $rplyto
  84. ."<br>"
  85. ."lease list names and ages of all family members (including yourself), live-in help, frequent visitors, etc. = " . $family
  86. ."<br>"
  87. ."Do you prefer a male or female Airedale? = " . $sex
  88. ."<br>"
  89. ."Have you previously owned an Airedale? = " . $previouslyowned
  90. ."<br>"
  91. ."When? = " . $whenpreviouslyowned
  92. ."<br>"
  93. ."Male or Female? = " . $sexpreviouslyowned
  94. ."<br>"
  95. ."What other dog breeds have you owned? = " . $otherbreeds
  96. ."<br>"
  97. ."What happened to your last dog? = " . $fateoflastdog
  98. ."<br>"
  99. ."Have you ever lost a dog other than through death? = " . $lostadog
  100. ."<br>"
  101. ."If you had to move, would you consider giving up your dog? = " . $movegiveupdog
  102. ."<br>"
  103. ."What other pets do you currently have? = " . $otherpets
  104. ."<br>"
  105. ."Their ages = " . $otherpetsages
  106. ."<br>"
  107. ."Are they spayed/neutered? = " . $otherpetsspayedneutered
  108. ."<br>"
  109. ."Are they currently licensed? = " . $otherpetscurrentlylicensed
  110. ."<br>"
  111. ."Do you a fenced-in yard? = " . $fencedinyard
  112. ."<br>"
  113. ."What kind of fence? = " . $kindoffence
  114. ."<br>"
  115. ."How high is the fence? = " . $howhighfence
  116. ."<br>"
  117. ."Size of fenced-in area? = " . $sizeoffencedinarea
  118. ."<br>"
  119. ."Will your new Airedale have run of the house? = " . $runofhouse
  120. ."<br>"
  121. ."Be allowed on the furniture? = " . $allowedonfurniture
  122. ."<br>"
  123. ."Have his/her own dog bed and blankets? = " . $havebedandblanket
  124. ."<br>"
  125. ."In what room will the dog bed be placed? = " . $dogbedinwhatroom
  126. ."<br>"
  127. ."In what room will your new Airedale sleep? = " . $wherewillairedalesleep
  128. ."<br>"
  129. ."How many hours at a time is no one at home? = " . $hoursnoonehome
  130. ."<br>"
  131. ."How many days a week will your dog be left alone? = " . $daysaweekalone
  132. ."<br>"
  133. ."In what room(s) will your dog be during the above times? = " . $whatroomabovetimes
  134. ."<br>"
  135. ."When you travel, where will your dog stay? = " . $travelingwherewilldogstay
  136. ."<br>"
  137. ."Are you familiar with a dog crate? = " . $familiardogcrate
  138. ."<br>"
  139. ."When and where do you use one? = " . $whenwheredogcrate
  140. ."<br>"
  141. ."Name, address, phone number = " . $reference1
  142. ."<br>"
  143. ."Name, address, phone number = " . $reference2
  144. ."<br>"
  145. ."Your veterinarian's name, address, phone number = " . $vetinfo
  146. ."<br>"
  147. ."Comments = " . $comments;
  148.  
  149.  
  150.  
  151. $mail->IsSMTP();
  152. $mail->Host = $mailhost;
  153. $mail->SMTPAuth = true;
  154. $mail->Username = $fromaddress;
  155. $mail->Password = $frompwd;
  156.  
  157. $mail->From = $fromaddress;
  158. $mail->FromName = $fromname;
  159. $mail->AddReplyTo($rplyto);
  160. $mail->AddAddress($toaddress);
  161. $mail->IsHTML(true);
  162. $mail->Subject = $subject;
  163. $mail->Body = $msgbody;
  164.  
  165. if(!$mail->Send())
  166.  
  167.  
  168.  
  169. {
  170. echo "Message could not be sent. <p>";
  171. echo "Mailer Error: " . $mail->ErrorInfo;
  172. exit;
  173. }
  174.  
  175. echo "Thank you, your message has been sent!";
  176. }
  177.  
  178. ?>
  179.  
  180. <html>
  181.  
  182. <head>
  183.  
  184. <style>
  185. .mystyle {font-size:15px; font-weight:600; font-family:Arial, Helvetica, sans-serif; font-variant:normal; letter-spacing:normal; font-size-adjust:inherit}
  186. TD.mystyle {font-size:15px; font-weight:600; font-family:Arial, Helvetica, sans-serif; font-variant:normal letter-spacing:normal; font-size-adjust:inherit}
  187. TR TD.mystyle {font-size:15px; font-weight:600; font-family:Arial, Helvetica, sans-serif; font-variant:normal letter-spacing:normal; font-size-adjust:inherit}
  188. TABLE TR TD.mystyle {font-size:15px; font-weight:600; font-family:Arial, Helvetica, sans-serif; font-variant:normal letter-spacing:normal; font-size-adjust:inherit}
  189. DIV TABLE TR TD.mystyle {font-size:15px; font-weight:600; font-family:Arial, Helvetica, sans-serif; font-variant:normal letter-spacing:normal; font-size-adjust:inherit}
  190. </style>
  191.  
  192. </head>
  193.  
  194.  
  195. <body>
  196.  
  197. <DIV class="mystyle">
  198.  
  199. <form name="SendEmail01" method="post">
  200.  
  201. <table border=0>
  202. <tr>
  203. <td class="mystyle">Referred by:</td>
  204. <td><input type="text" name="Referredby" size="30"></td>
  205. </tr>
  206. <tr>
  207. <td class="mystyle">Your Full Name:</td>
  208. <td><input type="text" name="Name" size="30"></td>
  209. </tr>
  210. <tr>
  211. <td class="mystyle">Your Street Address:</td>
  212. <td><input type="text" name="Street" size="30"></td>
  213. </tr>
  214. <tr>
  215. <td class="mystyle">City:</td>
  216. <td><input type="text" name="City" size="30"></td>
  217. </tr>
  218. <tr>
  219. <td class="mystyle">State:</td>
  220. <td><input type="text" name="State" size="30"></td>
  221. </tr>
  222. <tr>
  223. <td class="mystyle">Zip Code:</td>
  224. <td><input type="text" name="Zip" size="30"></td>
  225. </tr>
  226. <tr>
  227. <td class="mystyle">Your home telephone number (xxx-xxx-xxxx) :</td>
  228. <td><input type="text" name="Homephone" size="30"></td>
  229. </tr>
  230. <tr>
  231. <td class="mystyle">Your work number:</td>
  232. <td><input type="text" name="Workphone" size="30"></td>
  233. </tr>
  234. <tr>
  235. <td class="mystyle">Your cell phone number:</td>
  236. <td><input type="text" name="Cellphone" size="30"></td>
  237. </tr>
  238. <tr>
  239. <td class="mystyle">Email:</td>
  240. <td><input type="text" name="Email" size="30"></td>
  241. </tr>
  242. <tr>
  243. <td class="mystyle">Please list names and ages of all family members (including yourself), live-in help, frequent visitors, etc.:</td>
  244. <td><textarea rows="4" name="Family" cols="30"></textarea></td>
  245. </tr>
  246. <tr>
  247. <td class="mystyle">Do you prefer a male or female Airedale?:</td>
  248. <td><input type="radio" name="Sex" value="Male" checked="checked"> Male <br>
  249. <input type="radio" name="Sex" value="Female"> Female<br>
  250. <input type="radio" name="Sex" value="No preference"> No Preference<br>
  251. </td>
  252. </tr>
  253. <tr>
  254. <td> </td>
  255. </tr>
  256. <tr>
  257. <td> </td>
  258. </tr>
  259. <tr>
  260. <td class="mystyle">Have you previously owned an Airedale?:</td>
  261. <td><input type="radio" name="Previouslyowned" value="Yes"> Yes <br>
  262. <input type="radio" name="Previouslyowned" value="No" checked="checked"> No <br>
  263. </td>
  264. </tr>
  265. <tr>
  266. <td class="mystyle">When?:</td>
  267. <td><input type="text" name="Whenpreviouslyowned" size="30"></td>
  268. </tr>
  269. <td class="mystyle">Male or Female?:</td>
  270. <td><input type="radio" name="Sexpreviouslyowned" value="Male" checked="checked"> Male <br>
  271. <input type="radio" name="Sexpreviouslyowned" value="Female"> Female<br>
  272. <input type="radio" name="Sexpreviouslyowned" value="N/A"> N/A<br>
  273. </td>
  274. <tr>
  275. <td class="mystyle">What other dog breeds have you owned?:</td>
  276. <td><input type="text" name="Otherbreeds" size="30"></td>
  277. </tr>
  278. <tr>
  279. <td class="mystyle">What happened to your last dog?:</td>
  280. <td><input type="text" name="Fateoflastdog" size="30"></td>
  281. </tr>
  282. <tr>
  283. <td class="mystyle">Have you ever lost a dog other than through death?:</td>
  284. <td><input type="text" name="Lostadog" size="30"></td>
  285. </tr>
  286. <tr>
  287. <td class="mystyle">If you had to move, would you consider giving up your dog?:</td>
  288. <td><input type="text" name="Movegiveupdog" size="30"></td>
  289. </tr>
  290. <tr>
  291. <td class="mystyle">What other pets do you currently have?:</td>
  292. <td><input type="text" name="Otherpets" size="30"></td>
  293. </tr>
  294. <tr>
  295. <td class="mystyle">Their ages:</td>
  296. <td><input type="text" name="Otherpetsages" size="30"></td>
  297. </tr>
  298. <tr>
  299. <td class="mystyle">Are they spayed/neutered?:</td>
  300. <td><input type="text" name="Otherpetsspayedneutered" size="30"></td>
  301. </tr>
  302. <tr>
  303. <td class="mystyle">Are they currently licensed?:</td>
  304. <td><input type="text" name="Otherpetscurrentlylicensed" size="30"></td>
  305. </tr>
  306. <tr>
  307. <td class="mystyle">Do you a fenced-in yard?:</td>
  308. <td><input type="text" name="Fencedinyard" size="30"></td>
  309. </tr>
  310. <tr>
  311. <td class="mystyle">What kind of fence?:</td>
  312. <td><input type="text" name="Kindoffence" size="30"></td>
  313. </tr>
  314. <tr>
  315. <td class="mystyle">How high is the fence?:</td>
  316. <td><input type="text" name="Howhighfence" size="30"></td>
  317. </tr>
  318. <tr>
  319. <td class="mystyle">Size of fenced-in area?:</td>
  320. <td><input type="text" name="Sizeoffencedinarea" size="30"></td>
  321. </tr>
  322. <tr>
  323. <td class="mystyle">Will your new Airedale have "run of the house"?:</td>
  324. <td><input type="radio" name="Runofhouse" value="Yes"> Yes <br>
  325. <input type="radio" name="Runofhouse" value="No" checked="checked"> No <br>
  326. </td>
  327. </tr>
  328. <tr>
  329. <td> </td>
  330. </tr>
  331. <tr>
  332. <td> </td>
  333. </tr>
  334. <tr>
  335. <td class="mystyle">Be allowed on the furniture?:</td>
  336. <td><input type="radio" name="Allowedonfurniture" value="Yes"> Yes <br>
  337. <input type="radio" name="Allowedonfurniture" value="No" checked="checked"> No <br>
  338. </td>
  339. </tr>
  340. <tr>
  341. <td> </td>
  342. </tr>
  343. <tr>
  344. <td> </td>
  345. </tr>
  346. <tr>
  347. <td class="mystyle">Have his/her own dog bed and blankets?:</td>
  348. <td><input type="radio" name="Havebedandblanket" value="Yes"> Yes <br>
  349. <input type="radio" name="Havebedandblanket" value="No" checked="checked"> No <br>
  350. </td>
  351. </tr>
  352. <tr>
  353. <td class="mystyle">In what room will the dog bed be placed?:</td>
  354. <td><input type="text" name="Dogbedinwhatroom" size="30"></td>
  355. </tr>
  356. <tr>
  357. <td class="mystyle">In what room will your new Airedale sleep?:</td>
  358. <td><input type="text" name="Wherewillairedalesleep" size="30"></td>
  359. </tr>
  360. <tr>
  361. <td class="mystyle">How many hours at a time is no one at home?:</td>
  362. <td><input type="text" name="Hoursnoonehome" size="30"></td>
  363. </tr>
  364. <tr>
  365. <td class="mystyle">How many days a week will your dog be left alone?:</td>
  366. <td><input type="text" name="Daysaweekalone" size="30"></td>
  367. </tr>
  368. <tr>
  369. <td class="mystyle">In what room(s) will your dog be during the above times?:</td>
  370. <td><input type="text" name="Whatroomabovetimes" size="30"></td>
  371. </tr>
  372. <tr>
  373. <td class="mystyle">When you travel, where will your dog stay?:</td>
  374. <td><input type="text" name="Travelingwherewilldogstay" size="30"></td>
  375. </tr>
  376. <tr>
  377. <td class="mystyle">Are you familiar with a dog crate?:</td>
  378. <td><input type="radio" name="Familiardogcrate" value="Yes"> Yes <br>
  379. <input type="radio" name="Familiardogcrate" value="No" checked="checked"> No <br>
  380. </td>
  381. </tr>
  382. <tr>
  383. <td class="mystyle">When and where do you use one?:</td>
  384. <td><textarea rows="4" name="Whenwheredogcrate" cols="30"></textarea></td>
  385. </tr>
  386. <br><br>
  387. <tr>
  388. <td class="mystyle">REFERENCES: Name, address, phone number:</td>
  389. <td><textarea rows="4" name="Reference1" cols="30"></textarea></td>
  390. </tr>
  391. <tr>
  392. <td class="mystyle">REFERENCES: Name, address, phone number:</td>
  393. <td><textarea rows="4" name="Reference2" cols="30"></textarea></td>
  394. </tr>
  395. <tr>
  396. <td class="mystyle">REFERENCES: Your veterinarian's name, address, phone number:</td>
  397. <td><textarea rows="4" name="Vetinfo" cols="30"></textarea></td>
  398. </tr>
  399. <tr>
  400. <td class="mystyle">Comments:</td>
  401. <td><textarea rows="8" name="Comments" cols="30"></textarea></td>
  402. </tr>
  403. <tr>
  404. <td><input type="submit" name="Submit" value="Submit"></td>
  405. </tr>
  406.  
  407. </table>
  408. </form>
  409. </div>
  410.  
  411. </body></html>
  412.  

Thanks much
SqUarkMAn
Last edited by digital-ether; Dec 7th, 2008 at 8:52 pm. Reason: Please use [code=php] tags correctly [/code]
Reputation Points: 10
Solved Threads: 0
Light Poster
squarkman is offline Offline
42 posts
since Nov 2008
Dec 7th, 2008
0

Re: Adding validation after form finished

Yes, you usually do add validation later.

Simply you would want to make sure all form fields were filled in.

To check you would do:

php Syntax (Toggle Plain Text)
  1. if (isset($_POST['field']) && $_POST['field']) {
  2. // it was filled in
  3. }

If it wasn't you could give a message, stating that a particular field or set of fields are missing.

Then in the form fields, you'll want to 'remember' the user submitted values.

eg:
PHP Syntax (Toggle Plain Text)
  1. <input type="text" name="Referredby" size="30" value="<?php echo $_POST['Referredby']; ?>" />
Moderator
Reputation Points: 457
Solved Threads: 101
Nearly a Posting Virtuoso
digital-ether is offline Offline
1,250 posts
since Sep 2005
Dec 8th, 2008
0

Re: Adding validation after form finished

oops...

instead of doing like yours $var = $_REQUEST['var']

i will do like the following

foreach($_REQUEST as $key => $v)
$$key = $v;

the above code will convert all form variables into php variables
you could save lot of lines and typing work...

and here is one solution to your problem

foreach($_REQUEST as $key => $value)
if(empty($key)) echo $key." is empty";

and additionally what i might do is

i will create an associative array for the empty keys description
so like if the $key is firstname and if it is empty then displaying
"firstname is empty" wont be appropriate instead we will like to do
like "First Name is empty"

so create an associative array which will hold the actual texts for the
variables ($key) and display it...

and instead of doing like the following
"once ther lived ". $value

i would prefer like "once there lived $value";

how about you?
Last edited by jayapalchandran; Dec 8th, 2008 at 7:34 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jayapalchandran is offline Offline
6 posts
since Sep 2008
Dec 11th, 2008
0

Re: Adding validation after form finished

Hi...
I think its better to use javascript for the validation..
There are mainly 2 reasons for this purpose...

1) Using javascript it looks more professional.. You tell the user on the client side itself without submitting the form..
2) Once the form is submitted, then to validate, you also need to store all the values once.. maybe in a session.. so that we can return back to the form... Because the user will not like to fill in the whole form once again.. specially when its as big as ur form...

So its better to use javascript validation...

javascript Syntax (Toggle Plain Text)
  1. <script type="text/javascript" language="javascript">
  2.  
  3. function validate(frmobj)
  4. {
  5. name = frmobj.Name.value;
  6. if(name=="")
  7. {
  8. alert("Please input your full name");
  9. frmobj.Name.value="";
  10. frmobj.Name.focus();
  11. return false;
  12. }
  13.  
  14. street = frmobj.Street.value;
  15. if(name=="")
  16. {
  17. alert("Please input your Street");
  18. frmobj.Street.value="";
  19. frmobj.Street.focus();
  20. return false;
  21. }
  22.  
  23.  
  24. // Once the whole testing is done...
  25. // then return true to tell browser.. that form is validated
  26.  
  27. return true;
  28. }
  29. </script>

Once the javascript is coded..
then you can proceed with calling this function from form...

html Syntax (Toggle Plain Text)
  1. <form method="post" action="....somevalue...." onSubmit="javascript:return validate(this)">
  2.  
  3. </form>

You do not need to write the full document.formname.field.value..
since we are passing the this parameter that works as an object for the corresponding field in javascript..
Reputation Points: 11
Solved Threads: 12
Junior Poster in Training
sikka_varun is offline Offline
94 posts
since Dec 2008
Dec 11th, 2008
0

Re: Adding validation after form finished

Let me see if I understand.
You are saying JS is better because you won't have to store data to be retrieved since the validation is done at the time the form is filled out on client side. So you eliminate a database storage and you don't have to submit to validate.
Reputation Points: 10
Solved Threads: 0
Light Poster
squarkman is offline Offline
42 posts
since Nov 2008
Dec 11th, 2008
0

Re: Adding validation after form finished

Hunnn.. Yes.. You are almost correct...

In case of storage of data, its not in database when some input is wrong..

Suppose when some value is in error... then what you were doing..

1) submit the form
2) check validation in PHP...
3) link back to the form...

But at this point the form is empty,, since you are reloading the form..
so you have to temporary store the information that the user entered so that the user dont have to type the whole information again...
(its always irritating when u have to fill in the form which has more than 10 fields again and again, keep urself in place of a user)..

So you have to provide with some temporary storage when the form is submitted... the best option is sessions... Then again u clear sessions, and so on....
So in short it is a long procedure...

Thats y i said that before you actually write data to database, validate the information from javascript, so that once the form is submitted, there is no error in the data.. It is in the similar format/way you actually want from user... And finally, the form is submitted only once.....
Reputation Points: 11
Solved Threads: 12
Junior Poster in Training
sikka_varun is offline Offline
94 posts
since Dec 2008
Dec 12th, 2008
0

Re: Adding validation after form finished

Hunnn.. Yes.. You are almost correct...

In case of storage of data, its not in database when some input is wrong..

Suppose when some value is in error... then what you were doing..

1) submit the form
2) check validation in PHP...
3) link back to the form...

But at this point the form is empty,, since you are reloading the form..
so you have to temporary store the information that the user entered so that the user dont have to type the whole information again...
(its always irritating when u have to fill in the form which has more than 10 fields again and again, keep urself in place of a user)..

So you have to provide with some temporary storage when the form is submitted... the best option is sessions... Then again u clear sessions, and so on....
So in short it is a long procedure...

Thats y i said that before you actually write data to database, validate the information from javascript, so that once the form is submitted, there is no error in the data.. It is in the similar format/way you actually want from user... And finally, the form is submitted only once.....
It is good to have both server and client side validation, as some clients don't have JavaScript support.

JavaScript does increase the usability more then server side validation due to its faster feedback.
Moderator
Reputation Points: 457
Solved Threads: 101
Nearly a Posting Virtuoso
digital-ether is offline Offline
1,250 posts
since Sep 2005
Dec 12th, 2008
0

Re: Adding validation after form finished

It is good to have both server and client side validation, as some clients don't have JavaScript support.

JavaScript does increase the usability more then server side validation due to its faster feedback.
Yes.. I agree o digital-ether.... Thats a more safe idea...
You can use both of them to be tooooo sure that ur data is properly validated....

Otherwise most of the servers have javascript support with them... So i am usually assured that javascript thing will work...

Rest it depends upon developer to developer... you can add both.. absolutely no problem..

Since javascript would already have validated the data, PHP validation would be true as well (condition that you have applied similar validation in both javascript and php).. and php would carry on with the normal form submit thing...
Reputation Points: 11
Solved Threads: 12
Junior Poster in Training
sikka_varun is offline Offline
94 posts
since Dec 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Upload and Resize PNG and GIF images
Next Thread in PHP Forum Timeline: email configuration





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC