Popeye 2 is coming soon! Read about it here.


Popeye v 1.0
Making PHP login faster, safer and smoother


Download


Documentation

Start by including popeye.php

include 'popeye.php';

Use the statement entered above at the very top of your page, do not start any sessions. If you haven't already, wrap it around with the php code blocks. If you have you popeye file somewhere else, you will have to change the link above.


Connect to your database.

$conn = mysqli_connect("YOUR_HOST", "YOUR_DB_USERNAME", "YOUR_DB_PASSWORD", "YOUR_DATABASE");

If this is confusing, check out how to connect to a mysql database here.
You need to set this at the top of your page.


Now let's create our user table!

CREATE TABLE users (id int(11) not null AUTO_INCREMENT PRIMARY KEY,fullname varchar(128) not null,username varchar(128) not null,email varchar(128) not null,password varchar(1000) not null);

What you want to do know is first of all copy the SQL statement above or you can upload the file that comes with the download. Then open PhpMyAdmin, you can do so by either going to localhost/phpmyadmin if you are working locally, or if you are running ona live host with a domain. Please go to you control panel and find where your databases are. The alternative is ofcourse to do it in a mysql terminal if you so want to. Now select your database, go to the sql tab and enter paste the SQL, then click go.


Enough with the complicated stuff, it's register time!

popeye_register($conn)

Create a simple html form with the register details. It should contain "Full Name", "Username", "Email", "Password", "Re Password". The name attribute for these should be as above but in lower case and in one word. Then make a submit button with the name of "register", or else it won't work. The method should be set to POST and the action should be the function as shown above. You can do that with simple php concatenation. You can use the code below for the forms start.

<?php echo "<form action='".popeye_register($conn)."' method='POST'>"; ?>


Time to login.

popeye_login($conn)

Create a simple html form with the login details. It should contain "Username" and "Password". The name attribute for these should be as above but in lower case. Then make a submit button with the name of "login", or else it won't work. The method should be set to POST and the action should be the function as shown above. You can do that with simple php concatenation. You can use the code below for the forms start.

<?php echo "<form action='".popeye_login($conn)."' method='POST'>"; ?>


And finally, logout.

popeye_logout()

Now, it's very simple. Just create a form with the function as shown above. Or you can start your form with the code below. Just create one input field with the type submit and the name of logout, if you don't it won't work.

<?php echo "<form action='".popeye_logout()."' method='POST'>"; ?>


What if I want my own register information?

The popeye.php file has instructions on what everything does so you can customize it as you wish. You do need a prettu good knowledge of PHP to pull it of tho and the SQL statement at the top will be different as well. However in Popeye 2 this will allow you to configure it easily so stay tuned.

Download
Andaz AB © 2017