I have created a form that has a name and email address input.
Name: John Smith
Email: johnsmith@example.com
What I want to do is split the name in to first name and surname from the posted.
How would I go about doing this?
I have created a form that has a name and email address input.
Name: John Smith
Email: johnsmith@example.com
What I want to do is split the name in to first name and surname from the posted.
How would I go about doing this?
Assuming you are escaping user input and there is a validation to add space between name.
If that is already not implemented you could implement them otherwise consider to use separate input box for both first name and last name.
$name=explode(" ",$_POST['name']);
echo $name[0]; //first name
echo $name[1];// last name