Forum Moderators: coopster
Whenever the data contains an apostrophe, whatever is after the apostrophe disappears.
I've played around with addslashes() and stripslashes() but no luck.
input: Bob O'reilly
if(isset($_POST['form1']))
{
$lastname=($_POST['lastname']);
}print "<form action='$php_self'>";
print "<input type='text' name='lastname' value='$lastname' />";
print "<input type='submit' name='form1' />";
print "</form>";output: Bob O\
if(isset($_POST['form1']))
{
$lastname=($_POST['lastname']);
}print "<form action='$php_self'>";
print "<input type='text' name='lastname' value='".stripslashes($lastname)."' />";
print "<input type='submit' name='form1' />";
print "</form>";output: Bob O
I'm not sure why, but I still have to stripslashes() on display to make it work.
input: Bob O'reilly
if(isset($_POST['form1']))
{
$lastname=htmlentities($_POST['lastname'], ENT_QUOTES);
}print "<form action='$php_self'>";
print "<input type='text' name='lastname' value='".stripslashes($lastname)."' />";
print "<input type='submit' name='form1' />";
print "</form>";output: Bob O'reilly
Now I'm trying to validate the input to characters found in a name besides letters, such as ' and - but the apostrophe is not validating.
((eregi('^[a-zA-Z \'-]{1,50}$', $lastname))