Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!isset($_POST['username'], $_POST['password'])) {
- header('Location: register.html');
- exit();
- }
- $servername = "localhost";
- $username = "or";
- $password = "1234";
- $dbname = "forum";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "INSERT INTO users (username, password) VALUES ('".$_POST['username']."', '".$_POST['password']."')";
- if ($conn->query($sql) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: ".$sql."<br>".$conn->error;
- }
- $conn->close();
- // Eventually redirect to index
- header('Location: index.php');
- ?>
Add Comment
Please, Sign In to add comment