I have loaded libphonenumber for php and also I have created variable which is $phone that I would from users to enter their info as input type. Also, I would from libphonenumber that can check the $phone is (valid/invalid) and it can loading area code …etc
Yes, you haven’t really asked anything there. The idea of the forum is that you try to get it working, and if you run into trouble, come along and ask specific questions to find out why it’s not working. At the moment, you’ve said roughly what you want to do, but don’t seem to have done any of the work. Are there any samples you can run through from the provider of the library, to get you started?
Also, there’s a typo on this line:
<form action="welcome.php" method="$_POST">
And this section of code:
won’t execute because you’ve already sent output to the browser. You should be getting a “headers already sent” error when you try to run this.
And another minor typo:
<input type="text" name="$phone" placeholder="Enter your phone number">
Hint: You’re mixing up PHP variable names and html attributes in these two typos.
Before thinking about making the form submission work, get the form right first, there are a few mistakes that stand out immediately.
When you set the methos to post in HTML you don’t use the PHP global, just post:-
<form action="welcome.php" method="post">
Likewise on your input, it is HTML, not PHP so you don’t use a PHP variable there.
<input type="tel" name="phone" placeholder="Enter your phone number">
You can also use the tel input type in HTML5 for phone numbers.
Where you have a label for an input you should assign the label to the input with the for attribute with a value matching the input id attribute value.
<label for="phone">Enter your phone</label>
<input type="tel" name="phone" id="phone" placeholder="Enter your phone number">
Lastly this makes no sense here.
You can’t send headers after there has been any output to the browser. There is no need to forward the user to the welcome.php page, as you already have that as your form action.
Again some confusion. If test.php is parsing the form, it should be in the form’s action attribute.
But if welcome.php is supposed to be the action, the same file that the form is in, then you can leave the action blank or enter # for it.
Some of the form parsing php doesn’t make sense either, but one step at a time, get the form right first.