Jump to content

[SOLVED] Help displaying users text from an input field


coleby58

Recommended Posts

Hello everyone, sorry if and issue like this has already been solved I have looked for a while now.

 

I am designing a page on my web site where a user types in something and clicks submit and then they go to a new page where there text is displayed here is my code

 

on the page they type it:

 

<div id="inputform">

    <form method="post" action="inputform.php">

    <table width="0%">

    <tr>

        <td width="50%">

        Type a Sentence:

        </td>

        <td width="50%">

        <input width="200" type="text" name="userinput">

        </td>

    </tr>

<tr>

        <td>

        <center><input type="submit" value="submit" /></center>

        </td>

    </tr>

 

and on the page it is displayed on (inputform.php) I have:

 

<?php echo $_POST['userinput']; ?>

 

this seems to work great except say they user types "I like bob's bike"

 

the next page will display "I like bob\'s bike"

 

For some reason it places "\" before any quotes used in the users input how can I fix this?

 

Thanks! (sorry this was a long entry)

 

 

Can you run a php info script and confirm that the setting actually took?

 

Alternatively, you can change this:

<?php echo $_POST['userinput']; ?>

 

to

<?php echo stripslashes($_POST['userinput']); ?>

 

You would only do that if magic quotes gpc is turned on. So confirm if it is on or off before using that code (or you can just use it lol, but best to confirm first ;) )

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.