i am very new to SQL and PHP. I have a small DB set up with asset tag as a primary key. I have success when I just ask for all rows, but I want the user to enter the asset id tag they want. I can't seem to get the everything to work together. Here is my code and at the bottom is the result I am getting.
<?php //query //set the database connection and select the database require_once 'login.php'; $db_password, $db_database); $db_server = new mysqli ($db_hostname,$db_username, $db_password, $db_database); //$inputAssetTag = ""; //Check connection if (mysqli_connect_errno()) { echo "Unable to connect to database"; } else { echo "Connected" . ""; if (!isset($_GET['iputAssetTg'])){ echo "here"; ?>
<form action="AssetTagSearch3.php" method ="GET">
Please enter an Asset ID tag:
<br><br> <input type="text" name="inputAssetTg" value="<?php echo $inputAssetTag; ?>"> <br><br>
<input type ="submit" value = "Enter">
</form>
<?php
if (!empty($inputAssetTag)) {
$inputAssetTag = $_GET['inputAssetTg'];
echo "Perfect";
} else {
echo "Enter an id";
}
}
}
?>
this is my browser when I run my code...it doesn't stop to wait for the input.
Connected
here
Please enter an Asset ID tag:
[text box]
(enter button)
Enter an id