djclewes Posted March 30, 2014 Share Posted March 30, 2014 here is my code and i need help with why it is not letting people register or login. Once logged in i want it to take the logged in users to area.php. any help will be appriciated. <?php session_start(); ob_start(); //Include the database connection file include "config.php"; //Check to see if the submit button has been clicked to process data if(isset($_POST["submitted"]) && $_POST["submitted"] == "yes") { //Variables Assignment $username = trim(strip_tags($_POST['username'])); $user_password = trim(strip_tags($_POST['passwd'])); $encrypted_md5_password = md5($user_password); $validate_user_information = mysql_query("select * from `friendship_system_users_table` where `username` = '".mysql_real_escape_string($username)."' and `password` = '".mysql_real_escape_string($encrypted_md5_password)."'"); //Validate against empty fields if($username == "" || $user_password == "") { $error = '<br><div class="info">Sorry, all fields are required to log into your account. Thanks.</div><br>'; } elseif(mysql_num_rows($validate_user_information) == 1) //Check if the information of the user are valid or not { //The submitted info of the user are valid therefore, grant the user access to the system by creating a valid session for this user and redirect this user to the welcome page $get_user_information = mysql_fetch_array($validate_user_information); $_SESSION["VALID_USER_ID"] = $username; $_SESSION["USER_FULLNAME"] = strip_tags($get_user_information["fullname"]); header("location: area.php"); } else { //The submitted info the user are invalid therefore, display an error message on the screen to the user $error = '<br><div class="info">Sorry, you have provided incorrect information. Please enter correct user information to proceed. Thanks.</div><br>'; } } ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>A Cool Login System With PHP MySQL & jQuery | Tutorialzine demo</title> <link rel="stylesheet" type="text/css" href="demo.css" media="screen" /> <link rel="stylesheet" type="text/css" href="login_panel/css/slide.css" media="screen" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <!-- PNG FIX for IE6 --> <!-- http://24ways.org/2007/supersleight-transparent-png-in-ie6 --> <!--[if lte IE 6]> <script type="text/javascript" src="login_panel/js/pngfix/supersleight-min.js"></script> <![endif]--> <script src="login_panel/js/slide.js" type="text/javascript"></script> </head> <body> <!-- Panel --> <div id="toppanel"> <div id="panel"> <div class="content clearfix"> <div class="left"> <p><img alt="" height="136" src="http://chatanrelax.co.uk/images/logo.gif" width="205" /></p> </div> <div class="left"> <!-- Login Form --> <center> <div class="vpb_main_wrapper"> <br clear="all"> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <div style="width:115px; padding-top:10px;float:left;" align="left">Your Username:</div> <div style="width:300px;float:left;" align="left"> <input type="text" name="username" id="username" value="" class="auto-style1" style="width: 223px"></div><br clear="all"><br clear="all"> <div style="width:115px; padding-top:10px;float:left;" align="left">Your Password:</div> <div style="width:300px;float:left;" align="left"> <input type="password" name="passwd" id="passwd" value="" class="auto-style1" style="width: 223px"></div><br clear="all"><br clear="all"> <div style="width:300px;float:left;" align="left"> <input type="hidden" name="submitted" id="submitted" value="yes"> <input type="submit" name="submit" value="Login" style="margin-right:50px;" class="bt_login"> </div> </form> <br clear="all"><br clear="all"> <div style="width:450px;float:left;" align="left"><?php echo $error; ?></div><br clear="all"> </div> </center> </div> <div class="left right"> <!-- Register Form --> <center> <div class="vpb_main_wrapper"> <br clear="all"> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <div style="width:115px; padding-top:10px;float:left;" align="left">Your Username:</div> <div style="width:300px;float:left;" align="left"> <input type="text" name="username" id="username" value="<?php echo strip_tags($_POST["username"]); ?>" class="vpb_textAreaBoxInputs" style="width: 223px"></div><br clear="all"><br clear="all"> <div style="width:115px; padding-top:10px;float:left;" align="left">Email Address:</div> <div style="width:300px;float:left;" align="left"> <input type="text" name="email" id="email" value="<?php echo strip_tags($_POST["email"]); ?>" class="vpb_textAreaBoxInputs" style="width: 223px"></div><br clear="all"><br clear="all"> <div style="width:115px; padding-top:10px;float:left;" align="left">Desired Password:</div> <div style="width:300px;float:left;" align="left"><input type="password" name="passwd" id="passwd" value="" class="vpb_textAreaBoxInputs" style="width: 223px"></div><br clear="all"><br clear="all"> <input type="submit" name="submit" id="" value="Register" class="bt_register"> <input type="hidden" name="submitted" id="submitted" value="yes"> </form> <br clear="all"><br clear="all"> <div style="width:450px;float:left;" align="left"><?php echo $error; ?></div><br clear="all"> </div> </center> <!-- Code Ends --> </div> </div> </div> <!-- /login --> <!-- The tab on top --> <div class="tab"> <ul class="login"> <li class="left"> </li> <li>Hello Guest!</li> <li class="sep">|</li> <li id="toggle"> <a id="open" class="open" href="#">Log In | Register</a> <a id="close" style="display: none;" class="close" href="#">Close Panel</a> </li> <li class="right"> </li> </ul> </div> <!-- / top --> </div> <!--panel --> <div class="pageContent"> <div id="main"> <div class="container"> </div> <div class="container"> <div class="clear"></div> </div> </div> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/287395-help-with-login-script-phphtml/ Share on other sites More sharing options...
mac_gyver Posted March 30, 2014 Share Posted March 30, 2014 here is my code and i need help with why it is not letting people register or login. you would start by determining why the registration process is not working. the code you posted doesn't contain the php code for that process. we would also need to know what sort of errors or symptoms you are getting that leads you to believe that registration is not working. Quote Link to comment https://forums.phpfreaks.com/topic/287395-help-with-login-script-phphtml/#findComment-1474440 Share on other sites More sharing options...
djclewes Posted March 30, 2014 Author Share Posted March 30, 2014 (edited) i look in phpadmin and it does not show any users in the databse. it also when you try and login does not take you to area.php. feel free to try and register your self at chatanrelax.co.uk Edited March 30, 2014 by djclewes Quote Link to comment https://forums.phpfreaks.com/topic/287395-help-with-login-script-phphtml/#findComment-1474448 Share on other sites More sharing options...
boompa Posted March 30, 2014 Share Posted March 30, 2014 The tutorial you're following is old and uses deprecated functions as well as a very poor database hashing mechanism. I suggest you take a look at this one: http://forums.devshed.com/php-faqs-stickies-167/program-basic-secure-login-system-using-php-mysql-891201.html Quote Link to comment https://forums.phpfreaks.com/topic/287395-help-with-login-script-phphtml/#findComment-1474452 Share on other sites More sharing options...
djclewes Posted March 31, 2014 Author Share Posted March 31, 2014 to many connections is what i get there Quote Link to comment https://forums.phpfreaks.com/topic/287395-help-with-login-script-phphtml/#findComment-1474475 Share on other sites More sharing options...
djclewes Posted March 31, 2014 Author Share Posted March 31, 2014 got it working and i got it working on my script thank you. everything is falling into place nicely. Quote Link to comment https://forums.phpfreaks.com/topic/287395-help-with-login-script-phphtml/#findComment-1474476 Share on other sites More sharing options...
Strider64 Posted March 31, 2014 Share Posted March 31, 2014 Something tells me that djclewes will be back with further problems. Just a hunch.... Quote Link to comment https://forums.phpfreaks.com/topic/287395-help-with-login-script-phphtml/#findComment-1474480 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.