I need help on my php, I don’t know how to do this but what I want is the user to enter in a room number in a textbox and when the user submits the form, if the room number is not in the database then it should display a message stating room is invalid. Does anyone know if this is possible?
Below is relevant code:
Javascript code for validation:
function validation() {
var isDataValid = true;
var roomTextO = document.getElementById("room");
//this retrieves an element from the textbox where user enters in a room number
var errRoomMsgO = document.getElementById("roomAlert");
// this is where the alert message appears for validation
if (roomTextO.value == ""){
errRoomMsgO.innerHTML = "Please Enter in a Room Number";
isDataValid = false;
}else if (!trimmedRoomText.length){
errRoomMsgO.innerHTML = "Please Enter in a Room Number";
isDataValid = false;
}else{
errRoomMsgO.innerHTML = "";
}
}
Below is relevant SQL where room numbers are stored in database:
<?php
$roomresult = mysql_query( "SELECT Room FROM Room" );
?>
The name of the Table is “Room” and the Room numbers are stored under the field “Room”.
Below is the textbox where user enters in room number:
<p><strong>Room:</strong> <input type="text" id="room" name="roomChosen" /><br/><span id="roomAlert"></span></p> <!-- Enter Room here-->
Well you need to select by the room_id (or some other criteria[s] that will deliver a unique result) basic sql, really…