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
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
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
Share on other sites

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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.