![]() |
|
#1
|
|||
|
|||
storing html from a formOK so I have a lil problem storing html code in a textfile.
This is the form used to get the $page and $newtext variables. <form action="edtext.php" method="get"> <b>Page:</b><input type="text" name="page"><br> <b>Text:</b><textarea name="newtext">Add content here</textarea><br> <input type="submit" value="send"> </form> Now within the edtext.php file, the $page is for the textfile you want to add the $newtext to. This is all good it works quite fine, but a problem exists when a lot of code is entered. IE the $page and $newtext data is transferred as so: edtext.php?page=home;newtext=%3C%21--+Nav+Table+--%3E%0D%0A%3Ctable+border%3D%5C%5C%5C%220%5C%5C%5C% 22+cellPadd etc etc etc. So not all text within the $newtext textarea in the form is sent to the php script. And the text that is sent is further edited IE it would convert this text: <table border="0"> to this text: <table border=\"0\"> etc So how can I send large amounts of (unedited) text to a php script from a form in a html doc? Pls help thanx |
|||
|
#2
|
||||
|
||||
|
Use POST (instead of GET) method in your form?
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#3
|
|||
|
|||
|
Quote:
Firstly the text that is sent throught the form is limited. Is there a way I can assign the amount of characters sent, maybe in the <textarea> field of the form? I donno. Secondly the html text that is sent is being edited to work with php and I have no idea why. Surely the data should be sent as is I donno why this is happening. IE: <table border="0"> (entered in the textarea) would be edited to <table border=\"0\"> why is this? |
|
#4
|
||||
|
||||
|
This has to do with your php.ini setting for magic_quotes_gpc. If it's set to TRUE/ON/1, then all ' (single-quote), " (double quote), \ (backslash) and NUL's (in user-inputted data off GET/POST/COOKIE) are escaped with a backslash automatically.
If you need to display these 'values' on a web page, then simply pass the data through stripslashes e.g. PHP Code:
About limiting the characters submitted via a textarea, I don't know how to do this but I think it's impossible. However, you can do this client-side (i.e. with JavaScript) or server-side with e.g. PHP's substr() function. __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#5
|
|||
|
|||
|
I see. So can I save the html retrieved from the form as follows?
PHP Code:
Will that work now? Peace |
|
#6
|
||||
|
||||
|
Yes, that should work (considering your 'write' script works well).... I am sure you've tested it already.
You have a choice whether to pass the data via htmlentities before you store the data in a textfile or just before you display the data - you know that, right? __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#7
|
|||
|
|||
|
Quote:
Hmmm...isn't this what I have done in my previous post? The html text is stored in a string variable called $newtext, from a textarea. Then in the script, if $newtext is defined, then strip it back down using htmlentities and then store it in the textfile. I am still having problems with limited characters being sent from the textarea. Pls tell me more about PHP's substr() function and how i can use it? |
|
#8
|
||||
|
||||
|
An example string off $_POST['newtext'] could be;
<b>This is in "bold"</b>. right? With htmlentities( stripslashes($_POST['newtext']), ENT_QUOTES ), that string is converted to: <b>This is in "bold"</b>. About substr(), let's assume you only want to allow a user to submit up to 255 characters via $_POST['newtext'], your form-processing script can then ensure that it so simply by adding this line inside the script, before doing anything else: PHP Code:
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
Recent GIDBlog
Programming ebook direct download available by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help with form | orbitel | MySQL / PHP Forum | 11 | 21-Jan-2004 16:29 |
| Why doesnt my form work correctly? | rhino1616 | Web Design Forum | 2 | 06-Nov-2003 18:21 |
| simple form from generated page | zuzupus | Web Design Forum | 0 | 17-Sep-2003 10:27 |
| validate form | skyloon | MySQL / PHP Forum | 3 | 15-Jul-2003 10:04 |
| [class] Generate Forms Without Using HTML! | Elmseeker | PHP Code Library | 6 | 11-Mar-2003 13:05 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The