Jump to content

slotegraafd

Members
  • Posts

    35
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by slotegraafd

  1. First things first dont friggen attack me okay? I am NEW TO PROGRAMMING i know nothing! Hense the reason why the program that I am creating is so stupid and doesnt work and all the other insults you gave me. I wasnt against the idea of using the error reporting because I did and IT SHOWED ME NOTHING. I was simply asking for other suggestions. So if you arent gonna be helpful then leave me the hell alone. And yes I do have a lot of damn attitude.
  2. No errors showed up... Still having the same problem
  3. Sigh I feel like a broken record. Let me start over. All I am trying to do is figure out why the data that the user registers wont be saved in the database
  4. whenever I try to start the mysql thing in xampp it says it shut down unexpectedly there is something wrong with the port, and the password is the password I used for the database that I have using MYSQL workbench
  5. oh I see, so i click on that but now its saying access denied and it cant connect
  6. I'm using XAMPP if thats what you're asking
  7. I was going to try using phpmyadmin but i dont really know how to download it, or use it
  8. Hi, that's all very helpful but that doesnt really have anything to do with the problem I am having. All I need to know is why the information is not being stored into the database after the user registers and why it wont let me log in with the registered data
  9. Hi! So due to this pandemic I've decided to do some programming just for fun in preparation for school in september. I am currently focused on just creating a simple login and registration page. The registration page is supposed to add the users entered data into the MYSQL database and then redirect to the home page. That works just fine. But when I try to login using the information the user registered with it gives me the error that i created that it is incorrect which it is not so I don't think it's actually saving and I'm unsure why... This is the code for my server and creating the errors and what its supposed to do when the button is pressed <?php session_start(); // variable declaration $username = ""; $email = ""; $errors = array(); $_SESSION['success'] = ""; // connect to database $db = mysqli_connect('localhost', 'root', 'deanna1999', 'registration'); // REGISTER USER if (isset($_POST['registerbtn'])) { // receive all input values from the form $username = mysqli_real_escape_string($db, $_POST['username']); $email = mysqli_real_escape_string($db, $_POST['email']); $password_1 = mysqli_real_escape_string($db, $_POST['password_1']); $password_2 = mysqli_real_escape_string($db, $_POST['password_2']); // form validation: ensure that the form is correctly filled if (empty($username)) { array_push($errors, "Username is required"); } if (empty($email)) { array_push($errors, "Email is required"); } if (empty($password_1)) { array_push($errors, "Password is required"); } if ($password_1 != $password_2) { array_push($errors, "The two passwords do not match"); } // register user if there are no errors in the form if (count($errors) == 0) { $password = md5($password_1);//encrypt the password before saving in the database $query = "INSERT INTO users (username, email, password) VALUES('$username', '$email', '$password')"; mysqli_query($db, $query); $_SESSION['username'] = $username; $_SESSION['success'] = "You are now logged in"; header('location: home.php'); } } // ... // LOGIN USER if (isset($_POST['login'])) { $username = mysqli_real_escape_string($db, $_POST['username']); $password = mysqli_real_escape_string($db, $_POST['password']); if (empty($username)) { array_push($errors, "Username is required"); } if (empty($password)) { array_push($errors, "Password is required"); } if (count($errors) == 0) { $password = md5($password); $query = "SELECT * FROM users WHERE username='$username' AND password='$password'"; $results = mysqli_query($db, $query); if (mysqli_num_rows($results) == 1) { $_SESSION['username'] = $username; $_SESSION['success'] = "You are now logged in"; header('location: home.php'); }else { array_push($errors, "Wrong username/password combination"); } } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.