tags:

views:

116

answers:

6

I will do my best to explain my situation and what I have done so far. I am new to php and have tried to learn everything from the net and the forums, but now I must post in one.

I have a form that is comprised of two pages input.html and output.php. The user completes the form (input.html) and submits it. They are presented with a finished product on their screen (output.php). I have it so a file is created with a unique .html name. The goal is to then email a recipient list with the link to this file on the server.

The problem is, I wanted the unique file to contain the output.php page with the user data and all I am getting is the php code along with simple html text.

Thanks in advance

A: 

Check that your web server is correctly set up to parse PHP pages -- the client should never see your PHP code.

Make sure your HTML form is directing the form data to the correct script, the action parameter tells the broswer where to send the data, as in:

<FORM method="POST" action="output.php">
</FORM>

Hopefully this helps; if not post a little more detail and I am sure someone can assist.

JYelton
he said the html form is directing to the correct script because it shows the finished product on the screen.
Good Time Tribe
I have the <form> tags set correctly. What was being displayed on the screen to the user (output.php) was correct, but what was being written into the unique.html was the php code of the output.php page.
A: 

Are you saying that you wish to save the content of the output.php page into the unique.html file as well?

If so you can do this, at output.php:

<?php
ob_start();

// all your logic and code for displaying

$output = ob_get_contents();
file_put_contents($uniquehtml,$output); // save output page to the html file
?>
thephpdeveloper
Mauris, thank you so much. You and Bobby nailed it!
A: 

You can buffer the output. I dont remember the exact syntax.. its been a long time. But I am sure you can google it out if the syntax below dowsnt work:

ob_start();
$theoutput = ob_get_contents();
ob_end_flush();

if ($filehandle = fopen("uniquefile.htm­", "w")) {
fwrite($filehandle, $theoutput);
}
Bobby Alexander
Bobby, thank you so much. You and Mauris nailed it!
A: 

please provide a little details about your problem.

Tareq
This should be a comment to original question, not an answer
n1313
A: 

It sounds like the server hasn't been set up to parse PHP yet.

Assuming you are using Apache, type this into a file:

<?php phpinfo(); ?>

And save it to a file called info.php (though you could name it anything) in your web root. By default (on windows) it will be c:\program files\apache\htdocs or something like that. Now access your file via the webserver by visiting http://localhost/info.php.

Note that you must access your PHP files this way, not by just double-clicking on a file on your computer (which will open file:///C:/myfile.html or something)

If you see this in your browser:

<?php phpinfo(); ?>

Then the file isn't being parsed by PHP. Read up on the installation documentation for Apache and PHP again, remembering that you'll probably have to restart the apache service after each change to its configuration.

If you see a big page listing a heap of configuration settings, then that's good! It means that PHP is working. Let us know if this is the case, so we can continue to help from there.

nickf
+1  A: 

First off, everyone who think that apache isnt setup to parse the PHP and has wasted great effort in trying to prove and reoslve that, go back to the second paragraph where he clearly states "They are presented with a finished product on their screen (output.php)" and notice that it's processed the PHP fine on his form and sent the e-mail. PHP is obviously working correctly.

Without seeing any code, what I am able to identify as the issue here is you are emailing the output.php file and not the new unique .html file.

The next steps to get you on the right path to a solution will be to answer these questions:

  1. Is the new unique .html file being created properly? (you never mentioned a file name for it)
  2. When inspected, are the contents of it as expected? (not your output.php, you already said you don't want that, so don't look at output.php)
  3. If so, what is the Path/URL to this new unique file and how does it compare to what you are using to the Path/URL for the e-mail?
Good Time Tribe
GTT,Thank you. You were correct about Apache/PHP being setup and working. (1) Yes, the dynamic page was presented to them and the unique.html file was being created. (2) The problem was that the unique.html page was actually the php code of the output.php.When I looked into the suggested ob_start() statement and tried it, I got my desired result, at least the first part of it.I will now work through setting up the email portion of this little project. Thanks for your help. I will continue to read and learn from all of you.
+1 for having better luck figuring this out, I have been unable to follow up for a few days
JYelton
George, for help with the e-mail, I was very satisfied with PHPmailer using gmail's SMTP.
Good Time Tribe