Hack Forums
[PHP] Generating a new HTML page with a PHP script with PHP inside - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183)
+---- Thread: [PHP] Generating a new HTML page with a PHP script with PHP inside (/showthread.php?tid=2743000)



Generating a new HTML page with a PHP script with PHP inside - stuped200 - Aug 3, 2012

Yea quite complicated eh? :(

I have a form (let's say it's called index.html) which goes to main.php, from there it takes the info put into index.html (the person's email for example) and then creates a new page with the info.

The problem I'm having is how to make it actually make a new page with PHP inside. Basically, I need it to be able to write variables inside the file, but it keeps trying to locate the variable inside the script used to make it in the first place.. Help please <3

EDIT:

an example of what's happening; I use this in main.php to specify what I want inside the file:

Code
$content = "<?php \n $example = "example"; \n ?>";

Then that would show inside the newly created file with blanks where the variable $example would be D:


Solved! fillerfillerfillerfillerfillerfiller


* - Tom` - Aug 3, 2012

You cannot execute PHP inside a .html document, that may be your issue. As for the variables not being found, You'll have to use the post/get function.


* - J033 - Aug 3, 2012

If you still need help, add my Skype: RATRage

Or just PM me


* - система - Aug 4, 2012

(Aug 3, 2012 07:13 PM)I Play Heaps Wrote:  You cannot execute PHP inside a .html document, that may be your issue. As for the variables not being found, You'll have to use the post/get function.

You can use .Htaccess to show a .php file as a .html file with the following code:

Code
Options +FollowSymLinks +Indexes
RewriteEngine on
RewriteBase /
RewriteRule ^([^.]+)\.html$ $1.php [L]



* - tinkerman2000 - Aug 4, 2012

(Aug 3, 2012 07:13 PM)I Play Heaps Wrote:  You cannot execute PHP inside a .html document, that may be your issue. As for the variables not being found, You'll have to use the post/get function.

You actually can do this but you need to setup PHP to do so since it's not down by default.


* - stuped200 - Aug 4, 2012

You CAN do it by doing <?php The script here ?> ~.~

EDIT: btw I solved this yesterday, just added a backslash like so:

\$example