Posts Tagged ‘ login help ’
After creating a database named users, a table named users and two fields username and password, you can begin making this login script.
The basic form
Create a page named index.php, and inside that page add the following code.
<form action="login.php" method="post"> <label for="name">Username</label> <input name="username" type="text" /> <label for="password">Passwod</label> <input name="password" type="password" /> <input type="submit" value="submit" /> </form>
The form action tells the form where the information should be going once the submit button is clicked. Next, the method tells it how the information should be transmitted. In PHP there are two methods for tranmitting information,
Remember visiting Youtube and seeing youtube.com/watch?v=mEj-88iLjmM&feature=popular? This was submitted using a get, because you can see everything that is going on.
In cases where security is important this is not system, we do not want people to be able to hi-jack our login credentials.
We have basic input boxes. The “name” value is what is transmitted to the subsequent PHP pages.
Connecting to a database
Make a new document and name it: “connection.php”. This document will store the database connection information.
We have the variables stored with our database information, now we need to do something with them. Take the server location (most cases its localhost), database user, and database password and connecting. or die(mysql_error()) says, if connection does not complete, give us an error message.
Next, we select the database, and if something went wrong there, we display another error message.
We want to include this on every page that needs database access.PHP Script | Comments Off on Simple Login Script