redarrow Posted July 3, 2006 Share Posted July 3, 2006 try this and post the same thing<?phpsession_start();require_once("incs/conn.inc.php"); if(isset($_POST['submit'])) { echo "Right after Submit is Accepted"; $sql1= "SELECT * FROM administrators WHERE username = '".$_POST['username']."' and password = '".$_POST['password']."'";echo $sql1;//debug sql1$rez = mysql_query($sql1) or die("There was a problem with the query: $sql1" . mysql_error());echo $rez; // debug if(mysql_num_rows($rez) > 0){ echo "Right after checking if for numrows"; $row = mysql_fetch_row($rez) or die("The mysql fetch row is not working"); session_register('administrator_portal');//used single quote $_SESSION['administrator_portal'] = $row[0]; $_SESSION['superuser'] = $row[1]; $update="update `administrators` set `LastLoginAdmin`=Now() where id_administrator=".$_SESSION['administrator_portal'];echo $update;//debug $result=mysql_query($update); //removed $connecho $result;//debug header("Location: download2.php"); exit; }else{ $msg = "The username or password are wrong."; } } if($_GET['erroare'] == "nr"){ $msg = "Ne pare rau insa sesiunea dumneavostra a expirat.You must log on."; }?> Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52603 Share on other sites More sharing options...
Ninjakreborn Posted July 3, 2006 Author Share Posted July 3, 2006 [quote]Right after Submit is AcceptedSELECT * FROM administrators WHERE username = '' and password = ''Resource id #4 [/quote] That is the message I got from that one? Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52609 Share on other sites More sharing options...
redarrow Posted July 3, 2006 Share Posted July 3, 2006 try this for some reason were not picking up username and password.<?phpsession_start();require_once("incs/conn.inc.php");$username=($_POST['username']);$password=($POST['password']);echo $username;echo $password; if(isset($_POST['submit'])) { echo "Right after Submit is Accepted"; $sql1= "SELECT administrators.id_administrator,administrators.superuser FROM administrators WHERE username = '$username' and password = '$password' ";echo $sql1;//debug sql1$rez = mysql_query($sql1) or die("There was a problem with the query: $sql1" . mysql_error());echo $rez // debug if(mysql_num_rows($rez) > 0){ echo "Right after checking if for numrows"; $row = mysql_fetch_row($rez) or die("The mysql fetch row is not working"); session_register('administrator_portal');//used single quote $_SESSION['administrator_portal'] = $row[0]; $_SESSION['superuser'] = $row[1]; $update="update `administrators` set `LastLoginAdmin`=Now() where id_administrator=".$_SESSION['administrator_portal'];echo $update;//debug $result=mysql_query($update); //removed $connecho $result;//debug header("Location: download2.php"); exit; }else{ $msg = "The username or password are wrong."; } } if($_GET['erroare'] == "nr"){ $msg = "Ne pare rau insa sesiunea dumneavostra a expirat.You must log on."; }?> Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52613 Share on other sites More sharing options...
Ninjakreborn Posted July 3, 2006 Author Share Posted July 3, 2006 [quote]Right after Submit is AcceptedSELECT administrators.id_administrator,administrators.superuser FROM administrators WHERE username = '' and password = '' Resource id #4[/quote]I don't understand why this is happening, is this normal. I knew debugging was hard, but I am confused, This is what I got when I changed the code, this is what outputted? Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52614 Share on other sites More sharing options...
redarrow Posted July 3, 2006 Share Posted July 3, 2006 have you trid my above code please thanks.display errow oki dont understand it when you login in have you first got the correct name="username" and password in the form.secoundly have you got the sessions registred to the admin sessionsexamplealter this code to your needs ok$query="SELECT * from xxx where xxx='$xxx' and xxx='$xxx'";$result=mysql_query($query)or die("sorry mysql problam");while($row=mysql_fetch_array($result)) {if(mysql_num_rows($row) == 1) {$id=$row["id"];$name=$row["name"];$password=$row["password"];session_register('id');session_register('name');session_register('password');if($row["level"]=="promotor_member"){header("location: members_main_page.php?id=$id");exit;}}} Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52620 Share on other sites More sharing options...
Ninjakreborn Posted July 3, 2006 Author Share Posted July 3, 2006 Yes I tried your code exactly like above, also I do have the right username and password. I am beginning to think this dude that wrote teh script is a dumb fuck and i may rewrite the whole thing, or something I don't understand what is going on.I don't know why it's not working. I need a few things to happen, I don't understand, when I register it logs in a username and password, and even with the admin it doesn't work, I don't know about the session thing, where do I find that at, I showed you all teh code i Had for all the related pages, where do I register those sessions at. Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52623 Share on other sites More sharing options...
redarrow Posted July 3, 2006 Share Posted July 3, 2006 the code i provided is the code you need just alter the select statement and try ok.$query="SELECT * from whatever where name='$username' and password='$password'";$result=mysql_query($query)or die("sorry mysql problam");while($row=mysql_fetch_array($result)) {if(mysql_num_rows($result) == 1) {$id=$row["id"];$name=$row["name"];$password=$row["password"];session_register('id');session_register('name');session_register('password');if($row["username"]=="what ever the name of the user"){echo"your logged in user admin";exit;}}} Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52628 Share on other sites More sharing options...
Ninjakreborn Posted July 3, 2006 Author Share Posted July 3, 2006 I mean how do I work that into my current script, see here I see what to do, and what you showed me, but I have the alter script in the other one or something where does that fit in? Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52629 Share on other sites More sharing options...
redarrow Posted July 3, 2006 Share Posted July 3, 2006 use this on the page you got know okremember to make a backup of your existing code.<? session_start();$query="SELECT * from administrators where adminfirstname='$adminfirstname' and password='$password'";$result=mysql_query($query)or die("sorry mysql problam");while($row=mysql_fetch_array($result)) {if(mysql_num_rows($result) == 1) {$id=$row["id"];$adminfirstname=$row["adminfirstname"];$password=$row["password"];session_register('id');session_register('name');session_register('password');if($row["adminfirstname"]=="what ever the name of the user"){echo"your logged in user admin";exit;}}}else{echo"sorry not logged in";exit;}?> Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52631 Share on other sites More sharing options...
Ninjakreborn Posted July 3, 2006 Author Share Posted July 3, 2006 I don't understand. I could do this, but the script is supposed to check and see whether a username exists in the password, I am very confused:S:S Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52635 Share on other sites More sharing options...
redarrow Posted July 3, 2006 Share Posted July 3, 2006 edited to match your code ok<? session_start();$query="SELECT * from administrators where adminfirstname='$adminfirstname' and adminlastname='$adminlastname'";$result=mysql_query($query)or die("sorry mysql problam");while($row=mysql_fetch_array($result)) {if(mysql_num_rows($row) == 1) {$id=$row["id"];$adminfirstname=$row["adminfirstname"];$adminlastname=$row["adminlastname"];session_register('id');session_register('adminfirstname');session_register('adminlastname');}elseif($row["adminfirstname"]=="what ever the name of the user"){echo"your logged in user admin";exit;}elseif(mysql_num_rows($row) == 0) {echo"sorry not logged in";exit;}}}?> Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52638 Share on other sites More sharing options...
Ninjakreborn Posted July 3, 2006 Author Share Posted July 3, 2006 I tried exactly what you said and got a blank white screen. Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52641 Share on other sites More sharing options...
redarrow Posted July 3, 2006 Share Posted July 3, 2006 there you go<? session_start();$id_administrator=($_POST["id_administrator"]);$adminfirstname=($_POST["adminfirstname"]);$adminlastname=($_POST["adminlastname"]);if($_POST['submit']){$query="SELECT * from administrators where adminfirstname='$adminfirstname' and id_administrator='$id_administrator'";$result=mysql_query($query)or die("sorry mysql problam");while($row=mysql_fetch_array($result)) {if(mysql_num_rows($row) == 1) {$id_administrator=$row["id_administrator"];$adminfirstname=$row["adminfirstname"];$adminlastname=$row["adminlastname"];session_register('id_administrator');session_register('adminfirstname');session_register('adminlastname');echo"your logged in user admin";exit;}else{echo"sorry not logged in";exit;} } } }?> Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52645 Share on other sites More sharing options...
Ninjakreborn Posted July 3, 2006 Author Share Posted July 3, 2006 Still not working. Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52647 Share on other sites More sharing options...
redarrow Posted July 3, 2006 Share Posted July 3, 2006 [b]use this it will work ok form provided[/b]login_result.php<? session_start();$id_administrator=($_POST["id_administrator"]);$adminfirstname=($_POST["adminfirstname"]);$adminlastname=($_POST["adminlastname"]);if($_POST['submit']){$query="SELECT * from administrators where adminfirstname='$adminfirstname' and id_administrator='$id_administrator'";$result=mysql_query($query)or die("sorry mysql problam");while($row=mysql_fetch_array($result)) {if(mysql_num_rows($row) == 1) {$id_administrator=$row["id_administrator"];$adminfirstname=$row["adminfirstname"];$adminlastname=$row["adminlastname"];session_register('id_administrator');session_register('adminfirstname');session_register('adminlastname');echo"your logged in user admin";exit;}else{echo"sorry not logged in";exit;} } } }?> formlognin.php<html> <head><title>login page</title><body><h1>login please!</h1><form method="post" action="login_result.php"><br>firstname:<br><input type="text" name="adminfirstname"><br>lastname:<br><input type="text" name="adminlastname"><br><input type="hidden" name="id_administrator"><br><input type="submit" value="Login"><br></form></body></html> Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52651 Share on other sites More sharing options...
Ninjakreborn Posted July 3, 2006 Author Share Posted July 3, 2006 I am confused what do you meanshould I just rebuild this entire thing from scratch and learn how, I don't understand you said put it in a seperate page, and include it in my current page, or just run the form to it or what? Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52654 Share on other sites More sharing options...
Ninjakreborn Posted July 3, 2006 Author Share Posted July 3, 2006 Thanks for all the help so far as well it's greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52657 Share on other sites More sharing options...
redarrow Posted July 3, 2006 Share Posted July 3, 2006 I have crated the admin login for the database you got follow the instructions above ok.all you got to do is add the database ok. Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52658 Share on other sites More sharing options...
Ninjakreborn Posted July 4, 2006 Author Share Posted July 4, 2006 Thanks for the help, I am glad it finally works. Link to comment https://forums.phpfreaks.com/topic/13546-i-have-3-questions/page/2/#findComment-52970 Share on other sites More sharing options...
Recommended Posts