Jump to content

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


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 ?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.