Jump to content

Include url with variable


petenaylor

Recommended Posts

Hi all

 

I am writing a code to update customer details. It all works great until I get to the last line of code that directs the user to the next page:

 

include ('profile-success.php');

 

I need it to be the following page:

 

profile-success.php?username=$username

 

Can anyone show me how to edit the line to include the url variable?

 

I keep getting this error:

 

Warning: include() [function.include]: Failed opening 'profile-success.php?username=$username' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/cndvizp/public_html/prints2impress.co.uk/upload/update-profile.php on line 96

 

Thanks

Pete.

Link to comment
https://forums.phpfreaks.com/topic/211294-include-url-with-variable/
Share on other sites

Hi sorry the file is called update-success.php

 

I now get the error:

 

 

Warning: include(update-success.php?username=petenaylor) [function.include]: failed to open stream: No such file or directory in /home/cndvizp/public_html/prints2impress.co.uk/upload/update-profile.php on line 94

 

Warning: include(update-success.php?username=petenaylor) [function.include]: failed to open stream: No such file or directory in /home/cndvizp/public_html/prints2impress.co.uk/upload/update-profile.php on line 94

 

Warning: include() [function.include]: Failed opening 'update-success.php?username=petenaylor' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/cndvizp/public_html/prints2impress.co.uk/upload/update-profile.php on line 94

 

 

The file update-success.php if definitely on the server because if i type update-success.php?username=petenaylor into the address bar it works OK?

 

Cheers for your help

include cannot parse stand-alone files. when you write

include ('profile-success.php?username=$username');

it'll search for a file called "profile-success.php?username=$username" which obviously doesn't exist.

 

Instead you could try

include ('http://www.yourwebsite.com/profile-success.php?username=$username');

 

But the best thing for me is, assigning variables first, then call the page, will serve the same objective

$_GET['username'] = $username;
include ('profile-success.php');

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.