Team Copenhagen Task 2(Signup And Login Form)

Published on Sep 18th, 2019 04:21 PM

The HNG internship kicked off last Sunday September 15th, 2019 and tasks were assigned to all tracks....

We were also told to form groups consisting of 10 members per group(at least 2 members from Frontend/Backend/Design Tracks) to create a basic login/signup website with authentication.... I was fortunate to be in Team Copenhagen(i cannot pronounce it well enough :( )...

We all came together and tasks were assigned to members of the team... I was involved in both the frontend and backend aspect of the task but majorly backend...

Programming Languages for the Task





Step1: The people in charge of the design posted samples of the designs they did via Figma and we all agreed to go with the best...

Step 2: After agreeing on the design to use, the frontend guys(including me) started coding using HTML5 and CSS3 with respect to the design given... Also we made collaborations via github(we have more than 30 commits on our repo)... We had issues with responsiveness on mobile but we solved it...

Step 3: I and the team Leader made use of JAVASCRIPT to validate the signup form...

We had the following into considerations before anyone can register successfully

Step 4: This is the part where i got my hands dirty on PHP..


$db = mysqli_connect("localhost", "root", "", "copenhagen");

For the signup form, a name is already set for the register button "submitBtn", if the button is clicked, it will check if username already exists, authenticate(j.s already did this) and store the information in the database...

Passwords are stored securely in the db using md5 hash..


$username = $_POST['username'];

  $email = $_POST['email'];

  $password = $_POST['password'];

  $password = md5($password);

  $s = mysqli_query($db, "SELECT * FROM users WHERE username = '{$username}'");


die("unable to connect: " .mysqli_error($db));


$num = mysqli_num_rows($s);

if($num == 1){

array_push($errors, "Username exists");

} else{

$reg = mysqli_query($db, "INSERT INTO users(username, email, password) 

VALUES('$username', '$email', '$password')");


die("unable to connect: " . mysqli_error($db));


header("Location: index.php");



For the Login authentication: A button was set "loginBtn" and if clicked, it checks for all conditions below and logs into home.php...

Conditions below

  • Username must be equal to username in database

2 .Password must be equal to password in database

3.Username and Password cannot be blank

If all conditions are met, user will be redirected to the home.php where you see "Welcome $username"...

Lastly, I added a logout link where users can logout, and it is redirected to the login page... A GET variable was set "logout=1"...




header("Location: index.php");