Posts

Showing posts from February, 2023

simple PHP code for a sign-up form that accepts a user's name, email, and password

Image
  <?php if (isset($_POST['submit'])) {   $name = $_POST['name'];   $email = $_POST['email'];   $password = $_POST['password'];   // Connect to database   $conn = mysqli_connect('hostname', 'username', 'password', 'database_name');   // Check connection   if (!$conn) {     die("Connection failed: " . mysqli_connect_error());   }   // Prepare and bind   $stmt = $conn->prepare("INSERT INTO users (name, email, password) VALUES (?, ?, ?)");   $stmt->bind_param("sss", $name, $email, $password);   // Execute the statement   if ($stmt->execute()) {     echo "New record created successfully";   } else {     echo "Error: " . $stmt->error;   }   // Close statement and connection   $stmt->close();   $conn->close(); } ?> <!-- Signup form HTML --> <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="pos...