error require

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hrubos
Forum Contributor
Posts: 172
Joined: Sat Oct 07, 2006 3:44 pm

error require

Post by hrubos »

how to do to use $login because I have received error "error require "'autorizace.php'' and Undetermine variable $login
Autorizace

Code: Select all

<?php
$password = $_POST['password'];
$login = $_POST['login'];
session_start();
$MC = MySQL_Connect("localhost", "root", "");
$MS = MySQL_Select_DB("");
if ((IsSet($login)) AND (IsSet($password)) ){

//login($login,$password);
$_SESSION['valid_user']=$login;

$p = MD5($password);
//for only admin
$MSQ = MySQL_Query("SELECT * FROM users WHERE (login LIKE '$login') AND (password LIKE '$p') ");
$num_row = mysql_num_rows($MSQ);

if ($num_row == 1) {
        
                $row = mysql_fetch_array($MSQ);
                $id = $row['id'];
                $isAdmin = $row['isAdmin'];
                $return_array = array($id,$isAdmin);
           if($isAdmin=='1'){
           
                    echo "you are admin";
              echo '<p> <a href="autorizace.php?lo=true">Odhlásit se</a> </p>';
              $_SESSION['valid_user']=$login;
                     return $return_array;
                    }
          else if($isAdmin =='2' ) {
       
                  echo '<p> <a href = "http://localhost/BP/Room/reservation_display.php">Rezervace</a></p>';
                	echo "		<a href='../student/edit_profile.php'>Edit </a>";
                   $_SESSION['valid_user']=$login;      
                      echo '<p> <a href="autorizace.php?lo=true">Odhlásit se</a> </p>';
                 return $return_array;
                }         
}
}
Edit

Code: Select all

<html>
  <head><title>Rezevace</title></head>
  <body>
<table border =1>
<tr>

<td>First name</td>
<td>Last name</td>

<?php
session_start();
require('autorizace.php');
$MC = MySQL_Connect("localhost", "root", "");
$MS = MySQL_Select_DB("");
login($login,$password);	
$query = "SELECT last_name, first_name FROM student WHERE rc_student = '$login'";
$result  = mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;

while($i<$num){
	$first_name=mysql_result($result,$i,"first_name");
	$last_name=mysql_result($result,$i,"last_name");
	?>
<tr>
<?php
//echo "<td>$id_numberRoom</td>" ;
echo "<td>$first_name</td>" ;
echo "<td>$last_name</td>";
$i++;
}
?>
</tr>
<p> <a href="http://localhost/BP/autorizace/autorizace.php?lo=true">log out</a> </p>
</body>
</html>
Oly
Forum Newbie
Posts: 2
Joined: Sun Dec 10, 2006 8:18 pm

Post by Oly »

1. What directory is this and the require(); script in?
2. Is it spelt right?
3. Usually you can find whats wrong for an error :D
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Make sure autorizace.php is in the same directory
Post Reply