homepage Welcome to WebmasterWorld Guest from 184.73.87.85
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Loading A Web Page Via PHP
mhoctober




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

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




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

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




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

$var = file_get_contents($URL)
or
cURL library

LeChuck




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

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




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

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




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved