Tequila |
04-11-2009 11:05 AM |
RE: Failed Login
I did exactly what the mod set up said to do (including the bit added to register2).
Here's my register2 file:
PHP Code:
<?php
// Easy Adoptables Script by Brandon Rusnak // Get our includes out of the way
include("inc/functions.php"); include("inc/config.php"); include("inc/settings.php"); include("inc/nbbc.php"); // BBCODE Parser $bbcode = new BBCode;
// Define our Template File
$file = $current_theme;
//Get the user's data from the form
$username = $_POST["username"]; $pass1 = $_POST["pass1"]; $pass2 = $_POST["pass2"]; $email = $_POST["email"]; $tos = $_POST["tos"];
//Protect the database $username = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $username); $pass1 = preg_replace("/[^a-zA-Z0-9s]/", "", $pass1); $pass2 = preg_replace("/[^a-zA-Z0-9s]/", "", $pass2); $email = preg_replace("/[^a-zA-Z0-9@._-]/", "", $email); $tos = preg_replace("/[^a-zA-Z0-9s]/", "", $tos);
// Connect to our database
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql database!'); mysql_select_db($dbname);
// Should we show the extra pages in the nav bar?
$link1 = ""; if($show_extra_page1 == "yes"){ $link1 = "<li><a href='$extra_page1_link'>$extra_page1_name<span class='tab-l'></span><span class='tab-r'></span></a></li>"; }
$link2 = ""; if($show_extra_page2 == "yes"){ $link2 = "<li><a href='$extra_page2_link'>$extra_page2_name<span class='tab-l'></span><span class='tab-r'></span></a></li>"; }
// Do the template changes and echo the ready template
$template = file_get_contents($file); $template = replace(':SITETITLE:',$site_title,$template); $template = replace(':SITENAME:',$site_name,$template); //$template = replace(':ARTICLETITLE:',$article_title,$template); $template = replace(':ARTICLEDATE:',date('Y-m-d'),$template); //$template = replace(':ARTICLECONTENT:',$article_content,$template); $template = replace(':LINK1:',$link1,$template); $template = replace(':LINK2:',$link2,$template); $template = replace(':LINK3:',$link3,$template);
//Get the featured adoptable... $featured = getfeatured(); $template = replace(':FEATURED:',$featured,$template);
//Ad Management $header = @file_get_contents("ads/header.txt"); $footer = @file_get_contents("ads/footer.txt"); $tower = @file_get_contents("ads/tower.txt");
$header = stripslashes($header); $footer = stripslashes($footer); $tower = stripslashes($tower);
$template = replace(':HEADERAD:',$header,$template); $template = replace(':FOOTERAD:',$footer,$template); $template = replace(':TOWERAD:',$tower,$template);
//Is the user logged in? $isloggedin = "no"; if ($isloggedin == "yes"){
} else{
//User is not logged in $template = replace(':WELCOMEORREGISTER:','<u>Member Login:</u>',$template); $loginform = "<form name='form1' method='post' action='login.php'> <p>Username: <input name='username' type='text' id='username'> </p> <p>Password: <input name='password' type='password' id='password'> </p> <p> <input type='submit' name='Submit' value='Submit'> </p> <p>Don't have an account?<br> <a href='register.php'>Register Free</a> </p> </form> "; $template = replace(':LOGINORACCT:', $loginform ,$template); }
//Check for errors... if($username == "" or $pass1 == "" or $pass2 == "" or $email == ""){ $template = replace(':ARTICLETITLE:','Error',$template); $template = replace(':ARTICLECONTENT:','A required form element was left blank. Please <a href="register.php">go back</a> and fill out all the form elements and try again.',$template); echo $template; die();
}
if($tos != "tosyes"){ $template = replace(':ARTICLETITLE:','Error',$template); $template = replace(':ARTICLECONTENT:','You did not agree to the Terms of Service. You must agree to the TOS to use this site.',$template); echo $template; die(); }
if($pass1 != $pass2){ $template = replace(':ARTICLETITLE:','Error',$template); $template = replace(':ARTICLECONTENT:','Your passwords do not match. Please <a href="register.php">go back</a> and correct this issue.',$template); echo $template; die(); }
//Check that username does not already exist
$query = "SELECT * FROM users WHERE username = '$username'"; $result = @mysql_query($query); $num = @mysql_numrows($result);
//Loop out code $i=0; while ($i < 1) {
$luser=@mysql_result($result,$i,"username");
$i++; }
$luser = strtolower($luser); $u2 = $str = strtolower($username);
if($luser == $u2){ $template = replace(':ARTICLETITLE:','Error',$template); $template = replace(':ARTICLECONTENT:','Your username has been taken. Please <a href="register.php">go back</a> and select a different username.',$template); echo $template; die(); }
//All checks pass, create the user $pass1 = md5($pass1); //MD5 the password mysql_query("INSERT INTO users VALUES ('', '$username', '$pass1','$email','free','0')");
$template = replace(':ARTICLETITLE:','Success',$template); $template = replace(':ARTICLECONTENT:','Your account has been created with the username '.$username.'. <a href="login.php">Click here to log in to your account.</a>',$template);
echo $template; ?>
and my MySQL table setup (screenshot, I added items (but that may be my problem...) as I want the items to be for the users and their pets).
http://www.rusnakweb.com/forum/attachment.php?aid=157
[attachment=157]
|