Jump to content

[SOLVED] Passing values from one PHP file to another through the URL


Recommended Posts

Hi there,

 

I recently came across a problem that I couldn't solve. This is not surprising as I am not that good in PHP, so please bear with me if this sounds dumb.

 

I have written two scripts: one which takes information from a form a user fills in (mailform.php), and one which inserts a matching user into a PHPBB forum database (insertuser.php). The two scripts need to be in completely different directories.

 

I am trying to get the mailform.php script to pass values to the insertuser.php script. From what I have read the easiest way to do this would be to pass them in the URL. So when I tried this:

 

header( "Location:http://www.website.com/forum/insertuser.php?username=helloworld&password=helloworld&[email protected]" );

 

I got this error message:

 

Warning: Cannot modify header information - headers already sent by... (etc)

 

I know that changing the page location using the header works, is it simply a matter of that I am not escaping my characters properly? Or can I not pass variables through the header location? Or am I doing something else horribly wrong?

 

To be honest I'm not even sure this is the best way to do it. Like I say, I'm pretty amateurish with this stuff, so if there's an easier way to get PHP to pass values around between directories like this I'd be interested to know what it is. (Also, I know this isn't a secure way of adding new users, but this is a closed internal environment I'm developing for and security is not an issue at the moment.)

 

Thanks very much everyone, I really appreciate any thoughts.

 

Hrmm I'm not sure what else I can add. I have already used the relevant code snippets.

 

The two scripts work fine on their own when I test them directly. The problem is passing the code between them.

 

If you could point out what you are not clear on I will be happy to try and expand my problem?

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.