0

I'm simply echoing a user's info in an HTML form as "value=". Everything is working perfectly except the phone number. Here is my current code:

 <div class="sign-in-btn">
            <input type="phoneNumber" data-mask="(000) 000-0000" name='User_phonenumber' id='User_phonenumber' value=<?php echo $phone;?> />
          </div>

Only the area code appears - ie (908). The phone number is formatted in the db as (xxx) xxx-xxxx.

I feel it has something to do with the form because it echos perfectly when done outside the form. For example, the full number (with formatting) echos perfectly in this :

<h3 class="sign-in-header">Your phone number is <?php echo $phone;?> </h3>

Steps I've taken:

  1. removed "type" in the form attributes - no success
  2. removed "data-type" in the form - no success
  3. echoed $phone in other form fields (first name, etc) - same issue.

Any ideas guys and gals?!

Thanks!!

Tim
  • 17
  • 8
  • Please show your output array comes from database .... – Aman Kumar Mar 29 '17 at 04:35
  • your variable `$phone` is being affected by some other code in the PHP. How do you pull it from the database? What processes it before you echo it to the form? – Cfreak Mar 29 '17 at 04:36
  • don'T you need jquery to enable data-mask ? http://stackoverflow.com/questions/12578507/how-to-implement-an-input-with-a-mask (or implement it with js) – Louis Loudog Trottier Mar 29 '17 at 04:41
  • @AmanKumar - Here is a var_dump($userInfo) - string(33040) "{"LoginValid":true,"UserID_Valid":true,"UserID":5,"DriverID":132,"Email":"timk___@mac.com","AccountLoginType":"Facebook","FirstName":"Mitch","LastName":"Mitchell","MiddleName":"","PhoneNumber":"(908) 432-1424","CardOnRecord":true,"AccountComplete":true,"UserRating":4.46"}" – Tim Mar 29 '17 at 04:52
  • @Cfreak I'll past it here, sorry for the poor formatting :/ --- $info = new RetrieveInfo(REST_SERVER . 'UserInfo.php', $userSession); $userInfo = $info->DriverData(); //convert json data to array $userInfoArray = json_decode($userInfo,true); $loginValid = $userInfoArray['LoginValid']; $firstName = $userInfoArray['FirstName']; $lastName = $userInfoArray['LastName']; $phone = $userInfoArray['PhoneNumber']; $email = $userInfoArray['Email']; – Tim Mar 29 '17 at 04:53
  • @LouisLoudogTrottier - the "data-mask" doesn't seem to have any effect. I removed that and changed it to other types but had the same issue. Thanks though! – Tim Mar 29 '17 at 04:55
  • @Tim you should edit your post to include the new info. But print out `$userInfoArray['PhoneNumber']` to make sure it's what you expect – Cfreak Mar 29 '17 at 20:45

1 Answers1

4

your problem is here this

value=<?php echo $phone;?>

should be

value="<?php echo $phone;?>"

you forgot the quotes

Gert
  • 360
  • 3
  • 8
  • man, what a newb mistake @Gert! Why do you think the others worked fine without quotes? Is it because the $phone includes spaces? Thanks!!! – Tim Mar 29 '17 at 04:59
  • the other on is text and don't use "", for value the format is value="some value" , your welcome – Gert Mar 29 '17 at 05:04