Hey I have some script that is supposed to change the url of the page if it meets certain criteria, or somewhere else if it doesn't.
I'm getting this error:
Warning: Cannot modify header information - headers already sent by (output started at /hermes/bosweb25c/b1401/ipg.website/process.php:7) in /hermes/bosweb25c/b1401/ipg.website/process.php on line 53
Here's my PHP. I'm pretty sure it has to do with the if statement, but it was working fine on my WAMP Server before I uploaded to my web host.
<?php
session_start();
$con = mysql_connect('website', 'members_db_admin', 'password');
if (!$con) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully<br />';
// make members the current db
$db_selected = mysql_select_db('members_db', $con);
if (!$db_selected) {
die ('Can\'t use members database : ' . mysql_error());
}
$hash_password = md5($_POST['password']);
$email = $_POST['email'];
$result = mysql_query("SELECT email,password FROM `members` WHERE email = '$email'");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
}
$row = mysql_fetch_row($result);
if ($row[0] != $email && $hash_password != $row[1])
{
$query = "INSERT INTO members (email, password)
VALUES('".$_POST['email']."','".$hash_password."')";
// Perform Query
$result2 = mysql_query($query);
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result2) {
$message = 'Invalid query: ' . mysql_error() . "\n";
//$message .= 'Whole query: ' . $query;
die($message);
}
$_SESSION['email']=$_POST['email'];
$_SESSION['password']=$hash_password;
$_SESSION['loggedin']="YES";
$url = "Location: /welcome.php";
header($url);
}
$_SESSION['email']=$_POST['email'];
$_SESSION['password']=$hash_password;
$url = "Location: /checklogin.php";
header($url);
?>