Jump to content

html form and php ?


plodos

Recommended Posts

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

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

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

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

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

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.