Each time I enter a name with an Apostrophy ikeep getting
backslashes eg O'keeffe becomes O/'keeffe
Here is a sample of the code what I'm using
// Function for escaping and trimming form data.
function escape_data ($data)
{
global $dbc;
if (ini_get('magic_quotes_gpc'))
{
$data = stripslashes($data);
}
return mysql_real_escape_string (trim ($data), $dbc);
} // End of escape_data() function
// Validation Code
// Check for a username
if (eregi ("^[[:alnum:]_]{4,20}$", stripslashes(trim($_POST['username']))))
{
$u = escape_data($_POST['username']);
}
else
{
$u = FALSE;
echo '<p class="validation">Please enter a valid username!</p>';
}
// Form Code
<tr>
<td colspan="2" class="labelcell"><label for = "username">1. Username</label></td>
<td colspan="2" class="fieldcell"><input type="text" name="username" size="20" maxlength="20"
value="<?php if(isset($_POST['username'])) echo $_POST['username'];?>"/>
</td>
</tr>
What am I doing wrong trying to fix it for the last 3 weeks
driving me crazy.
Tks
Gaz
backslashes eg O'keeffe becomes O/'keeffe
Here is a sample of the code what I'm using
// Function for escaping and trimming form data.
function escape_data ($data)
{
global $dbc;
if (ini_get('magic_quotes_gpc'))
{
$data = stripslashes($data);
}
return mysql_real_escape_string (trim ($data), $dbc);
} // End of escape_data() function
// Validation Code
// Check for a username
if (eregi ("^[[:alnum:]_]{4,20}$", stripslashes(trim($_POST['username']))))
{
$u = escape_data($_POST['username']);
}
else
{
$u = FALSE;
echo '<p class="validation">Please enter a valid username!</p>';
}
// Form Code
<tr>
<td colspan="2" class="labelcell"><label for = "username">1. Username</label></td>
<td colspan="2" class="fieldcell"><input type="text" name="username" size="20" maxlength="20"
value="<?php if(isset($_POST['username'])) echo $_POST['username'];?>"/>
</td>
</tr>
What am I doing wrong trying to fix it for the last 3 weeks
driving me crazy.
Tks
Gaz