Hi,
I have been struggling with this one for over a week now and still havent figured out whats going wrong. I have one page that allows members to upload a song, and another page that it uses as the form action page.
It has a field for Song Title and also for description. If somebody pastes Word Characters into the Song Description field like these quotes “its” , it tells them they havent entered a Song Title. The odd thing is I don't see why that error would say no Song Title because the Title is there but if the description has the characters, it seems to break the code and not make it think that there was a Song Title. Everything works fine with no msword chars involved.
I tried all of the functions found near the bottom of the html_eminities page on php.net but no go. I found this on the forum, and here is what I get:
$sdescr = str_replace("“", "\"", $sdescr);
$sdescr = str_replace("”", "\"", $sdescr);
I tested using “its” as the description, and it said I didnt enter a song title. I added this after it:
echo $sdescr;
and it echoed as normal quotes! If I remmed out the str_replace lines, it echoed with the special quotes. If I remove the quotes in the description, all works fine.
Can somebody PLEASE tell me where my code might be breaking? Thanks much.
Form Action code:
function prepIn($input) {
$input = trim($input);
if (!get_magic_quotes_gpc()) {
return addslashes($input);
}
return $input;
}
function prepOut($input) {
$input = stripslashes($input);
return htmlspecialchars($input);
}
if (isset($_POST['submit_mp3'])) {
$stitle = prepIn($_POST['stitle']);
$sdescr = prepIn($_POST['songDescr']);
$sdescr = str_replace("“", "\"", $sdescr);
$sdescr = str_replace("”", "\"", $sdescr);
$sdescr = strip_tags($sdescr);
if (!$stitle){
$error = "Sorry! You must enter a song title.<br>
$please<p>";
include ('errorinc.php');
exit();
}
elseif (!$sdescr){
$error = "Sorry! You must enter a song description.<br>
$please";
include ('errorinc.php');
exit();
}
thanks again.