Jump to content

I got mobile number to validate but I am stuck at the prefix part.


Recommended Posts

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."'  )";
            

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?

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.