homepage Welcome to WebmasterWorld Guest from 54.161.246.212
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
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

5+ Year Member



 
Msg#: 11399 posted 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

5+ Year Member



 
Msg#: 11399 posted 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

10+ Year Member



 
Msg#: 11399 posted 8:45 pm on Jan 16, 2006 (gmt 0)

$var = file_get_contents($URL)
or
cURL library

LeChuck

5+ Year Member



 
Msg#: 11399 posted 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

5+ Year Member



 
Msg#: 11399 posted 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

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 11399 posted 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.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved