Notice: Undefined index: user_id in c:\program files\easyphp1-8\www\html\login.php on line 37
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\html\login.php:37) in c:\program files\easyphp1-8\www\html\login.php on line 37
what is the error
user_id is primary key .Does it need to be index ...as i have forgetten it to make index will
create index....command work...
i tried but it didnt.
and next line erro i have read some where that before header the data should not be sent to browser how can i solve this problem.
Code: Select all
<?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 '<p><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 '<p><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, MYSQL_NUM);
if ($row) {
$_SESSION['name'] = $row[1];
$_SESSION['user_id'] = $row[0];
ob_end_clean();
header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/view.php?uid={$row['user_id']}");
exit();
} else { // No match was made.
echo '<p><font color="red" size="+1">The username and password entered do
not match those on file.</font></p>';
}
mysql_close();
} else {
echo '<p><font color="red" size="+1">Please try again.</font></p>';
}
}
?>
<h1>Login</h1>
<p>Your browser must allow cookies in order to login.</p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset>
<p><b>User Name:</b> <input type="text" name="username" size="10" maxlength="20" value="<?php if
(isset($_POST['username'])) echo $_POST['username']; ?>" /></p>
<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><!-- End of Form -->in second linked page from login
error is
Parse error: parse error, expecting `','' or `';'' in c:\program files\easyphp1-8\www\html\view.php on line 37
if i make line 37 as remarks
than
error
Parse error: parse error, expecting `','' or `';'' in c:\program files\easyphp1-8\www\html\view.php on line 23
complete code
view.php
Code: Select all
<?php.
require_once ('includes/config.inc');
require_once ('../mysql_connect1.php');
$page_title = 'view';
if (!isset($_SESSION['first_name'])) {
header ("Location: http://" . $_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_affected_rows()==1)
{
echo 'Name{$row[‘name’]}<br>';
echo 'Email{$row[‘email’]}<br>';
echo 'Address{$row[‘address’]}<br>';
echo 'phone{$row[‘phone’]}<br>';
echo "<a href=\"results.php?uid1={$row['user_id']}\">results</a>";
}
else
{
echo ‘No such records’;
}
}
else
{
echo ‘system error’;
}
}
mysql_close();
?>by the way how to get those codes in to the scroll box while posting .I Used code bbcode but didnt help...
its long agian...
any way please help about that php
thanks
rami