Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-07-2010, 05:32 PM   PM User | #1
Skippy
New Coder

 
Join Date: Jul 2009
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Skippy is an unknown quantity at this point
htmlentities help

I'm building a little script for myself where it'll get the html from a file so it can be edited.

This is my code:
PHP Code:
<?php
    
echo "<form name=\"myform\" action=\"\" method=\"POST\">";
    echo 
"<textarea rows=\"20\" cols=\"50\>";

    
$str=htmlentities(file_get_contents('otherheader.php'));
    echo 
$str;

    echo 
"</textarea>";
    echo 
"<input type=\"submit\" value=\"Submit\">";
    echo 
"</form>";
?>
When I take away the form bit it works however when I put the form part in it just returns </form> within the text area. How can I stop this?

Thanks.
Skippy is offline   Reply With Quote
Old 01-07-2010, 06:23 PM   PM User | #2
sir.jones
New Coder

 
Join Date: Dec 2009
Posts: 84
Thanks: 6
Thanked 3 Times in 3 Posts
sir.jones is an unknown quantity at this point
go and appropriate to http://php.net/manual/en/function.htmlentities.php
sir.jones is offline   Reply With Quote
Old 01-07-2010, 06:58 PM   PM User | #3
sir.jones
New Coder

 
Join Date: Dec 2009
Posts: 84
Thanks: 6
Thanked 3 Times in 3 Posts
sir.jones is an unknown quantity at this point
Quote:
Originally Posted by Skippy View Post

When I take away the form bit it works however when I put the form part in it just returns </form> within the text area. How can I stop this?

Thanks.
Your Code change to:

<form name="myform" action="" method="POST">
<textarea rows="20" cols="50">
PHP Code:
<?php
//$charse='UTF-8';
//$str=stripcslashes($str);
$str=file_get_contents('yourpage.html/.php/.chm/.txt');
echo 
htmlentities($str);
//echo htmlentities($str, ENT_COMPAT, $charset);
?>
</textarea>
<input type="submit" value="Submit">
</form>


Regards

Last edited by sir.jones; 01-07-2010 at 07:11 PM..
sir.jones is offline   Reply With Quote
Old 01-07-2010, 08:15 PM   PM User | #4
bazz
Master Coder

 
Join Date: Apr 2003
Location: in my house
Posts: 5,211
Thanks: 39
Thanked 201 Times in 197 Posts
bazz will become famous soon enoughbazz will become famous soon enough
@skippy;
Whether your code was fundamenatlly OK, I don;t know but you missed off your closing " on line 2 in your OP.

Code:
 echo "<textarea rows=\"20\" cols=\"50\>";
should have been

Code:
 echo "<textarea rows=\"20\" cols=\"50\">";
I would try sir.jones code though since it seems to make more sense to me.

bazz
__________________
"The day you stop learning is the day you become obsolete"! - my late Dad.

Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
Useful MySQL resource
Useful MySQL link
bazz is offline   Reply With Quote
Old 01-07-2010, 09:01 PM   PM User | #5
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Bazz is right. Fix your php.
PHP Code:
echo "<textarea rows=\"20\" cols=\"50\">"
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 01-07-2010, 10:57 PM   PM User | #6
sir.jones
New Coder

 
Join Date: Dec 2009
Posts: 84
Thanks: 6
Thanked 3 Times in 3 Posts
sir.jones is an unknown quantity at this point
From 1st time i look Skype code i kown him/her missed close with " at cols=\"50\" but my code model able to avoid it.

that's mean someone save his/her time if work with thousand html tags line
sir.jones is offline   Reply With Quote
Old 01-07-2010, 10:57 PM   PM User | #7
sir.jones
New Coder

 
Join Date: Dec 2009
Posts: 84
Thanks: 6
Thanked 3 Times in 3 Posts
sir.jones is an unknown quantity at this point
From 1st time i look Skippy code i kown him/her missed close with " at cols=\"50\" but my code model able to avoid it.

that's mean someone save his/her time if work with thousand html tags line
sir.jones is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:36 AM.


Advertisement
Log in to turn off these ads.