Question:
Can you combine two input fields on a form on the next PHP confirmation form to a variable?
Phil M
2009-11-17 22:25:30 UTC
I have an area code and phone number field. 2 Fields (Area Code) and (Phone Number) and onto the next PHP confirmation page, I would like to combine them to make 1 variable to be stored into a database.

Here is the PHP variable code I have:
$phoneareacode = $_POST['phoneareacode'];
$phone = $_POST['phone'];

How can I combine the two to make 1 phone number?
Three answers:
Zack P
2009-11-17 22:33:38 UTC
$finalNumber = $phoneareacode . $phone;
?
2016-02-29 03:41:22 UTC
If you have the username and email address in session, why do you want it to come back from the browser? Can't you just get it from $session again? If you rely on what comes back from the browser, then you have a security problem. You can disable an input field. I can enable it again using simple tools that are built into most browsers. So can any wanna be hacker. So you can't trust what comes back from the browser (unless it is encrypted data that only you can decrypt). NEVER TRUST DATA COMING FROM THE CLIENT. You have no control over it. You *CAN'T* make it readonly. I think the problem you need to solve is how to get username and email back from session, not from the browser.
2009-11-17 22:34:25 UTC
$phonenumber = $_POST['phoneareacode'].$_POST['phone'];



Use a "." to add the two inputs.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...