Welcome, Guest

Please login or register

TUTORIALS SUBMENU

PHOTOSHOP    FLASH    ILLUSTRATOR    BLENDER    CINEMA 4D    WEB-CODING    [SUBMIT]

Related Links

A Complete Membership System

pages (4): 1 2 [3] 4


Members Page (member.php)
This is the page the user will be shown when they log in. In my code I have separated all the menu structure into a separate file, menus.php, and added it back in by way of an INCLUDE to keep the source code below as simple as possible. You can either use the same code/idea in your script or make your own navigation, but you need to make sure that the following 3 links are included to make use of the inbuilt features in this members only page:

member.php?change=password – This will show a form to change your password
member.php?change=email – This will show a form to change your email address.

Note: both of the features above deactivate the user when the script processes, and they must re-activate via email.

member.php?change=account – This will shut the account down & delete it. This shows a confirmation message before referring itself to processing for account deletion (see processing.php for more details).

<?php
session_start();
if($_SESSION['s_logged_n'] == 'true'){
include 'process.php';
?>
<html>
<head>
<title>Members Page</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>

<div id="wrapper">

<div id="head">The member page</div><br>
<div id="container">
<? include 'menus.php' ?>
</div>
<div id="spacer">&nbsp;</div>
<div id="memmain">


<?php

switch($_GET['change']){

case 'password':

echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">
<p>Current password:<br>
<input name="current" type="password"></p>
<p>New password:<br>
<input name="new" type="password"></p>
<p>Confirm new password:<br>
<input name="confirm" type="password"></p>
<p><input type="submit" value="Change Password" name="changepassword"></p>
</form>
';

break;

case 'email':

echo '<p>
WARNING! - By changing your email address you will have to re-validate. Make sure you email address is 100% correct.</p>
<form action="'.$_SERVER['PHP_SELF'].'" method="post">
<p>Current email:<br>
<input name="current" type="text"></p>
<p>New email:<br>
<input name="new" type="text"></p>
<p>Confirm new email:<br>
<input name="confirm" type="text"></p>
<p><input type="submit" value="Change Email" name="changeemail"></p>
</form>
';

break;

case 'account':

echo '<p>
WARNING - By closing your account, you will not be able to login again under this account. Press the button below to confirm you wish to close your account</p>
<form action="'.$_SERVER['PHP_SELF'].'" method="post">
<p><input type="submit" value="Close Account" name="closeaccount"></p>
</form>
';

break;

default:

echo '<p>Welcome to the super secret members only control panel!</p>';

}

?>

</div>

</body>
</html>

<?php
} else {
header("Location: login.php");
}
?>

The first crucial IF statement checks the session containing data to ensure that the user is allowed to view the page. If the user is properly authenticated, the page will be shown. Otherwise, the page will re-refer to the login.

The rest of the main page is pretty simple and you can structure it how you like - providing, of course, that you include the appropriate links mentioned above. Adding extra options is as easy as adding a few lines of code to the switch. The switch statement chooses what to do depending on the header variable “change”. It has 3 inbuilt forms and a default clause which initiates when $_GET[‘change’] is empty.

Resending Validation E-Mails (resend.php)
When running a script system that features user authentication, one essential feature is a script that resends the validation e-mail, ensuring that if the e-mail doesn't reach the recipient (due to network connectivity problems, over-eager anti-spam systems, etc) then it can be re-sent with ease by simply filling out a form.

<?php
include 'config.php';

