rahul19dj Posted August 3, 2012 Share Posted August 3, 2012 if(empty($_POST['mobileno'])) // phone number is not empty { $error[] = 'Please enter mobile number'; } else { if(preg_match('/^\d{10}$/',$_POST['mobileno'])) // phone number is valid { $mobile = $_POST['mobileno']; // your other code here } else // phone number is not valid { $error[] = 'Phone number invalid !'; } } $prefix = 0; $pmobile = $prefix . $mobile; This is what I am trying to do for prefix. Is this right as I cant add the value 0 before the number. This is my insert statement $query_verify_mobileno = "SELECT * FROM userdtls WHERE mobileno = '$pmobile'"; $result_verify_mobileno = mysqli_query($dbc, $query_verify_mobileno); if (!$result_verify_mobileno) {//if the Query Failed ,similar to if($result_verify_mobileno==false) echo ' Database Error Occured '; } if (mysqli_num_rows($result_verify_mobileno) == 0) { // IF no previous user is using this number . // Create a unique activation code: //$activation = md5(uniqid(rand(), true)); $query_insert_user = "INSERT INTO userdtls ( mobileno, serviceprovider, pass, fname, lname, email, citystate, MUM, PUN, BNG, MYS ) VALUES ( '".$pmobile."', '".$serviceprovider."', '".$password."', '".$fname."', '".$lname."', '".$email."', '".$citystate."','".$mumbai."', '".$pune."', '".$banglore."', '".$mysore."' )"; Quote Link to comment https://forums.phpfreaks.com/topic/266622-i-got-mobile-number-to-validate-but-i-am-stuck-at-the-prefix-part/ Share on other sites More sharing options...
Mahngiel Posted August 3, 2012 Share Posted August 3, 2012 you done with this thread? What's the database cell type where you're trying to store the value? many types will drop the leading 0 Quote Link to comment https://forums.phpfreaks.com/topic/266622-i-got-mobile-number-to-validate-but-i-am-stuck-at-the-prefix-part/#findComment-1366493 Share on other sites More sharing options...
rahul19dj Posted August 3, 2012 Author Share Posted August 3, 2012 I am storing as bigint(11) Quote Link to comment https://forums.phpfreaks.com/topic/266622-i-got-mobile-number-to-validate-but-i-am-stuck-at-the-prefix-part/#findComment-1366494 Share on other sites More sharing options...
rahul19dj Posted August 3, 2012 Author Share Posted August 3, 2012 the old thread had 2 problems 1. to validate phone no ( which I got it ) 2. To add prefix of 0 before adding to the database ( which I am expecting you can help) Thanks Quote Link to comment https://forums.phpfreaks.com/topic/266622-i-got-mobile-number-to-validate-but-i-am-stuck-at-the-prefix-part/#findComment-1366495 Share on other sites More sharing options...
Mahngiel Posted August 3, 2012 Share Posted August 3, 2012 i'm not the brightest around here will database intricaces, but i do believe if you set the attributes to 'unsigned zerofill' you should be okay. PS, if that other thread is done, mark it solved ploxxors PPS: are the phone numbers you're storing always 10 digits? Quote Link to comment https://forums.phpfreaks.com/topic/266622-i-got-mobile-number-to-validate-but-i-am-stuck-at-the-prefix-part/#findComment-1366497 Share on other sites More sharing options...
rahul19dj Posted August 3, 2012 Author Share Posted August 3, 2012 i have put unsigned but what is zero fill ( is it null ) Quote Link to comment https://forums.phpfreaks.com/topic/266622-i-got-mobile-number-to-validate-but-i-am-stuck-at-the-prefix-part/#findComment-1366498 Share on other sites More sharing options...
rahul19dj Posted August 3, 2012 Author Share Posted August 3, 2012 i have marked it as solved Quote Link to comment https://forums.phpfreaks.com/topic/266622-i-got-mobile-number-to-validate-but-i-am-stuck-at-the-prefix-part/#findComment-1366499 Share on other sites More sharing options...
Mahngiel Posted August 3, 2012 Share Posted August 3, 2012 zerofill will maintain the integer count you specified ( which, btw, you don't need bigint )and produce leading zeros. say you store 567, zerofill should give 0567 on a int(4). maybe it's the other way around, i dunno for sure. but if you're going to store the numbers formatted, which it would make sense to, you should just save it as a string. Quote Link to comment https://forums.phpfreaks.com/topic/266622-i-got-mobile-number-to-validate-but-i-am-stuck-at-the-prefix-part/#findComment-1366500 Share on other sites More sharing options...
rahul19dj Posted August 3, 2012 Author Share Posted August 3, 2012 where do I put zero fill Quote Link to comment https://forums.phpfreaks.com/topic/266622-i-got-mobile-number-to-validate-but-i-am-stuck-at-the-prefix-part/#findComment-1366503 Share on other sites More sharing options...
rahul19dj Posted August 3, 2012 Author Share Posted August 3, 2012 Hey, Thanks a ton I got it finally. I just used zerofill Thanks a lot Quote Link to comment https://forums.phpfreaks.com/topic/266622-i-got-mobile-number-to-validate-but-i-am-stuck-at-the-prefix-part/#findComment-1366506 Share on other sites More sharing options...
Mahngiel Posted August 3, 2012 Share Posted August 3, 2012 Good job! Hope you learned something today! Quote Link to comment https://forums.phpfreaks.com/topic/266622-i-got-mobile-number-to-validate-but-i-am-stuck-at-the-prefix-part/#findComment-1366509 Share on other sites More sharing options...
rahul19dj Posted August 3, 2012 Author Share Posted August 3, 2012 Yup now I have problem in something else. http://forums.phpfreaks.com/index.php?topic=363423.0 Would be helpful if you can let me know in this too Quote Link to comment https://forums.phpfreaks.com/topic/266622-i-got-mobile-number-to-validate-but-i-am-stuck-at-the-prefix-part/#findComment-1366511 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.