0byt3m1n1
Path:
C:
/
wamp64
/
www
/
Crops
/
[
Home
]
File: new.php
<!DOCTYPE html> <html> <head> <title>Crop and Nutrient Selection</title> <style> body { display: flex; justify-content: center; align-items: center; min-height: 100vh; background-color: #e8f7d2; font-family: Arial, sans-serif; } .container { max-width: 600px; padding: 20px; background-color: #fff; border-radius: 8px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); } h1 { text-align: center; position: absolute; top: 20px; left: 20%; transform: translateX(-50%); } h2 { text-align: center; margin-top: 0; padding-top: 20px; } form { margin-top: 20px; } label { display: block; margin-bottom: 5px; font-weight: bold; } select { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } input[type="submit"] { margin-top: 10px; padding: 10px 20px; background-color: #4CAF50; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; } hr { margin-top: 30px; border: none; border-top: 1px solid #ccc; } .result { margin-top: 20px; padding: 10px; background-color: #f9f9f9; border: 1px solid #ccc; border-radius: 4px; } </style> </style> </head> <body> </head> <body> <form action="" method="post"> <label for="crop">Select Crop:</label> <select name="crop" id="crop"> <option value="">Select Crop</option> <!-- Add crop options dynamically from the database --> <?php // Establish a database connection $servername = "localhost"; $username = "root"; $password = ""; $dbname = "crops"; $conn = mysqli_connect($servername, $username, $password, $dbname); // Fetch crop names from the database $cropQuery = "SELECT Name FROM crop"; $cropResult = mysqli_query($conn, $cropQuery); // Display crop options while ($row = mysqli_fetch_assoc($cropResult)) { echo "<option value='" . $row['Name'] . "'>" . $row['Name'] . "</option>"; } // Close the database connection mysqli_close($conn); ?> </select> <br><br> <label for="nutrient">Select Nutrient:</label> <select name="nutrient" id="nutrient"> <option value="">Select Nutrient</option> <!-- Add nutrient options dynamically from the database --> <?php // Establish a database connection $servername = "localhost"; $username = "root"; $password = ""; $dbname = "crops"; $conn = mysqli_connect($servername, $username, $password, $dbname); // Fetch nutrient names from the database $nutrientQuery = "SELECT Nutrient FROM crop"; $nutrientResult = mysqli_query($conn, $nutrientQuery); // Display nutrient options while ($row = mysqli_fetch_assoc($nutrientResult)) { echo "<option value='" . $row['Nutrient'] . "'>" . $row['Nutrient'] . "</option>"; } // Close the database connection mysqli_close($conn); ?> </select> <br><br> <label for="disease">Select Disease:</label> <select name="disease" id="disease"> <option value="">Select Disease</option> <!-- Add disease options dynamically from the database --> <?php // Establish a database connection $servername = "localhost"; $username = "root"; $password = ""; $dbname = "crops"; $conn = mysqli_connect($servername, $username, $password, $dbname); // Fetch disease names from the database $diseaseQuery = "SELECT Dicease FROM crop"; $diseaseResult = mysqli_query($conn, $diseaseQuery); // Display disease options while ($row = mysqli_fetch_assoc($diseaseResult)) { echo "<option value='" . $row['Dicease'] . "'>" . $row['Dicease'] . "</option>"; } // Close the database connection mysqli_close($conn); ?> </select> <br><br> <label for="pests">Select Pests:</label> <select name="Pests" id="Pests"> <option value="">Select Pests</option> <!-- Add disease options dynamically from the database --> <?php // Establish a database connection $servername = "localhost"; $username = "root"; $password = ""; $dbname = "crops"; $conn = mysqli_connect($servername, $username, $password, $dbname); // Fetch disease names from the database $diseaseQuery = "SELECT Pests FROM crop"; $diseaseResult = mysqli_query($conn, $diseaseQuery); // Display disease options while ($row = mysqli_fetch_assoc($diseaseResult)) { echo "<option value='" . $row['Pests'] . "'>" . $row['Pests'] . "</option>"; } // Close the database connection mysqli_close($conn); ?> </select> <br><br> <input type="submit" name="submit" value="Submit"> </form> <hr> <?php if (isset($_POST['submit'])) { // Get the selected crop, nutrient, and disease values $selectedCrop = $_POST['crop']; $selectedNutrient = $_POST['nutrient']; $selectedDisease = $_POST['disease']; $selectedPests=$_POST['Pests']; // Display the details of the selected crop if (!empty($selectedCrop) && empty($selectedDisease) && empty($selectedPests) && empty( $selectedNutrient)) { // Display nutrient-related content include("crop.php"); } if (!empty($selectedCrop) && !empty($selectedDisease) && empty($selectedPests) && empty( $selectedNutrient)) { // Display nutrient-related content include("cdi.php"); } if (!empty($selectedCrop) && !empty($selectedDisease) && !empty($selectedPests) && empty( $selectedNutrient)) { // Display nutrient-related content include("cdpe.php"); } if (!empty($selectedCrop) && !empty($selectedDisease) && !empty($selectedPests) && !empty( $selectedNutrient)) { // Display nutrient-related content include("complete.php"); } // Include the content from another webpage based on the selected values if (!empty($selectedCrop) && !empty($selectedNutrient) && empty($selectedDisease) && empty($selectedPests)) { // Display nutrient-related content include("nutri.php"); } if (!empty($selectedCrop) && empty($selectedDisease) && !empty($selectedPests) && empty( $selectedNutrient)) { // Display nutrient-related content include("pests.php"); } if (!empty($selectedCrop) && !empty($selectedDisease) && empty($selectedPests) && !empty( $selectedNutrient)) { // Display nutrient-related content include("cnd.php"); } if (!empty($selectedCrop) && empty($selectedDisease) && !empty($selectedPests) && !empty( $selectedNutrient)) { // Display nutrient-related content include("cnp.php"); } } ?> </body> </html>