Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
Insane-HK committed May 26, 2024
1 parent 9fe3f11 commit 56484e2
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<div id="sellerModal" class="modal">
<div class="modal-content">
<span class="close">&times;</span>
<h2>Seller Form</h2>
<form id="sellerForm">
<h2>Seller Form</ h2>
<form action="D:/XAMPP/htdocs/phpForm.php" method="post" id="sellerForm">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
Expand Down
58 changes: 58 additions & 0 deletions phpForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

<!DOCTYPE html>
<html>

<head>
<title>Inserts</title>
</head>

<body>
<center>

<?php

// Enable error reporting
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

// Retrieve POST data
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$energyType = $_POST['energyType'];
$energyAmount = $_POST['energyAmount'];

// Database credentials
$servername = "localhost";
$username = "hitesh";
$password = "hitesh123";
$db = "rec";

// Create connection
$conn = new mysqli($servername, $username, $password, $db);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

// Prepare and bind
$stmt = $conn->prepare("INSERT INTO sellinglist VALUES (?, ?, ?, ?, ?, ?)");
$stmt->bind_param("sssssi", $name, $email, $phone, $address, $energyType, $energyAmount);

// Execute statement
if ($stmt->execute()) {
echo "ADDED: " . $name . ", " . $email . ", " . $phone;
} else {
echo "Error: " . $stmt->error;
}

// Close connection
$stmt->close();
$conn->close();
?>

</center>
</body>

</html>

0 comments on commit 56484e2

Please sign in to comment.