I am trying this.
$fullname=mysqli_real_escape_string($connect,filter_var($_POST["fullname"],FILTER_SANITIZE_STRING));
If I enter John O'Brien
The variable $fullname = John O'Brien
I have a regex as shown below which allows the apostrophe through and saves it in the format as shown below in the table in the database which is ideal.
John O'Brien
The regex I am using is
If(!preg_match('/^[a-z .\-']+$/i', $fullname)
Now the above regex works to a point, it will lets numbers through, it should not. If I were to add the number 4 as an example to the end of the name as shown below this is accepted and is let through.
The variable $fullname = John O'Brien4
Saving the apostrophe in a safe format in the database is important and being able to retrieve the name from the table and display it on the webpage with the apostrophe. Perhaps there is a simpler way to approach my problem! Any help much appreciated.