0% found this document useful (0 votes)
13 views1 page

PHP Progmm

The document contains a PHP script that handles the submission of a form for recording milk production data. It captures details such as animal ID, date, quantity, fat content, and quality score, and inserts this information into a database. Upon successful insertion, it confirms the record addition, otherwise, it displays an error message.

Uploaded by

Stella Nelima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

PHP Progmm

The document contains a PHP script that handles the submission of a form for recording milk production data. It captures details such as animal ID, date, quantity, fat content, and quality score, and inserts this information into a database. Upon successful insertion, it confirms the record addition, otherwise, it displays an error message.

Uploaded by

Stella Nelima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

<?

php

include 'db.php';

if ($_SERVER["REQUEST_METHOD"] == "POST") {

$animal_id = $_POST['animal_id'];

$date = $_POST['date'];

$quantity = $_POST['quantity'];

$fat_content = $_POST['fat_content'];

$quality_score = $_POST['quality_score'];

$sql = "INSERT INTO milk_production (animal_id, date, quantity, fat_content, quality_score)

VALUES ('$animal_id', '$date', '$quantity', '$fat_content', '$quality_score')";

if ($conn->query($sql) === TRUE) {

echo "Milk production record added successfully!";

} else {

echo "Error: " . $sql . "<br>" . $conn->error;

?>

<form method="POST">

<input type="number" name="animal_id" placeholder="Animal ID" required>

<input type="date" name="date" required>

<input type="number" step="0.01" name="quantity" placeholder="Quantity (liters)" required>

<input type="number" step="0.01" name="fat_content" placeholder="Fat Content (%)" required>

<input type="number" step="0.1" name="quality_score" placeholder="Quality Score" required>

<button type="submit">Submit</button>

</form>

You might also like