Page 1 of 1

Problem with String in html Form

Posted: Tue Aug 08, 2006 8:48 am
by ityd
Given a simple form:

Code: Select all

<form method="post" action="getMessage.php">
        <input type="text" name="message">
        <input type="submit" value="Submit">
    </form>
and the getMessage.php:

Code: Select all

<?php 
$message=$_POST['message'];
echo $message;
?>
Sampe Input: It's David's "Dog"

Sample Output: It\'s David\'s \"Dog\"

Why are the the quote being represented this way?
Is everyone's server like this? Or is this just the way my server is configured?

Thanks.

Sorry it seems I might have posted this is the wrong topic. Sorry in advance.

Posted: Tue Aug 08, 2006 9:00 am
by jayshields
Is magic quotes on? If so, there are numerous ways to combat it, search this forum or the PHP website.

Posted: Tue Aug 08, 2006 10:41 am
by ityd
Thanks for the reply. Is there any special characters I could use to represent the quotes, so as to bypass magic quotes all together?

Posted: Tue Aug 08, 2006 10:45 am
by feyd
Handle the quotes properly and you'll be fine. Don't band-aid it.

get_magic_quotes_gpc() and/or get_magic_quotes_runtime() can be used in combination with stripslashes(). It's not that difficult.

Posted: Tue Aug 08, 2006 10:49 am
by ityd
lol ok thanks for you help