Xster Posted January 30, 2007 Share Posted January 30, 2007 My time form suppose to accept the [b]numbers[/b] written as (eg: 01 for hours and 02 for minutes)i've tried this regex code on my php code...[b]$legit = ereg("^[0-9]{2,2}$", $time);[/b]and here's my php code...[code]<?phpif(!isset($_POST['submit'])){?><form action="" method="post"><table width="100%" cellpadding="10" cellspacing="0" border="0"><!--Step 3 : Select Time--><tr><td style="border-width:1px; border-color:#A8B2C6; border-style:solid;" class="body" colspan="2"><div style="font-size:18px; color:#007E8C; font-weight:bold;"><font color="#cccccc">3. </font>Select Time</div><br></td></tr><tr><td width="15%" class="body-facilities">From:</td><td class="body-facilities"> <input type="text" name="timeFrom" size="1" maxlength="2"> : <input type="text" name="timeFrom1" size="1" maxlength="2"> <sup style="color:#FF0000">eg: 08:00</sup></td></tr><tr><td class="body-facilities">To:</td><td class="body-facilities"> <input type="text" name="timeTo" size="1" maxlength="2"> : <input type="text" name="timeTo1" size="1" maxlength="2"> <sup style="color:#FF0000">eg: 23:00</sup></td></tr><tr><td class="body-facilities"><sub>Operating Hour:</sub></td><td class="body-facilities"><sub><?php echo $row_rs['fac_wkdayS'];?> to <?php echo $row_rs['fac_wkdayE'];?> (Monday to Friday)</sub><br><sub><?php echo $row_rs['fac_wkendS'];?> to <?php echo $row_rs['fac_wkendE'];?> (Saturday & Sunday)</sub></td></tr><tr><td colspan="2" align="right"><input type="submit" name="submit" value="Next"> <input type="hidden" name="fac_id" value="<?php echo $fac_id;?>"></td></tr></table></form><?php}?></td></tr></table></td>[/code]mine does not work...anybody got ideas for more tests I can run to pin down this problem..? u guys rock...! Quote Link to comment Share on other sites More sharing options...
effigy Posted January 30, 2007 Share Posted January 30, 2007 Are you trying to match hours [i]and[/i] seconds, such as 09:05? What values are in the variables[tt] $time [/tt]and[tt] $legit[/tt]? Quote Link to comment Share on other sites More sharing options...
Xster Posted January 30, 2007 Author Share Posted January 30, 2007 Btw,this link...[url=http://www.badongo.com/pic/433848]http://www.badongo.com/pic/433848[/url]suppose to show you the image of my php..hope this will help...p/s: effigy: i want my form accepting only [b]numbers[/b]...if you see mine still accepting any data entry such as letter,symbol or none (means nothing to put inside the box) please put the line if you got any ideas..thk u Quote Link to comment Share on other sites More sharing options...
effigy Posted January 30, 2007 Share Posted January 30, 2007 [code]if (preg_match('/^\D+\z/', $field)) { echo 'Invalid entry';}[/code][tt]\D [/tt]means "not a digit." Quote Link to comment Share on other sites More sharing options...
Xster Posted January 31, 2007 Author Share Posted January 31, 2007 effiegy...do u know which line should I put your code according to my php code?mine does not work and still got same problem... Quote Link to comment Share on other sites More sharing options...
effigy Posted January 31, 2007 Share Posted January 31, 2007 Try some troubleshooting techniques. Are you sure your form data is being read properly? Does this show you the proper information when you submit your form?[code]echo '<pre>', print_r($_POST, true), '</pre>';[/code] Quote Link to comment Share on other sites More sharing options...
Xster Posted January 31, 2007 Author Share Posted January 31, 2007 effigy,Im not quiet sure..but still I need your attention..what Im looking is,when I click button 'next'then its shows prompt msg something like "Invalid Entry" (if user didnt insert numbers into the box)pls forgive me if Im ask for stupid questions because Im freaking new bout this PHP. Quote Link to comment Share on other sites More sharing options...
effigy Posted January 31, 2007 Share Posted January 31, 2007 Well, let's start from the beginning. What is in your form's "action" attribute? Quote Link to comment Share on other sites More sharing options...
Xster Posted February 13, 2007 Author Share Posted February 13, 2007 [code]<form action="" method="post">[/code]why effigy? Quote Link to comment Share on other sites More sharing options...
effigy Posted February 13, 2007 Share Posted February 13, 2007 I'm trying to figure out how you're processing your form. You need an "action" URL to send the form submittal to, which can process the data. Have you setup any of this? Quote Link to comment Share on other sites More sharing options...
Xster Posted February 13, 2007 Author Share Posted February 13, 2007 No. How to setup?I want the PHP to check for the errors (eg : no input or wrong time format) and put them all in an array, if there are some errors it should redirect back to the previous form (written in html and php) and display the errors, if there are no errors it should link to the confirmation page before the data save into database.Is there any way to do that effigy? I already sent my php code before..hope you can show me how to setup.. Quote Link to comment Share on other sites More sharing options...
effigy Posted February 13, 2007 Share Posted February 13, 2007 Have a look at these tutorials:http://www.tizag.com/phpT/forms.phphttp://www.w3schools.com/php/php_forms.asp Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.