Jump to content

Sticky Forms


ibuprofen

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/137490-sticky-forms/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/137490-sticky-forms/#findComment-718570
Share on other sites

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.