Jump to content

Recommended Posts

<?php

#check to see if the submit button has been pressed.
if (isset($_POST['submit'])) {
#if so then output staff number is ... then the value of the textbox sent via post variable
echo "Your stff number is..." . $_POST['staff_no'];

} else {
#if the submit button hasn't been pressed then display the form for the user
echo "<form name=\"Form1\" method=\"POST\" action=$_SERVER['PHP_SELF']>
Staff Number: <input type=text name=staff_no><br>
<input type=submit name=submit value=submit>
</form>";

}

?>

use mysql to query your database where stuff_no = employees_name

 

then create a hidden field in your form and just echo the variable out for your employees name.

 

something like:

 

<?php

// connect to db
// select db
$mystaff = $_POST['staff_no'];
$results = mysql_query("select employee_name from tblName where staff_no='$mystaff'");

while ($mychoice=mysql_fetch_array($results)) {

$employee=$mychoice["employee_name"];

echo "<form name=\"Form1\" action=\"". $_SERVER['PHP_SELF'] ."\">
Staff Number: <input type=text name=staff_no><br>
<input type=\"hidden\" value=\"$employee\" name=\"currentemployee\">
<input type=submit name=submit value=submit>
</form>";

}

?>

well you have to have the employee enter the number some how - if your not using a form for them to enter their employee number in; then how are they entering it?

 

what i want is when user enter their staff no

 

if your using a link with each employees name in them and a predefine employee number in the link; the just change $_POST to $_GET.

 

$mystaff = $_POST['staff_no'];

 

Link To Employee Form

<a href="employeeform.php?staff_no=123">John Doe</a>

I think if im correct you mean that you want it so when ever they type their staff number in

 

 

54 for example it will display the name of that staff member before they press the button. This would need abit of javascript as it is classed as clientside, unless u used abit of ajax.

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.