Weedpacket PHP --------------------------------------------------------------------------------
ob_start();
include('file.html');
$contents=ob_get_contents();
ob_end_clean();
$contents=htmlspecialchars($contents);
echo "<textarea>$contents</textarea>";
This is an excellent code Weedpacket, but another fairly new newbie here has a question... With this code, how can one modify it to carry php variables over to the outputted HTML?
In short here is what I am doing..😃
I have an HTML page built with variables in php within the html page. Pretty basic stuff.. here is an example:
<HTML>
<HEAD>
<TITLE>Example</TITLE>
</HEAD>
<BODY>
Here is a wonderful web page<P>
See Spot Run. Spot runs <? echo "$spotrun"; ?> through the bushes.<P>
This concludes my wonderful web page<P>
</BODY>
</HTML>
Thats just a VERY simplified version of what I am doing with the HTML file.
Ok, now with the php file that works with my HTML example above would look like this
<? ?> <!-- this line is just to trick the browser into accepting a .php
extention for a file name even though the file is very much html -->
How fast does Spot run? Fill in the box below<br>
<FORM METHOD="POST" ACTION="spot2.php">
<input type="text" name="spotrun" size="10">
<P>
<INPUT type="submit" VALUE="Submit My Response">
</FORM>
<FORM METHOD="POST" ACTION="code.php">
<INPUT type="submit" VALUE="View The Code!">
</FORM>
<? ?>
Ok, with your script you have here, how would one pass along the variable without loosing what the user has typed in the form box to the output page your script generates?
With the script as it is now, it does not pass along the inputted fields, but does pass along the rest of the html.
I just don't know what to put in this cool little script you wrote to get it to pass along the inputted variable from the user.
So for an example, if someone typed in Spot runs "Fast" and you click the "Submit My Response" then right click to view source on the web page that was generated, you will see the variable passed along as if it were passed along in the html file with no php.
But when you click on "View the Code". you get the html without the variables passed.
I do appreciate any help you could give on this..
Any one else have any suggestions? I appreciate them too!!!
😃