0

I have a file login.php

<?php
session_start();
include_once "../lib/opendb.php";
include_once "products_make.php";
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$email= $_GET['email'];
$pswd= $_GET['pswd'];

if ($email=="admin") {
    $arr['id']=0;
    $arr['judge_name']="Administrator";    
    $_SESSION['gVars']=$arr;
    if ( $pswd == "2755") {
        $arr['status']="admin";
    }
    else {
        $arr['status']="error";
    }
}
else {
  $db= connect_db();
  $sql= "SELECT id,judge_name,category_code,cellphone FROM judges WHERE email='$email'";

//  $db= connect_db();
  $rs = mysql_query( $sql);
  if (mysql_num_rows($rs) >0 ) {
    $arr= mysql_fetch_assoc($rs) ;

    // test the pin

    $pin = substr($arr['cellphone'],-4);
    if ($pin==$pswd) {

      $_SESSION['gVars']=$arr;
      $arr['status']="success";

    // check, if the scoreboard ready for this judge
      test_scoringboard($arr['category_code'], $arr['id']) ;
      echo "<a href='a/menu.php'></a>";
    }
    else {
      $arr['status']="error";    

    }
  }
  else {
    $arr['status']="error";   
  }
}
print json_encode($arr);

close_db($db);
?>

and i want to show the other file (red:menu.php)

but when I am login and the username and password are true, the page don't show menu.php, but "undefined". So what's the solution. Please help me. Thank you.

2
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by labibah
0

Dear labibah, I will consider that you are not using "admin" as username, because this is in the first if which doesn't contain the echo for the menu.php link.

else {
      $db= connect_db();
      $sql= "SELECT id,judge_name,category_code,cellphone FROM judges WHERE email='$email'";

    //  $db= connect_db();
      $rs = mysql_query( $sql);

      /*TRY TO ECHO THE NUMBER OF ROWS FOUND, MAYBE THE LOGIN IS NOT SUCCESSFUL AS YOU ARE THINKING*/
      echo mysql_num_rows($rs);

      if (mysql_num_rows($rs) >0 ) {
        $arr= mysql_fetch_assoc($rs) ;



    // test the pin

    $pin = substr($arr['cellphone'],-4);

    /*ECHO THE PIN AND PSWD, MAYBE THERE IS AN UNEXPECTED LOGICAL ERROR*/
    echo "Are they equal: " . $pin . " == " . $pswd;

    if ($pin==$pswd) {

      $_SESSION['gVars']=$arr;
      $arr['status']="success";

    // check, if the scoreboard ready for this judge
      test_scoringboard($arr['category_code'], $arr['id']) ;
      echo "<a href='a/menu.php'></a>";
    }
    else {
      $arr['status']="error";    

    }
  }
  else {
    $arr['status']="error";   
  }
}

Please check my comments and the two echo debuggin that I've added in your code
Good Luck

0

this is the json

{"id":0,"judge_name":"Administrator","status":"admin"}


Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in C:\xampp\htdocs\inaicta\lib\opendb.php on line 45
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.