I have two forms - one that my co-worker built and one that I built.
When you go to his form, the cursor sits on the first text field waiting for input. When you enter a number and hit enter, the form is submitted no problems.
When you go to MY form, the cursor is not there, you have to click in the field to enter input. After you enter it and press enter, it does nothing but reload the page.
I want my form to act like it should - the cursor should sit on that first field waiting for input and once you hit enter - the form should submit.
I have tried everything from javascript to re-writing the entire script - I am getting frustrated because it is probably something obvious and stupid I am missing. Below is the script in its entirety.
NOTE: I have tried to use Javascript to solve this issue, but as you can probably guess, that did not work at all.
Any and all help would be greatly appreciated.
<?php
//Authorizations required for this page
$group = "NULL";
$type = "NULL";
//INCLUDES
INCLUDE("../includes/includefile.php");
INCLUDE("../includes/auth.php");
$_SESSION['sessiontimeout'] = (time() + 3600);
IF(isset($_POST['submit']))
{
$dbname = $_SESSION['current_org'];
$dbc = new mysqli($dbhost,$dbuser,$dbpass,$dbname);
IF(mysqli_connect_error())
{
$errorMSG = $dbc->error;
}//end if
ELSE
{
$sql = "SELECT * FROM {$_SESSION['current_org']}_users WHERE id = '{$_POST['number']}'";
$results = $dbc->query($sql);
IF($results->num_rows == 1)
{
header("location: member_display.php?mid={$_POST['number']}");
}//end if
ELSE
{
$path = "<a href = '../mainMenu.php'>Main Menu</a>→ <a href = 'membermenu.php'>Member Menu</a>";
INCLUDE("../header.php");
PRINT("<center><h2>More than 1 user found!</h2></center><br><br>Please report this to the Database Administrator!<br><br><div style = 'width: 50%; border: 5px solid red;'>");
WHILE($item = $results->fetch_object())
{
PRINT("$item->id ..... $item->name <br><br>");
}//end while loop
PRINT("</div>");
INCLUDE("../footer.php");
}//end else
//This file will display the users profile
INCLUDE("member_profile.php");
}
}//end if
ELSE
{
$path = "<a href = '../mainMenu.php'>Main Menu</a>→ <a href = 'membermenu.php'>Member Menu</a>";
INCLUDE("../header.php");
PRINT("
<h2>SEARCH BY NUMBER</h2>
<form id = 'sbynum' name = 'sbynum' method = 'post' action = '{$_SERVER['PHP_SELF']}'>
<center>
<table>
<tr>
<td>
<center><img src = '../images/org_logos/{$_SESSION['current_org']}.jpg'></center>
</td>
</tr>
<tr>
<td>
<input type = 'text' name = 'number' size = '20'>
</td>
</tr>
<tr>
<td>
<input type = 'submit' name = 'submit' value = 'SEARCH'>
</td>
</tr>
</table>
</center>
</form>
<!--
<script type='text/javascript'>
document.sbynum.number.focus();
</script>
-->
");
}//end else
INCLUDE("../footer.php");
?>