[help] PHP $_GET issues

Status
Not open for further replies.

Macemore

Circumcised pineapples
Aug 26, 2011
1,681
819
I'm trying to make is so a user enters a URL via HTML form and then the page will go and get that URL (
PHP:
include()
) but I'm 100% sure I'm doing something wrong seeing as this should be simpler. or harder I have no idea.
here's my code
index.php
HTML:
<html>
<body>
<form name="input" action="get.php" method="get">
URL: <input type="text" name="url" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
get.php
PHP:
<html>
<body>
<?php
include $_GET["url"]
?>
</body>
</html>
Please post what I did wrong :D

Thanks!
 

Macemore

Circumcised pineapples
Aug 26, 2011
1,681
819
"Warning: include(devbest.com) [ ]: failed to open stream: No such file or directory in C:\Users\sn291324\Desktop\xampp\htdocs\test\get.php on line 5

Warning: include() [ ]: Failed opening 'devbest.com' for inclusion (include_path='.;C:\Users\sn291324\Desktop\xampp\php\PEAR') in C:\Users\sn291324\Desktop\xampp\htdocs\test\get.php on line 5"
is what I get after I enter "devbest.com" on index.php and press submit
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,639
2,397
I know why, I think. You're trying to include a file, not a URL.

This is the best way I can put it:

You typed 'devbest.com' in the URL box, so to your website it's trying to include ' ', instead of ' '. To fix this, change get.php to this:

PHP:
<html>
<body>
<?php
    include( "http://www." . str_replace( "http://", "", str_replace( "www.", "", $_GET["url"] ) ) );
?>
</body>
</html>
 

Macemore

Circumcised pineapples
Aug 26, 2011
1,681
819
New error with "devbest.com"
"Warning: include() [ ]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\Users\sn291324\Desktop\xampp\htdocs\test\get.php on line 4

Warning: include( ) [ ]: failed to open stream: no suitable wrapper could be found in C:\Users\sn291324\Desktop\xampp\htdocs\test\get.php on line 4

Warning: include() [ ]: Failed opening ' ' for inclusion (include_path='.;C:\Users\sn291324\Desktop\xampp\php\PEAR') in C:\Users\sn291324\Desktop\xampp\htdocs\test\get.php on line 4"
oi ;(
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,639
2,397
Ahh, yes. You can't use include() to include external web-files.

Use this:

PHP:
<html>
<body>
<?php
    echo file_get_contents( "http://www." . str_replace( "http://", "", str_replace( "www.", "", $_GET["url"] ) ) );
?>
</body>
</html>
 
Status
Not open for further replies.

Users who are viewing this thread

Top