WordPress Code Snippets

A fresh mix of code snippets and tutorials

Simple PHP login form

71

Here’s a quick PHP snippet for creating a simple login form for your site.

Here is the magic PHP snippet to create a basic login form:

<?php 
// simple login form

$username = '';
$password = '';

if ( $_POST['username'] !== $username || $_POST['password'] !== $password ) { ?>

<h1>Member Login</h1>
<p>Please enter your credentials:</p>
<form name="form" method="post" action="http://deadletterart.com/dla/forum/">
	<p><label for="username">Username:</label><input type="text"     title="username" name="username" /></p>
	<p><label for="password">Password:</label><input type="password" title="password" name="password" /></p>
	<p><input type="submit" name="submit" value="Login" /></p>
</form>

<?php } else {

	// process successful login as normal

} ?>

Customize as needed, and remember to use strong passwords!


Show Support

Like our new Facebook Page to show support!