This resource is what I used to develop the activate.php file. Specifically Step 4 : Activation Page was my guide to building activate.php. With a bit of help from Celauran.
Now.. my goal is to format the activate.php file. This has been an interesting exercise. If you review the resource I used to build this page you will see that there is some mixing of php and html. Specifically the following if block uses echo statements to execute html formatting of messages.
Code: Select all
12 if (isset($email) && isset($key)) {
13
14 // Update the database to set the "activation" field to null
15
16 $query_activate_account = "UPDATE members SET Activation=NULL WHERE(Email ='$email' AND Activation='$key')LIMIT 1";
17 $result_activate_account = mysqli_query($dbc, $query_activate_account);
18
19 // Print a customized message:
20 if (mysqli_affected_rows($dbc) == 1) //if update query was successfull
21 {
22 echo '<div>Your account is now active. You may now <a href="login.php">Log in</a></div>';
23
24 } else {
25 echo '<div>Oops !Your account could not be activated. Please recheck the link or contact the system administrator.</div>';
26
27 }
28
29 mysqli_close($dbc);
30
31 } else {
32 echo '<div>Error Occured .</div>';
33 }Code: Select all
<?php
// include database connection file, if connection doesn't work the include file will throw an error message
include '../schedule/include/db_connect.php';
// the following code is an adaptation of registration code examples found at: http://youhack.me/2010/04/01/building-a-registration-system-with-email-verification-in-php/
if (isset($_GET['email']) && preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/',
$_GET['email'])) {
$email = $_GET['email'];
}
if (isset($_GET['key']) && (strlen($_GET['key']) == 32))
//The Activation key will always be 32 since it is MD5 Hash
{
$key = $_GET['key'];
}
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Activation Form</title>
<link rel="stylesheet" type="text/css" href="../schedule/include/formats.css"/>
</head>
<body>
<div class="shadow"><div class="header"></div></div>
<?php
if (isset($email) && isset($key)) {
// Update the database to set the "activation" field to null and "Active" field to 1.
$query_activate_account = "UPDATE UserTbl SET Activation = NULL, Active = '1' WHERE(EmailAddress ='$email' AND Activation='$key')LIMIT 1";
$result_activate_account = mysql_query($query_activate_account, $link);
// Print a customized message:
if (mysql_affected_rows($link) == 1) //if update query was successfull
{
echo '<fieldset id="standardForm">Your account is now active. You may now <a href="login.php">Log in</a></fieldset>';
} else {
echo '<fieldset id="standardForm">Oops !Your account could not be activated. Please recheck the link or contact the system administrator.</fieldset>';
}
mysql_close($link);
} else {
echo '<fieldset id="standardForm">An Error Occured. I have no idea where, but an error did occur.</fieldset>';
}
?>
</body>
</html>The same linked resource has a login page that I will want to use and adapt for my own purposes (including accommodation of hashed passwords). So... it is important for me to make sure I'm getting the formatting correct before attempting to adapt another file.
Thanks Much: - Pavilion