L Posted June 27, 2007 Author Share Posted June 27, 2007 i took the $start line and put it right under the doctype in my index, and i change the isset. Only one problem is solved, i log in. The main part isn't solved whihc is 3/4 of my page not showing up and the Wrong User or pass echo that shows up when the page is seen before an attempt at logging in. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 27, 2007 Share Posted June 27, 2007 can i have a login to test it and see whats happening? Quote Link to comment Share on other sites More sharing options...
L Posted June 27, 2007 Author Share Posted June 27, 2007 user: cooldude pass: 111111 it sends me to the control panel that isn't working, Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 27, 2007 Share Posted June 27, 2007 it goes to the control pannel fine, show me the control pannel scripts and I can help you a bit there Quote Link to comment Share on other sites More sharing options...
L Posted June 27, 2007 Author Share Posted June 27, 2007 <?php include ('database.php'); //Make the query to the database to get the users information $query = mysql_query("SELECT * FROM users WHERE userid='$userID'")or die(mysql_error()); $row = mysql_fetch_assoc($query); //This is example information that you could echo out. echo '<b>Username:</b> '.$row['username'].'</b><br>'; echo '<b>Email:</b> '.$row['email'].'</b>'; echo '<b>Registration Date:</b> '.$row['date'].'</b>'; ?> EDIT: But what about my index...how come none of it's showing except the login? EDIT 2: Nm, it was just an issue of includes...and i had a session started twice EDIT 3: Changed code to look more like what I want. Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted June 27, 2007 Share Posted June 27, 2007 Wrong. Call the session here and assign your username to sessions already stored. Â Edit: I check ur login i can enter wiath any username did u check it against db. Â Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 27, 2007 Share Posted June 27, 2007 your issue is in your query you use the where UserID = $userID howevre you never defined $userid try adding to the top session_start(); $userID = $_SESSION['UserID']; Â Quote Link to comment Share on other sites More sharing options...
L Posted June 27, 2007 Author Share Posted June 27, 2007 hmm...still blank....and no it looks like it isn't being checked againt database...ill try fixing that EDIT: Here's the code <?php session_start(); $userID = $_SESSION['userid']; include ('database.php'); //Make the query to the database to get the users information $query = mysql_query("SELECT * FROM users WHERE userid='$userID'")or die(mysql_error()); $row = mysql_fetch_assoc($query); //This is example information that you could echo out. echo '<b>Username:</b> '.$row['username'].'</b><br>'; echo '<b>Email:</b> '.$row['email'].'<br />'; echo '<b>Registration Date:</b> '.$row['date'].'</b>'; ?> Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 27, 2007 Share Posted June 27, 2007 you still didn't change the login script to say $_SESSION['userid'] = storage['UserID']; Quote Link to comment Share on other sites More sharing options...
L Posted June 27, 2007 Author Share Posted June 27, 2007 yah but when i do that the page, including the login, disapears...heres my login script. <?php if (ISSET($_POST['sublogin']) || $_POST['sublogin'] == "Login") { // Recreation of variables for later encryption uses the $_POST will be replaced with the decrypted source $username = trim($_POST['username']); $password = trim($_POST['password']); $cryptpassword = md5($password); $url = '/cp.php?user=$username'; $sql="SELECT `userid` FROM $table WHERE username='$username' and password='$cryptpassword'"; //Connects to DB require("database.php"); $table = "users"; // Mysql_num_row is counting table row $count=mysql_num_rows($result); $storage= mysql_fetch_array($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1) { // Registers sesions and redirect to file "login_success.php" //Sessions here  $_SESSION['username'] = $_POST['username'];  $_SESSION['userid'] = storage['UserID'];  header("location: $url"); } else { echo "Wrong Username or Password"; } } ?> <form action="cp.php" method="post"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td></tr><tr><td><input type="text" name="username" size="15" maxlength="30"/></td></tr> <tr><td>Password:</td></tr><tr><td><input type="password" name="password" size="15" maxlength="30"></td></tr><tr><td> <input type="submit" name="sublogin" value="Login" style="font-size: 8pt; color: #000000; word-spacing: 0; margin-top: 0; margin-bottom: 0" /></td></tr> </table> </form> Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted June 27, 2007 Share Posted June 27, 2007 I edit ur both codes try it and let me know: index.php <?php session_start(); if (ISSET($_POST['sublogin'])) { // Recreation of variables for later encryption uses the $_POST will be replaced with the decrypted source $username = trim($_POST['username']); $password = trim($_POST['password']); $cryptpassword = md5($password); $url = '/cp.php?user=$username'; //Connects to DB require("database.php"); $table = "users"; $sql="SELECT * FROM $table WHERE username='$username' and password='$cryptpassword'"; // Mysql_num_row is counting table row $count=mysql_num_rows($result); $storage= mysql_fetch_array($result); $userID= $storage->userID; // If result matched $myusername and $mypassword, table row must be 1 row if(($count, >)>0) { // Registers sesions and redirect to file "login_success.php" //Sessions here  $_SESSION['username'] = $username;  $_SESSION['userid'] = $userID;  header("location: $url"); } else { echo "Wrong Username or Password"; } } ?> <form action="" method="post"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td></tr><tr><td><input type="text" name="username" size="15" maxlength="30"/></td></tr> <tr><td>Password:</td></tr><tr><td><input type="password" name="password" size="15" maxlength="30"></td></tr><tr><td> <input type="submit" name="sublogin" value="Login" style="font-size: 8pt; color: #000000; word-spacing: 0; margin-top: 0; margin-bottom: 0" /></td></tr> </table> </form>  cp.php <?php session_start(); $userID = $_SESSION['userid']; include ('database.php'); //Make the query to the database to get the users information if (isset($userID)){ $query = mysql_query("SELECT * FROM users WHERE userid='$userID'")or die(mysql_error()); $row = mysql_fetch_assoc($query); //This is example information that you could echo out. echo '<b>Username:</b> '.$row['username'].'</b><br>'; echo '<b>Email:</b> '.$row['email'].'<br />'; echo '<b>Registration Date:</b> '.$row['date'].'</b>'; }else { echo "You are not authorized to access this area directly"; } ?> Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 27, 2007 Share Posted June 27, 2007 missing the $ on storage Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 27, 2007 Share Posted June 27, 2007 mmarif4u's version looks good go with that Quote Link to comment Share on other sites More sharing options...
L Posted June 27, 2007 Author Share Posted June 27, 2007 hmm...im getting a blank on the login....meaning nothing is showing at, http://taizkul.prohosts.org/login.php, or the index EDIT: cp.php is working because it's telling me i can;t view the page directly. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 27, 2007 Share Posted June 27, 2007 make sure you got php set to error it will help you a lot Quote Link to comment Share on other sites More sharing options...
L Posted June 27, 2007 Author Share Posted June 27, 2007 im not sure how to do that, if i can with my host Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted June 27, 2007 Share Posted June 27, 2007 Put this at very top of the page before any include or reqiure or sessions. Other sessions will be very top of the page before any html doc or php code. <?php ini_set('display_errors','1'); error_reporting(E_ALL); The rest of code..... ?> Quote Link to comment Share on other sites More sharing options...
L Posted June 27, 2007 Author Share Posted June 27, 2007 odd enough, it isn't showing any errors....maybe it might be cause im logged in?....let me clear my cookies and cache to make sure here's my code to see if i just typed it wrong <?php ini_set('display_errors','1'); error_reporting(E_ALL); session_start(); if (ISSET($_POST['sublogin'])) { // Recreation of variables for later encryption uses the $_POST will be replaced with the decrypted source $username = trim($_POST['username']); $password = trim($_POST['password']); $cryptpassword = md5($password); $url = '/cp.php?user=$username'; //Connects to DB require("database.php"); $table = "users"; $sql="SELECT * FROM $table WHERE username='$username' and password='$cryptpassword'"; // Mysql_num_row is counting table row $count=mysql_num_rows($result); $storage= mysql_fetch_array($result); $userID= $storage->userID; // If result matched $myusername and $mypassword, table row must be 1 row if(($count, >)>0) { // Registers sesions and redirect to file "login_success.php" //Sessions here  $_SESSION['username'] = $username;  $_SESSION['userid'] = $userID;  header("location: $url"); } else { echo "Wrong Username or Password"; } } ?> <form action="" method="post"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td></tr><tr><td><input type="text" name="username" size="15" maxlength="30"/></td></tr> <tr><td>Password:</td></tr><tr><td><input type="password" name="password" size="15" maxlength="30"></td></tr><tr><td> <input type="submit" name="sublogin" value="Login" style="font-size: 8pt; color: #000000; word-spacing: 0; margin-top: 0; margin-bottom: 0" /></td></tr> </table> </form>  BIG EDIT: I used another host and they gave me this error, "Parse error: syntax error, unexpected ',' in /hosted/subs/ulmb.com/i/n/infinitevortex/public_html/login.php on line 25" Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 27, 2007 Share Posted June 27, 2007 just looking at your outputted source its errorring right at the <div class="login">Â check your includes Quote Link to comment Share on other sites More sharing options...
L Posted June 27, 2007 Author Share Posted June 27, 2007 yah, but i'm also looking at the direct page at taizkul.prohosts.org/login.php, which has only the code here in the topic....also I got an error on anotehr host saying, "Parse error: syntax error, unexpected ',' in /hosted/subs/ulmb.com/i/n/infinitevortex/public_html/login.php on line 25" Quote Link to comment Share on other sites More sharing options...
mmarif4u Posted June 27, 2007 Share Posted June 27, 2007 sorry also for this change this line : if(($count, >)>0) Â To this: if(($count, 0) > 0) Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 27, 2007 Share Posted June 27, 2007 Try this code:  <?php session_start(); if (ISSET($_POST['sublogin'])) { // Recreation of variables for later encryption uses the $_POST will be replaced with the decrypted source $username = trim($_POST['username']); $password = trim($_POST['password']); $cryptpassword = md5($password); $url = '/cp.php?user=$username'; //Connects to DB require("database.php"); $table = "users"; $sql="SELECT * FROM $table WHERE username='$username' and password='$cryptpassword'"; $result = mysql_query($sql); $storage= mysql_fetch_assoc($result); $userID= $storage['userID']; // If result matched $myusername and $mypassword, table row must be 1 row if(mysql_num_rows($result) > 0) { // Registers sesions and redirect to file "login_success.php" //Sessions here  $_SESSION['username'] = $username;  $_SESSION['userid'] = $userID;  header("location: $url"); } else { echo "Wrong Username or Password"; } } ?> <form action="" method="post"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td></tr><tr><td><input type="text" name="username" size="15" maxlength="30"/></td></tr> <tr><td>Password:</td></tr><tr><td><input type="password" name="password" size="15" maxlength="30"></td></tr><tr><td> <input type="submit" name="sublogin" value="Login" style="font-size: 8pt; color: #000000; word-spacing: 0; margin-top: 0; margin-bottom: 0" /></td></tr> </table> </form> ?> Quote Link to comment Share on other sites More sharing options...
L Posted June 27, 2007 Author Share Posted June 27, 2007 sweet it's showing up now!!! now i hope it works EDIT: It says I'm not authorized, even though I logged in using registered details....then it pointed me at the url: http://taizkul.prohosts.org/cp.php?user=$username Something is wrong cause shouldn't the $username be L? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 27, 2007 Share Posted June 27, 2007 change your $url to just be cp.php you don't need that extra stuff since you can get it all from sessions/queries Quote Link to comment Share on other sites More sharing options...
L Posted June 27, 2007 Author Share Posted June 27, 2007 it still says im not authorized.....with the url: http://taizkul.prohosts.org/cp.php Quote Link to comment 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.