skybird Posted January 26, 2012 Share Posted January 26, 2012 Hi, I want to add phone# info in registration form. But after clicking submit button, both phone# and the message (Please enter your phone number!) exist. My Q is how to remove the sticky message? Here is the code in register.php: // Check for phone#: if (preg_match ('/^[A-Z0-9]{2,30}$/i', $_POST['phone'])) { $u = mysqli_real_escape_string ($dbc, $_POST['phone']); } else { $reg_errors['phone'] = 'Please enter your phone number!'; } And the code for form in register.php: <form action="contact.php" method="post" accept-charset="utf-8" style="padding-left:100px"> <p><label for="phone"><strong>Phone Number</strong></label><br /><?php create_form_input('phone', 'text', $reg_errors); ?></p> </form> I don't make any change in form_functions.inc.php. Thanks for your kind help. xampp 1.7.3 php5.3.1 mysql 5.1.41 php<MyAdmin 3.2.4 Win7 editor: DW Link to comment Share on other sites More sharing options...
Hermann Posted January 26, 2012 Share Posted January 26, 2012 Hi there. Have a look on page 270 of Effortless E-Commerce. Larry used a Phone number in the second example and you can check how he validated this. 1 Link to comment Share on other sites More sharing options...
skybird Posted January 27, 2012 Author Share Posted January 27, 2012 Hi Hermann, Thank you very much for your guide. My problem was solved. after reading page 270, i found the above validation code works unless there's space between the phone#. Thanks again. Link to comment Share on other sites More sharing options...
Hermann Posted January 28, 2012 Share Posted January 28, 2012 Great pleasure. You should thank Larry for his great book as I'm not clever enough to find solutions like these !! haha Link to comment Share on other sites More sharing options...
Recommended Posts