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!

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 ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.