plodos Posted March 2, 2008 Share Posted March 2, 2008 addnotices.php <form action="savenotices.php" method="post"> <textarea name="notices" cols="100" rows="10" id="notices" ><?php echo $_GET['notices'];?></textarea><br /> <input name="Submit" type="submit" value="Send"/> </form> savenotices.php <?php $notices = $_REQUEST['notices']; echo " <br> output is $notices <br> "; echo "<br><a href=\"addnotices.php?notices=$notices\"> Edit! </a> <br><br>"; ?> user will check the output of the notice, if there is a mistake user will click this link to TURN BACK <a href=\"addnotices.php?notices=$notices\"> Edit! </a> when I wrote a HTML code inside of the text area everything is mixing for example http://img219.imageshack.us/img219/938/74077155fx3.jpg, this is my form and when I click the Send button output is like that http://img219.imageshack.us/img219/5840/96262361xw8.jpg If I wrote normal sentences, sciprt is working.. Do you know why???? Whats wrong?? Also please run to your localserver, you will see the error clearly! Link to comment https://forums.phpfreaks.com/topic/93940-html-form-and-php/ Share on other sites More sharing options...
plodos Posted March 2, 2008 Author Share Posted March 2, 2008 there are only 4 lines HTML code and 3 lines PHP code.. addnotices.php?notices=AAAAAAAA aaaaaaaaaaaa AAAAAAAAAAAAA -> this is working addnotices.php?notices=http://www.phpfreaks.com -> this is working addnotices.php?notices=<a href="http://www.w3schools.com/">Visit W3Schools!</a> this is not working:) like a joke:) I didnt understand..... Link to comment https://forums.phpfreaks.com/topic/93940-html-form-and-php/#findComment-481379 Share on other sites More sharing options...
plodos Posted March 2, 2008 Author Share Posted March 2, 2008 Still I didnt solve this problem... Who will help me Link to comment https://forums.phpfreaks.com/topic/93940-html-form-and-php/#findComment-481665 Share on other sites More sharing options...
wildteen88 Posted March 2, 2008 Share Posted March 2, 2008 use urlencode when sending strings which contain special characters over the url (especially those than contain spaces) and then use urldecode when your receive them,: <form action="savenotices.php" method="post"> <textarea name="notices" cols="100" rows="10" id="notices" ><?php echo urldecode($_GET['notices']); ?></textarea><br /> <input name="Submit" type="submit" value="Send"/> </form> <?php $notices = $_POST['notices']; echo " <br> output is $notices <br> "; echo "<br><a href=\"addnotices.php?notices=" . urlencode($notices) . "\"> Edit! </a> <br><br>"; ?> Link to comment https://forums.phpfreaks.com/topic/93940-html-form-and-php/#findComment-481667 Share on other sites More sharing options...
plodos Posted March 2, 2008 Author Share Posted March 2, 2008 Still it is not working... im writing this sentence <a href="http://www.w3schools.com/">Visit W3Schools!</a> and if I click to the edit link, textarea output is <a href=\\\"http://www.w3schools.com/\\\">Visit W3Schools!</a>[code] [/code] Link to comment https://forums.phpfreaks.com/topic/93940-html-form-and-php/#findComment-481749 Share on other sites More sharing options...
wildteen88 Posted March 2, 2008 Share Posted March 2, 2008 Looks like you have magic quotes enabled, you'll need to use stripslashes: <?php if(isset($_GET['notices'])) { $notices = (get_magic_quotes_gpc()) ? stripslashes(urldecode($_GET['notices'])) : urldecode($_GET['notices']); } else { $notices = '<Enter notices>'; } ?> <form action="savenotices.php" method="post"> <textarea name="notices" cols="100" rows="10" id="notices" ><?php echo $notices; ?></textarea><br /> <input name="Submit" type="submit" value="Send"/> </form> <?php $notices = (get_magic_quotes_gpc()) ? stripslashes($_POST['notices']) : $_POST['notices']; echo ' <br> output is ' . htmlentities($notices) . '<br> <br> <a href="addnotices.php?notices=' . urlencode($notices) . '"> Edit! </a>'; ?> Link to comment https://forums.phpfreaks.com/topic/93940-html-form-and-php/#findComment-481755 Share on other sites More sharing options...
plodos Posted March 2, 2008 Author Share Posted March 2, 2008 savanotices.php <?php //echo ' <br> output is ' . htmlentities($notices) . '<br> echo ' <br> output is ' . $notices . '<br> ?> I just modfiy the output, I delete the htmlentities() function, now I see the output of the original link. I dont know how to thank you, this problem took my 2 days:) And can I ask one more question? I didnt understand your solution way? Link to comment https://forums.phpfreaks.com/topic/93940-html-form-and-php/#findComment-481785 Share on other sites More sharing options...
wildteen88 Posted March 2, 2008 Share Posted March 2, 2008 What part did you not understand? magic quotes or the urlencode / urldecode functions? Link to comment https://forums.phpfreaks.com/topic/93940-html-form-and-php/#findComment-481867 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.