first error message it gives
Forbidden
You don't have permission to access /html/"view.php on this server.
the directory is not protected as other all files of the directory can be accessed easily with out any message
htaccess is also not used ...
the problem is used very peculiar...
full code
login.php
Code:
<?php
ob_start();
//require_once ('includes/config.inc');
$page_title = 'Login';
if (isset($_POST['submit'])) {
require_once ('mysql_connect1.php');
if (empty($_POST['username'])) {
$u = FALSE;
echo '
<font color="red" size="+1">You forgot to enter your username!</font></p>';
} else {
$u = escape_data($_POST['username']);
}
if (empty($_POST['password'])) {
$p = FALSE;
echo '
<font color="red" size="+1">You forgot to enter your password!</font></p>';
} else {
$p = escape_data($_POST['password']);
}
if ($u && $p) { // If everything's OK.
// Query the database.
$query = "SELECT user_id,name FROM students WHERE username='$u' AND password=PASSWORD('$p')";
$result = @mysql_query ($query);
$row = mysql_fetch_array ($result);
if ($row) {
$_SESSION['name'] = $row[1];
$_SESSION['user_id'] = $row[0];
ob_end_clean();
header ("Location: *" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) .
"\"view.php?aid={$row['user_id']}\">");
exit();
} else { // No match was made.
echo '
<font color="red" size="+1">The username and password entered do not match those on file.</font></p>';
}
mysql_close();
} else {
echo '
<font color="red" size="+1">Please try again.</font></p>';
}
}
?>
<h1>Login</h1>
Your browser must allow cookies in order to login.</p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset>
[b]User Name:[/b] <input type="text" name="username" size="10" maxlength="20" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /></p>
[b]Password:[/b] <input type="password" name="password" size="20" maxlength="20" /></p>
<div align="center"><input type="submit" name="submit" value="Login" /></div>
</form>
view.php
Code:
<?
//require_once ('includes/config.inc');
require_once ('/mysql_connect1.php');
$page_title = 'view';
if (!isset($_SESSION['name'])) {
header ("Location: *" . $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']) . "/login.php");
exit();
}
else
{
if (isset($_GET['uid'])) {
$query = "SELECT * FROM students WHERE user_id = {$_GET['uid']}";
$result=@mysql_query($query);
if (mysql_num_rows($result)) { // if there are any rows of data, fetch the data
if (mysql_fetch_assoc($result)) {
echo '
Name: ' . $row['name'] . '
';
echo '
Email: ' . $row['email'] . '
';
echo '
Address: ' . $row['address'] . '
';
} else {
echo '
No data returned!</p>';
}
} else {
echo '
Student not found.</p>';
}
} else {
echo '
Missing uid!</p>';
}
}
?>
whats the matter
i think the problem is with
header ("Location: *" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) .
"\"view.php?aid={$row['user_id']}\">");
of login.php if i replace that view.php as index...or any other files just works fine...
all files are in one directory
html inside www
i am using easyphp 1-8 on windows...
the actual project is
1)the register page is working fine...loginpage and that view page has this problem ....
and other are teacer login and view which will be solved if this problem get solved as it uses same logic but only different table
2)other give assignment ...is a form connected to database ...and view assignment...is just same as view ..it retrieves assignment according to teacherid ...$_GET['tid']
3)and i have combo box for listing data of students table and next combo for listing teachers ...(i have not used seach)
so its just 3 good pages that will complete my application ...that also i have coded all just there are some errors so....
by the way have you seen this kind of application development in any books(i will buy them if locally available),sites (to printed)..or even rady made source code download...which might solve my problem.
any help
its just a test ...non commercial university project i am trying to develop
any php expert
saha