I have gone through the code in Kevin Yank's article. When I try to register a user I get this error.
Forbidden
You don't have permission to access /folder/<br /><b>Notice</b>: Undefined variable: editFormAction in <b>c:/easyphp1-7/www/folder/tmpdypps2lh38.php</b> on line <b>25</b><br /> on this server.
As I was going through the code I was adapting it to fit with my settings.
What might this mean?
<?php // accesscontrol.php
include_once 'common.php';
include_once 'db.php';
session_start();
//At this point, the user's login details should be available whether they were just submitted from a login form
//(in the $_POST array) or stored in the user's session (in the $_SESSION array).
//The script pulls the login credentials out of either the $_POST or the $_SESSION array:
$uid = isset($_POST['email_ID']) ? $_POST['email_ID'] : $_SESSION['email_ID'];
$pwd = isset($_POST['pwdID']) ? $_POST['pwdID'] : $_SESSION['pwdID'];
if(!isset($uid)) {
?>
<!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Please Log In for Access </title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1> Login Required </h1>
<p>You must log in to access this area of the site. If you are
not a registered user, <a href="signup.php">click here</a>
to sign up for instant access!</p>
<p><form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="log_frm" id="log_frm">
User ID: <input name="email_ID" type="text" id="email_ID" size="8" />
Password: <input name="pwdID" type="password" id="pwdID" SIZE="8" />
<input type="submit" value="Log in" />
</form></p>
</body>
</html>
<?php
exit;
}
$_SESSION['email_ID'] = $uid;
$_SESSION['pwdID'] = $pwd;
dbConnect("gymtv");
$sql = "SELECT * FROM users WHERE
Email = '$uid' AND Password = PASSWORD('$pwd')";
$result = mysql_query($sql);
if (!$result) {
error('A database error occurred while checking your '.
'login details.\\nIfhis error persists, please '.
'contact [email]blah@blah.com[/email].');
}
if (mysql_num_rows($result) == 0) {
unset($_SESSION['nUser_email']);
unset($_SESSION['nUser_password']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Access Denied </title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1> Access Denied </h1>
<p>You do not have permission to access these pages.<br>
Click <a href="self_service.php">here</a> to return to<br>
the self service point.</p>
</body>
</html>
<?php
exit;
}
$username = mysql_result($result,0,'Firstname');
?>
<?php // signup.php
include 'common.php';
include 'db.php';
if (!isset($_POST['submitok'])):
// Display the user signup form
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>New User Registration</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h3>New User Registration Form</h3>
<p><font color="orangered" size="+1"><tt><b>*</b></tt></font>
indicates a required field</p>
<form name="newUser_frm" id="newUser_frm" method="post" action
//problem is here?
[B]="<?php echo $editFormAction; ?>">[/B]
<table width="287" height="132" border="0" cellpadding="1" cellspacing="0">
<tr>
<td width="108" class="news_text">Firstname</td>
<td colspan="2"><input name="nUser_firstname" type="text" id="nUser_firstname" />
* </td>
</tr>
<tr>
<td class="news_text">Lastname</td>
<td colspan="2"><input name="nUser_lastname" type="text" id="nUser_lastname" />
*</td>
</tr>
<tr>
<td class="news_text">Organisation</td>
<td colspan="2"><input name="nUser_Org" type="text" id="nUser_Org" />
*</td>
</tr>
<tr>
<td class="news_text">Email (Username)</td>
<td colspan="2"><input name="nUser_email" type="text" id="nUser_email" />
*</td>
</tr>
<tr>
<td rowspan="2" class="news_text">Address</td>
<td width="147" rowspan="2"><textarea name="nUser_address" cols="18" rows="3" id="nUser_address"></textarea>
</td>
<td width="26">*</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td class="news_text">Postcode</td>
<td colspan="2"><input name="nUser_postcode" type="text" id="nUser_postcode" />
*</td>
</tr>
<tr>
<td class="news_text">Registrar</td>
<td colspan="2"><input name="nUser_registrar" type="text" id="nUser_registrar" />
*</td>
</tr>
<tr>
<td class="news_text"><input name="Usergroup" type="hidden" id="Usergroup" value="visitor" /></td>
<td colspan="2"><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="newUser_frm" />
</form>
</body>
</html>
<?php
else:
// Process signup submission
dbConnect('blah');
//check required form fields are filled in.
//If any variables are found to be empty strings, the script calls the error function
//from common.php to tell the user what went wrong and return to the form
if
($_POST['nUser_firstname']=='' or $_POST['nUser_lastname']==''
or $_POST['nUser_org']=='' or $_POST['nUser_email']==''
or $_POST['nUser_address']=='' or $_POST['nUser_postcode']==''
or $_POST['nUser_registrar']=='') {
error('One or more required fields were left blank.\\n'.
'Please fill them in and try again.');
}
// Check for existing user with the new id
$sql = "SELECT COUNT(*) FROM users WHERE Email = '$_POST[nUser_email]'";
$result = mysql_query($sql);
if (!$result) {
error('A database error occurred in processing your '.
'submission.\\nIf this error persists, please '.
'contact [email]blah@blah.com[/email].');
}
if (@mysql_result($result,0,0)>0) {
error('A user already exists with your chosen username (email).\\n'.
'Please try another.');
}
//The "$newpass" code below generates a random password string to send to new user's email (validates the email-username)
//This works by taking the current time and performing
//an MD5 hash on it. This is basically a one-way cryptographic encoding into a text string,
//which is then chopped to 6 characters using the substr function.
//The result is a 6-character password that would be fairly difficult to guess.
$newpass = substr(md5(time()),0,6);
$sql = "INSERT INTO users SET
Firstname = '$_POST[nUser_firstname]',
Lastname = '$_POST[nUser_lastname]',
Organisation = '$_POST[nUser_org]',
Email = '$_POST[nUser_email]',
Password = PASSWORD('$newpass'),
Address = '$_POST[nUser_address]',
Postcode = '$_POST[nUser_postcode]',
Registrar = '$_POST[nUser_registrar]',
Usergroup = '$_POST[Usergroup]',";
if (!mysql_query($sql))
error('A database error occurred in processing your '.
'submission.\\nIf this error persists, please '.
'contact [email]blah@blah.com[/email].');
// Email the new password to the person.
$message = "We Welcome our Newest Member!
Your personal account for the Members Web Site
has been created! To log in, proceed to the
following address:
[url]http://www.blah.com/members.php[/url]
Your personal login ID and password are as
follows:
username: $_POST[nUser_email]
password: $newpass
You aren't stuck with this password! Your can
change it at any time after you have logged in.
If you have any problems, feel free to contact me at
<blah@blah.com>.
-blah balh
";
mail($_POST['nUser_email'],"Your Password for MEMBERS Website",
$message, "From:blah <blah@blah.com>");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Registration Complete </title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<p><strong>User registration successful!</strong></p>
<p>Your userid and password have been emailed to
<strong><?=$_POST[nUser_email]?></strong>, the email address
you just provided in your registration form. To log in,
click <a href="login.php">here</a> to return to the login
page, and enter your new personal userid and password.</p>
</body>
</html>
<?php
endif;
?>