if(isset($_POST['resend']))
{

$email = trim($_POST['email']);

$query = mysql_query("SELECT Actkey FROM Users WHERE Email = '$email' LIMIT 1") or die(mysql_error());

while($row = mysql_fetch_array($query)){

$act = $row['Actkey'];

if(mysql_num_rows($query) > 0)
{

$send = mail($email , "Activate your account" , "Thank you for registering with YourWebsite.\n\nClick the link below to activate your account:\nhttp://CHANGETHISURL.COM/activate.php?id=".$act."\n\nPlease do not reply, this is an automated mailer.\n\nThanks", "FROM: auto@mailer.com");

if($send){

echo '
<html>
<head>
<title>Success</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>

<div id="wrapper">

<div id="head">the resend activation email page</div>
<br>
<div id="success">
<p>The validation email was successfully sent. <a href="login.php">Click here</a> to login once you have activated.</p>
</div>
</div>

</body>
</html>
';

} else {

echo '
<html>
<head>
<title>Error</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>

<div id="wrapper">

<div id="head">the resend activation email page</div>
<br>
<div id="error">
<p>Ha, what an act. There has been an error processing your activation email. Please contact the administrator.</p>
</div>
</div>

</body>
</html>
';

}

} else {

echo '
<html>
<head>
<title>Error</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>

<div id="wrapper">

<div id="head">the resend activation email page</div>
<br>
<div id="error">
<p>Sorry, your email was not found in the database, please enter an email address that you have registered with and not recieved and email with.</p>
</div>
</div>

</body>
</html>
';

}

}

} else {

?>
<html>
<head>
<title>Resend validation email</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>

<div id="wrapper">

<div id="head">the resend activation email page</div>
<br>
<div id="main">
<p>Ok, so your activation email didn't get sent? DAMN S**T C*H(#@ ((@J no, stop swearing, put that bottle down. You don't need it. We need each other. I'm here to resend your email, so enter your email address, and I will send the validation link to that email, provided you have registered ofcourse, if you are trying to hack me, what a sad guy, taking advantage of my emotions like that... jeez.</p>
<form method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
<p>Email:<br>
<input name="email" type="text">
<p>
<input name="resend" type="submit" id="resend" value="Resend">
</form>
</p>
Once you enter your email and hit resend, I will make sure your email is valid, then send you out your validation link. If it doesn't come, try me again! I'm not a one night stand you know...
<p>By the way, I am very (case) sensitive so enter the email exactly as you registered with it. </p>
</div>
</div>

</body>
</html>
<? } mysql_close($l); ?>

As you can probably deduce, this script features a logic switch, meaning that when the user first loads the page they will be shown a form, and when they submit the data, the page will process that data instead. This involves searching the database for the user account with the email address provided. If it is found, an e-mail is sent to the appropriate e-mail address with the user’s activation key in a URL that they can activate. As before, though, you must change that URL in the mail() function to reflect your server's settings!

If the email address isn’t found the user gets an error message.  You may have noticed I use PHP_SELF as the form method in all the forms so far - That is basically just telling the form to process onto itself.  Its a convenient method that reduces the overall number of scripts needed for the whole membership system.

- Tutorial written by Scrowler

Pages (4): <Prev 1 2 [3] 4 Next>
Automatic Translations: Translate Into French Translate Into German Translate Into Italian Translate Into Spanish Translate Into Portuguese

Last 5 User Comments


There are no comments for this tutorial yet.
You can place a comment by clicking here.
Amazing Font Pack!

Featured Tutorialsmore

Signature Techniques
Signature Techniques
- Adobe Photoshop -
Abstract Grunge In...
Abstract Grunge In...
- Adobe Photoshop -
Anti-Aliasing Inte...
Anti-Aliasing Inte...
- Adobe Photoshop -
The Glamour Effect
The Glamour Effect
- Adobe Photoshop -
Membership

Username:
Password:  
Remember Me

Lost Password? || Register

Related Links



Special Options
Download Source File
Printer Friendly Version
Forum Threads

 Deactivate Account
Author: jerinian
Posted: Oct 02nd, 11:16am
Activity: 1 replies, 887 views
 changes....
Author: supertackyman
Posted: Sep 12th, 2:56am
Activity: 2 replies, 1052 views
Back again and with free webhosting :)
Author: ngz
Posted: Aug 14th, 3:50pm
Activity: 0 replies, 1054 views
Cartoon Crab 6 Legs Walk Run created in Blender
Author: patricia3d
Posted: Jun 19th, 12:58pm
Activity: 0 replies, 1935 views
HTML Form Post Array to PHP
Author: Space Cowboy
Posted: May 25th, 2:18pm
Activity: 0 replies, 1832 views
My blog where i create Digi Scrapbook
Author: claudya07
Posted: May 11th, 2:33pm
Activity: 0 replies, 14441 views
Blood Dripping from Letters
Author: patricia3d
Posted: Apr 05th, 3:37am
Activity: 0 replies, 2751 views
A New Designer has joined the ranks
Author: skates1
Posted: Mar 28th, 2:19pm
Activity: 2 replies, 2772 views
The hole in Photoshop
Author: Mars
Posted: Feb 13th, 9:28pm
Activity: 2 replies, 3439 views
Colour Swatch
Author: ebz7350
Posted: Jan 15th, 11:18am
Activity: 0 replies, 2356 views
 BioRUST Forums - Reply to Topic
Author: inonShozy
Posted: Jan 11th, 11:32am
Activity: 8 replies, 2499 views
 Version 2 of my portfolio site.
Author: andrewnleon
Posted: Jan 08th, 6:18am
Activity: 6 replies, 2798 views
Forum Threads

--- Site Resources ---
Total Tutorials:212
Total Downloads:    441
Total Fonts:    4673