PHP question :)

paruhd0x

Diamond Member
Apr 2, 2000
3,100
0
0
Well, I am pretty novice at PHP, but I am asking here since I couldn't find my answer from friends/book/or google.

What I am trying to do is I have a page that posts data into some snazzy template. Then have a form button at the bottom of that page post the html code including the printed stuff from the previous form submit to another page in pre tags so someone could easily highlight and copy and paste the code.

I've tried several different ways, and I cannot seem to get it to work. Any help is appreciated.
 

Tetsuo

Lifer
Oct 20, 2002
10,904
0
71
Try looking around hotscripts.com. most of the php I learned was by dissecting other peoples code
 

mugs

Lifer
Apr 29, 2003
48,903
19
81
Uh... can't think of any way to help you short of writing it myself. E-mail the template to me and I'll give it a shot (e-mail address is in profile).

Edit: I'm not sure the pre tag does what you want it to. Look up the function htmlspecialchars() on php.net, that does what you want.
 

Ness

Diamond Member
Jul 10, 2002
5,407
2
0
The simplest way to do this might be to make the php create a file, then call that file on the next page...

Work out some psuedo-code and outlining first and it may better help describe your situation.


-use forms to gather data
-use php functions to format data
-write formatted data to a file
-move to next page

*next page loads*

-form text box is displayed
--temp file from previous page is called via php
--contents of temp file displayed in form text box
-contents can be copied pasted into next document at user's will


Is that what you are looking for?

 

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
Ok I am not quite surei understand your question, but here goes.
<!-- Page one -->
<html>
<head>
<title>Page One</title>
</head>
<body>
Enter info to fill in template.
<form method="post" action="post.php">
Title: <input type="text" name="title">

Message: <input type="text" name="message">

</form>
</body>
</html>


<!-- Page two -->
<?php
$template = "<table><tr><td>$_POST['title']</td></tr><tr><td>$_POST['message']</td></tr></table>";

echo "
<html>
<head>
<title>Page two</title>
</head>
<body>
Here is what the template looks like:
".$template."


Here is the code for the template:

<pre>".$template."</pre>
</body>
</html>
?>

//You can put < b r > tages in there if you want...I tried to, but you cant see them cuz fusetalk treats them like HTML
 

paruhd0x

Diamond Member
Apr 2, 2000
3,100
0
0
Thanks guys, I ended up figuring it out. Thanks for your suggestions! Well appreciated.

I ended up not having to create a file, just set the inputted html + variables as a variable then in the form stuff made the hidden input value that variable and used the function htmlspecialchars() and the one that removes slashes also.
 

ASK THE COMMUNITY