Jump to content

[SOLVED] how to forward information using PHP and catch it later


weetabix

Recommended Posts

Ok, I have a form where the user will enter their ID and I want to forward this to another page where it will be checked if it's valid and display the appropriate information.

 

I created the following form

<form action="staffMenu" method="get">
<table width="42%">
<tr>
	<td width="43%">Please enter staff ID</td>
	<td width="54%"><input type = "Text" name="staffid"></td>
</tr>
<tr>
	<td colspan="2"><input type= "Submit" name="submit" value= "Submit"></td>
</tr>
</table>

 

Which I think is correct, not sure though

 

However, how am I going to refer to it from the other PHP file ? What I've been told is that it should be something like this:

 

	if(!isset($_GET['staffid'])) {
	echo "<p><strong>Error:</strong> Cannot determine staff ID.</p>\n";
	die();
}

 

Any help is appreciated.

 

Correct.

 

According to your form once you submit it, your URL will look something like this:

 

http://website.tld/staffMenu?staffid=x&submit=Submit

 

Using the $_GET method, you will define the two variables as:

 

$staffid = $_GET['staffid'];
$submit = $_GET['submit'];

 

If you want to use this for continuous use you're going to want to use sessions or cookies to pass the data throughout any other pages that you wouldn't want the user having to type the Staff ID again.

No, I only want to forward the information to the next page, so this should do

so if I use the isset command after I submit the information that's going to check if the staff id is set and if not it'll kill the connection. right ?

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.