I can still login, however the user will not be automatically redirected to the next page.Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/J/a/p/JapII/html/reftek/site/support.php:1) in /home/content/J/a/p/JapII/html/reftek/site/support.php on line 2
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/J/a/p/JapII/html/reftek/site/support.php:1) in /home/content/J/a/p/JapII/html/reftek/site/support.php on line 2
Here is the php I'm using:
Code: Select all
<?php
session_start();
$query = mysql_connect("*******", "******", "******") or die(mysql_error());
mysql_select_db('*******', $query) or die(mysql_error());
if(isset($_GET['try'])) {
If(empty($_POST['company']) OR empty($_POST['password'])) {
echo 'Please fill in all required fields.';
}
else {
$company = addslashes($_POST['company']);
$password = md5($_POST['password']);
$query = mysql_query("SELECT usergroup FROM users WHERE company = '" . $company . "' AND password = '" . $password . "'") or die(mysql_error());
list($usergroup) = mysql_fetch_row($query);
if(empty($usergroup)) {
echo 'No combination of username and password found.';
}
else{
session_start();
$_SESSION['company'] = ($_POST['company']);
header('Location: account.php'); die ("<a href='account.php'> Next>> </a>\n");
}
}
}
if (isset($_POST['guest'])){
session_start();
$_SESSION['company'] = ($_POST['guest']);
header('Location: account.php'); die ("<a href='account.php'> Next>> </a>\n");
}
?>Code: Select all
<form action="support.php?try=true" method="post" class="user_login">
Username: <br/>
<input type="text" name="company"><br/>
Password:<br/>
<input type="password" name="password"><br>
<br>
<input type="submit" value="Login">
</form>
<form action="support.php" method="post" class="guest_login" >
Login as a guest:
<div style="display:none;"><input type="text" name="guest" value="guest"></div>
<input type="submit" value="guest">
</form>