Welcome to WebmasterWorld Guest from 54.145.44.134

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Loading A Web Page Via PHP

     

mhoctober

8:37 pm on Jan 16, 2006 (gmt 0)

5+ Year Member



I'd like to find out if its possible to simply load a webpage in PHP.

I'm presenting users with an input box and asking for a ref number. The submit button loads a php file which searches the database for the ref nunber. If its founds I'd like the PHP code to then go extract a web url from the database and load that page.

I can do all the searching bits but have yet to found out how I can get php to load a page if the ref number is found in the db.

Many thanks

mhoctober

8:38 pm on Jan 16, 2006 (gmt 0)

5+ Year Member



Just to clarify..

I ONLY need to know how to write code to load a page. I can do all the rest db stuff!

Many thanks

vBMechanic

8:45 pm on Jan 16, 2006 (gmt 0)

10+ Year Member



$var = file_get_contents($URL)
or
cURL library

LeChuck

8:47 pm on Jan 16, 2006 (gmt 0)

5+ Year Member



Or did you mean something like this? You need output buffering on if you're printing stuff before this.

header("HTTP/1.1 301 Moved Permanently");
header("Location: $your_url");

mhoctober

12:38 am on Jan 17, 2006 (gmt 0)

5+ Year Member



I simply need to know how to call a PHP file that has the following logic in it...

If the user enter 'A' in a box and clicked the Submit button take them to the following page

www.anyoldsite.com/theychosea.htm

However if they put 'B' in abox and click the submit button take them to the following page

www.anyoldsite.com/theychoseb.htm

I know how towork the logic and the forms part - just dont know how to get php to issue commands that loads one particular page from a site or another.

Many thanks ....

jamesa

1:53 pm on Jan 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What LeChuck said. Example:

<?

// NOTE: Don't echo anything to the screen before
// the header function.

if ($userInput == 'A') {

header("Location: ht*p://www.anyoldsite.com/theychosea.htm");

}

?>

FYI that'll do a 302 redirect. If you want a 301 add the bit LeChuck mentioned above.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month