Redirect to another php page (Header)

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Redirect to another php page (Header)

Postby shiraoka » 02. June 2008 09:24

Could Someone help me with this??? I tried looking on the internet but came up with nothing.=(
Here is my error followed by the code.

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\PGL_Online_IT_Request_System\validatelogin.php:1) in C:\xampp\htdocs\PGL_Online_IT_Request_System\validatelogin.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\PGL_Online_IT_Request_System\validatelogin.php:1) in C:\xampp\htdocs\PGL_Online_IT_Request_System\validatelogin.php on line 2

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\PGL_Online_IT_Request_System\validatelogin.php:1) in C:\xampp\htdocs\PGL_Online_IT_Request_System\validatelogin.php on line 49

<?php
session_start();
session_save_path('./sessions');


//Checking to see if Login submit button was pressed
if (isset($_POST['login']))
{
//variables for DB access
$hostname_db = "localhost";
$database_db = "systemrequest";
$username_db = "username";
$password_db = "password";
$sherwin = mysql_pconnect($hostname_db, $username_db, $password_db) or trigger_error(mysql_error(),E_USER_ERROR);

//variable from user login page
$username = $_POST['username'];
$password = $_POST['password'];


//setting query to access table userProfile for username and password
$query = "SELECT * FROM userProfile";
mysql_select_db($database_db, $db);
$LoginRS=mysql_query($query, $db) or die(mysql_error());
$results = mysql_query($query);

while($row = mysql_fetch_object($results))
{
$validUsername = $row -> username;
$validPassword = $row -> password;
$fname = $row -> firstname;
$lname = $row -> lastname;
//$userID = $row -> userID;

//varifying username and password from DB and matching it with user input
if($username == $validUsername AND $password == $validPassword)
{
//creating session to pass variables through

session_register('firstname');
$_SESSION['fname'] = $fname;
session_register('lastname');
$_SESSION['lname'] = $lname;
session_register('security');
$_SESSION['security'] = "valid";
session_register('userID');
$_SESSION['userID'] = $userID;

header ('location: ./index_main.htm');

}else{

echo '<html> <head><meta http-equiv="refresh" content="3;URL=index.php"></head>
<body><p align="center"><i><font color="#FF0000" size="5"><b> *Error* Invalid login! *Error*</center></font></i></p></b></body></html>';
}
}
}

?>

<html>

<head>
<title>PGL System Request Login</title>
<style type="text/css">
.style1 {
font-size: x-large;
}
.style2 {
border-style: solid;
border-color: #99CCFF;
}
.style3 {
font-weight: bold;
border-style: solid;
border-color: #99CCFF;
}
</style>
</head>

<body>

<div align="center">
<center>
<table border="0" width="75%" bordercolor="#99CCFF" bgcolor="#99CCFF">
<tr>
<td width="100%" class="style2">
<p align="center" class="style1">
<img alt="" src="images/pglbanner.jpg" width="955" height="167">&nbsp;</p>
<form method="POST" action="index.php" >
<div align="center">
<center>
<table border="0" width="30%">
<tr>
<td width="22%" class="style3">Username:</td>
<td width="78%" class="style2"><input type="text" name="username" size="20"></td>
</tr>
<tr>
<td width="22%" class="style3">Password:</td>
<td width="78%" class="style2"><input type="password" name="password" size="20"></td>
</tr>
<tr>
<td width="22%" class="style2"></td>

<td width="78%">
<table border="0" width="75%">
<tr>
<td width="75%" class="style2">
<p align="right"><input type="submit" value="Login" name="login"></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<center>
<p align="center">&nbsp;</p>
</form>
<p align="center">&nbsp;</td>
</tr>
</table>
</center>
</div>

</body>

</html>

Thanks
Sherwin
shiraoka
 
Posts: 2
Joined: 02. June 2008 09:03

Postby Wiedmann » 02. June 2008 11:21

Your file is stored with utf-8 encoding (incl. a BOM).
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Header

Postby shiraoka » 03. June 2008 07:13

What do you mean "Your file is stored with utf-8 encoding (incl. a BOM)"?

What do i have to do to get my program to work?

Thanks in advance
shiraoka
 
Posts: 2
Joined: 02. June 2008 09:03

Postby sari42 » 03. June 2008 09:28

you have to use a plain text editor (not "word" or some such) and remove everything infront of <?php in the first line of your scripts (even any whitespace).
sari42
 
Posts: 800
Joined: 27. November 2005 18:28


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 152 guests