Computing.Net > Forums > Web Development > post HTML page in PHP

post HTML page in PHP

Reply to Message Icon

Original Message
Name: chrisjasp
Date: May 5, 2005 at 21:56:41 Pacific
Subject: post HTML page in PHP
OS: mandriva
CPU/Ram: 1.3
Comment:

It's been a while since i've used PHP. How can i display a specific html page in a case statement. Basically i have a form with radio buttons on it and from each radio selectoin when they click the submit button i want it to display a different HTML page depending on wich radio button was selected. I know how to do everything up to the point that you tell it to launch that HTML page.
I know how to do it by putting the html code in the php code but i was wondering if i could keep the code in seperate files. One html and one php.

Any help would be great.

C


Report Offensive Message For Removal


Response Number 1
Name: Michael J (by mjdamato)
Date: May 5, 2005 at 22:29:56 Pacific
Reply: (edit)

Since you are wanting to open an HTML page and not a PHP page I am assuming you are not passing any form data to it. If that is the case you do not need to use PHP at all. A little javascript will do the trick.

Have the onSubmit of the form run a function with something like this.

function submitForm() {
var df = document.formname.radiofieldname

if (df[0].checked) (window.loaction=page1.html)
if (df[1].checked) (window.loaction=page2.html)

etc...
}

If you still wanted to do it solely in PHP, I think you would need to create an interim PHP page that retrieves the value of the radio button and then redirects to the correct html page. This might create a double-clicking sound (at least in IE) or a page-flash. Should be easy to test.

The interim page could look something like this (use the html page name as the value for each radio button option):

if ($_POST['radioBtnName']) {
$pageValue = $_POST['radioBtnName'];
Header("Location: ".pageValue);
else {
//Put error handling here
}

Michael J


Report Offensive Follow Up For Removal

Response Number 2
Name: FBI Agent
Date: May 6, 2005 at 06:11:43 Pacific
Reply: (edit)

use the include function
<?php
include_once("YOUR HTML FILE.html")
?>

FBI Agent

AIM: EliteAssassin187


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: post HTML page in PHP

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge