ibuprofen Posted December 18, 2008 Share Posted December 18, 2008 When creating sticky forms, I can get one textfield to work with apostrophes and another to work with double quotes, but neither of them works with both. Below is the script I wrote to illustrate the problem. The first script is the form, the second script echos the output on another page. The output page just links back to the first at which time the problem occurs. Any ideas on how to get a field to accept both apostrophes and double quotes? ----------------------------- First script: ----------------------------- <body> Sticky Forms: <form action="materialPreview2.php" method="post" name="enterName" target="_self" id="enterName"> <p>This will retain double quotes, but NOT apostrophes. Try it: <input name="firstTextField" type="text" value='<?php echo @$_POST['firstTextField']; ?>'> </p> <p>This will retain apostrophes, but NOT double quotes. Try it: <input name="secondTextField" type="text" value="<?php echo @$_POST['secondTextField']; ?>"> </p> <p> <input name="insert" type="submit" id="insert" value=" Insert "> </p> </form> </body> ----------------------------- Second script: ----------------------------- <body> <?php $myVar = $_POST["firstTextField"]; $myVar2 = $_POST["secondTextField"]; echo "Is " . $myVar . " and " . $myVar2 . " really what you want to stick?"; echo "<br>"; ?> <form name="form1" method="post" action="materialInput2.php"> <input type="hidden" name="firstTextField" value='<?php echo $myVar; ?>'> <input type="hidden" name="secondTextField" value="<?php echo $myVar2; ?>"> <input type="submit" name="button2" id="button2" value=" Edit "> </form> </body> Quote Link to comment https://forums.phpfreaks.com/topic/137490-sticky-forms/ Share on other sites More sharing options...
sKunKbad Posted December 18, 2008 Share Posted December 18, 2008 you could add slashes with addslashes() Quote Link to comment https://forums.phpfreaks.com/topic/137490-sticky-forms/#findComment-718535 Share on other sites More sharing options...
ibuprofen Posted December 18, 2008 Author Share Posted December 18, 2008 I tried addslashes(), no luck. I've come to the conclusion textboxes in PHP are not compatible with both apostrophes and double quotes. It must be one or the other. Quote Link to comment https://forums.phpfreaks.com/topic/137490-sticky-forms/#findComment-718564 Share on other sites More sharing options...
PFMaBiSmAd Posted December 18, 2008 Share Posted December 18, 2008 Quotes and any other characters that have meaning in HTML are rendered by the browser and affect what and how it displays information. If you do a "view source" of your pages in your browser, you will see that all the content is there. To output content to a browser that contains characters that have special meaning in HTML, use htmlentities Quote Link to comment https://forums.phpfreaks.com/topic/137490-sticky-forms/#findComment-718570 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.