Page 350 - Computer Software Application TP - Volume 1
P. 350
COMPUTER SOFTWARE APPLICATION - CITS
$email = $_POST[“email”];
// Prepare and execute the SQL statement to insert data into the table
$stmt = $conn->prepare(“INSERT INTO users (username, email) VALUES (?,?)”);
$stmt->bind_param(“ss”, $username, $email);
if ($stmt->execute())
{
echo “New record inserted successfully”;
}
else
{
echo “Error: “ . $conn->error;
}
// Close statement
$stmt->close();
}
// Close connection
$conn->close();
?>
</body>
</html>
3 Save the program in C:\Apache24\htdocs in a folder as insert.php
4 Run the Apache services from windows services
5 Open the browser and type the following address
http://localhost/foldername/
6 Click the index.html file to run and verify the output
335
CITS : IT & ITES - Computer Software Application - Exercise 61