Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php include '../config.php'; ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Register</title>
- </head>
- <body>
- <form action="register.php" method="POST">
- <input type="text" placeholder="Username..." name="username"><br><br>
- <input type="text" placeholder="Email..." name="email"><br><br>
- <input type="password" placeholder="Password..." name="password"><br><br>
- <input type="password" placeholder="Repeat password..." name="password2"><br><br>
- <button type="submit" name="submit">Register</button>
- </form>
- </body>
- </html>
- <?php
- if (isset($_POST['submit'])) {
- $username = $_POST['username'];
- $email = $_POST['email'];
- $password = $_POST['password'];
- $errors = array();
- if (trim($_POST['username']) == '') {
- $errors[] = 'Empty username!';
- }
- if (trim($_POST['email']) == '') {
- $errors[] = 'Empty email';
- }
- if ($_POST['password'] == '') {
- $errors[] = 'Please enter password!';
- }
- if ($_POST['password2'] !== $_POST['password']) {
- $errors[] = 'Passwords do not match!';
- }
- if (empty($errors)) {
- mysqli_query($db_connect, "INSERT INTO registration (user_name,email) VALUES ('$username', '$email')");
- } else {
- echo 'OoOops '.array_shift($errors). '' ;
- }
- }
- // if (!$db_connect) {
- // echo 'No connection to database!';
- // } else {
- // echo 'All OK, we are connected to DB!';
- // }
- mysqli_close($db_connect);
- ?>
- <?php
- // define - Defines A Named Constant
- $conn_error = 'Could not connect!';
- define("DB_SERVER", "localhost");
- define("DB_USERNAME", "root");
- define("DB_PASSWORD", "");
- define("DB_DATABASE", "test");
- // We Connect To database
- // Ar @ Zimi Neparadisies Errors
- $db_connect = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE) or die ("$conn_error");
- // $db_select = mysqli_select_db(DB_DATABASE);
- if (!$db_connect) {
- die ("$conn_error");
- }
- // } else {
- // echo "All OK!"; // If It's Connected will dispaly All OK!
- // }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement