Jump to content

I have 3 questions


Ninjakreborn

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.";
  }
?>
Link to comment
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.";
  }
?>
Link to comment
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?
Link to comment
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;
}
}
}

Link to comment
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.
Link to comment
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;
}
}
}
Link to comment
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;
}

?>
Link to comment
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;
}
}
}




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

Guest
This topic is now closed to further replies.
×
×
  • Create New...

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.