Tech Support Guy banner
Status
Not open for further replies.
1 - 3 of 3 Posts

· Registered
Joined
·
648 Posts
Discussion Starter · #1 ·
The title isn't very descriptive, or accurate, so I will try to explain.

I'm not all that good at PHP so i'm trying to do things with the limited skill/knowledge I have.

I've created a file called directorate.php and I am trying to write both HTML AND user entered values to it. I have included the file on a page so the idea is for the Directors/CEO to be able to post notes. I will post some code to hopefully make more sense...

PHP:
<?
$fn = "/home/vortex/public_html/news/bullet/directorate.php";

$title = stripslashes($_POST['mtitle']);
$body = stripslashes($_POST['mbody']);
$fp = fopen($fn,"r+") or die ("Error opening file in write mode!");

$htmlstart = "[TABLE][TR]\n[TD][IMG]img/lb_dec.jpg[/IMG][/TD] [TD]\n";

$htmlmiddle = "[/TD][TD]

[/TD][/TR][/TABLE]\n[TABLE]\n[TR][TD]
[TABLE][TR][TD]

";

$htmlend = "

[/TD][/TR][/TABLE]
[/TD][/TR][/TABLE]";

fwrite($fp, $htmlstart + $title + $htmlmiddle + $body + $htmlend);

fclose($fp) or die ("Error closing file!");
echo "";
echo "\n";
?>
In my view, which is probably wrong, this says "Write > HTML Start > User entered title > HTML Middle > User entered body (message) > HTML end.

It doesn't work and brings up junk characters and doesn't add all the HTML.

What's a better (or working) way to add HTML + User values to a document?

Thanks in advance
 

· Registered
Joined
·
6,956 Posts
1) you should use '.' instead of '+' between stringed variables.
2) try echoing the full string(echo $htmlstart.$title.$htmlmiddle.$body.$htmlend;), just to make sure that the string its going to write with is what you want before it gets written. This will help figure out where the problem is occurring.
 
1 - 3 of 3 Posts
Status
Not open for further replies.
Top