Delaran Posted May 9, 2007 Share Posted May 9, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/50707-solved-calling-_post-phone-numbers-including-dashes/ Share on other sites More sharing options...
Trium918 Posted May 9, 2007 Share Posted May 9, 2007 Try using string concatenation. <?php // Name of form fields $a = $_POST['are_code']; $b = $_POST['extension']; $c = $_POST['digits']; $result =$a."-".$b."-".$c; ?> Quote Link to comment https://forums.phpfreaks.com/topic/50707-solved-calling-_post-phone-numbers-including-dashes/#findComment-249286 Share on other sites More sharing options...
cmgmyr Posted May 9, 2007 Share Posted May 9, 2007 if you take that (int) out it should work too Quote Link to comment https://forums.phpfreaks.com/topic/50707-solved-calling-_post-phone-numbers-including-dashes/#findComment-249294 Share on other sites More sharing options...
Delaran Posted May 9, 2007 Author Share Posted May 9, 2007 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 ?> Quote Link to comment https://forums.phpfreaks.com/topic/50707-solved-calling-_post-phone-numbers-including-dashes/#findComment-249298 Share on other sites More sharing options...
Trium918 Posted May 9, 2007 Share Posted May 9, 2007 That should do it! Quote Link to comment https://forums.phpfreaks.com/topic/50707-solved-calling-_post-phone-numbers-including-dashes/#findComment-249302 Share on other sites More sharing options...
Delaran Posted May 9, 2007 Author Share Posted May 9, 2007 if you take that (int) out it should work too This worked. Thanks y'all! Quote Link to comment https://forums.phpfreaks.com/topic/50707-solved-calling-_post-phone-numbers-including-dashes/#findComment-249303 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.