Skip to content

Instantly share code, notes, and snippets.

@Payden-Pringle
Created November 18, 2025 18:58
Show Gist options
  • Select an option

  • Save Payden-Pringle/edda9c5580719343e9f4dbd172626a50 to your computer and use it in GitHub Desktop.

Select an option

Save Payden-Pringle/edda9c5580719343e9f4dbd172626a50 to your computer and use it in GitHub Desktop.
tmp - code for form
<?php
// Connect to DB
$db = new SQLite3('/var/www/mfarelay/twilio.db');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Prepare and bind parameters
$stmt = $db->prepare('INSERT INTO users (name, phone, email) VALUES (:name, :phone, :email)');
$stmt->bindValue(':name', $_POST['name'], SQLITE3_TEXT);
$stmt->bindValue(':phone', $_POST['phone'], SQLITE3_TEXT);
$stmt->bindValue(':email', $_POST['email'], SQLITE3_TEXT);
// Execute the statement
$stmt->execute();
echo "<p>Record inserted successfully!</p>";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Insert User Record</title>
<style>
form {
max-width: 400px;
margin: 0 auto;
padding: 1em;
border: 1px solid #ccc;
}
div {
margin-bottom: 1em;
}
label {
margin-bottom: .5em;
color: #333333;
}
input {
border: 1px solid #cccccc;
padding: .5em;
font-size: 1em;
width: 100%;
}
button {
padding: 0.7em;
color: #fff;
background-color: #007BFF;
border: none;
width: 100%;
font-size: 1em;
}
</style>
<script>
function validateForm() {
const userName = document.forms["userForm"]["name"].value;
const userPhone = document.forms["userForm"]["phone"].value;
const userEmail = document.forms["userForm"]["email"].value;
const yourEmail = document.forms["userForm"]["other_email"].value;
if (!userName || !userEmail || !userPhone || !yourEmail) {
alert("All fields must be filled out");
return false;
}
return true;
}
</script>
</head>
<body>
<form name="userForm" method="post" onsubmit="return validateForm()">
<div>
<label for="name">User Name</label>
<input type="text" id="name" name="name" required>
</div>
<div>
<label for="phone">User Phone</label>
<input type="text" id="phone" name="phone" required>
</div>
<div>
<label for="email">User Email</label>
<input type="text" id="email" name="email" required>
</div>
<div>
<label for="other_email">Your Email</label>
<input type="text" id="other_email" name="other_email" required>
</div>
<div>
<button type="submit">Submit</button>
</div>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment