Jump to content

Archived

This topic is now archived and is closed to further replies.

Ninjakreborn

I have 3 questions

Recommended Posts

try this and post the same thing

<?php
session_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 $conn

echo $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.";
  }
?>

Share this post


Link to post
Share on other sites
[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?

Share this post


Link to post
Share on other sites

try this for some reason were not picking up username and password.

<?php
session_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 $conn

echo $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.";
  }
?>

Share this post


Link to post
Share on other sites
[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?

Share this post


Link to post
Share on other sites
have you trid my above code please thanks.

display errow ok


i 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 sessions


example

alter 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;
}
}
}

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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;
}
}
}

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
use this on the page you got know ok

remember 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;
}

?>

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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;
}
}
}




?>

Share this post


Link to post
Share on other sites
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;
}
}
  }
   }
?>

Share this post


Link to post
Share on other sites

[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;
}
}
  }
   }
?>

form

lognin.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>

Share this post


Link to post
Share on other sites
I am confused what do you mean
should 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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.