Jump to content

[SOLVED] Calling $_POST phone numbers (including dashes)


Delaran

Recommended Posts

Hey all, I'm certain this thread belongs in this forum  ::)

 

Anyway, I'm at the point where I am calling the $_POST data inserted in a text field from the previous page.  However, if the user inserts their phone number in the field as:

 

"555-555-5555" than it will return on the next page as:

 

"555" and omit the rest.  However, if entered as:

 

"5555555555" it returns as "5555555555".

 

Obviously the dashes are being omitted and everything beyond them.  Stripslashes has not worked for me.  My code is as follows:

 

we will contact you at <?php echo stripslashes((int)($_POST['phone'])); ?>

 

Please help!

Link to comment
Share on other sites

So should I create three text fields on the first page to signify area code, middle, and latter areas in the phone number, then assign their own $_POST values to call?

 

I would assume the way it would work would be something similar to:

 

<?php
<p>Phone number * <br><input type="text" name="areacode" size="3" maxsize="3" /><input type="text" name="midnum" size="3" maxsize="3" /><input type="text" name="lastnum" size="4" maxsize="4" /></p>
?>

 

And to call this, I would use:

 

<?php
// Name of form fields
$a = $_POST['areacode'];
$b = $_POST['midnum'];
$c = $_POST['lastnum'];

$result =$a."-".$b."-".$c;

we will contact you at echo $result ?>

Link to comment
Share on other sites

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.