We created the sign-up form in a slightly different way from other forms like the login form. The ‘SELECT * FROM’ query was used so that it can look up the existing users and lets them log in to the site. The ‘$_SESSION [“message”]’ and ‘$_SESSION [“username”]’ bits of code echo out a message which tells the user whether or not they have logged in successful.
This part of the code was slightly complicated as we had to adapt the code so that a user could log in with their username and password. The singup.php was used so submit their details when they signed up. This was code we used in other areas of our site. However we kept on having errors with this code including the data not being placed onto the database and then the user not being able to log in. Another problem we couldn’t overcome was that someone could create a user without typing anything in the fields as we did not know how to set the character limit for the password and username. Kyle helped us sort out some of these errors. He noticed that we had put ‘SELECT*FROM’ in the code but it actually needed to be ‘INSERT INTO’ as we were trying to add data to the database rather than pull it from the database. This finally made the sign up page work and we were now able to log into our site.
This is the code for the sign up page form:
After being able to log in we now realised that when you logged in you could see the log in feature in the nav bar and we wanted to show the ‘New Post’ page at the top so a user was able to create a profile. We thought that this might cause errors and it didn’t look right for it to be there if a user was already logged in so we asked Kyle how to do this and there was an easy fix for it. We had to work out the code that would mean that “if the user isn’t logged in then show the login and sign up button on the page”. It was a simple bit of code to add to hide and show the elements we wanted in different situations.