So I am new to all this coding and I am making a small website, which has to have a login and something is not working properly. My login user/pass processing code looks like this
<?php
$host = 'xxxx'; // Host name Normally 'LocalHost'
$user = 'xxxx'; // MySQL login username
$pass = 'xxxx'; // MySQL login password
$database = 'members'; // Database name
$table = 'members'; // Members name
$username = $_POST["username"];
$password = $_POST["password"];
$connection = mysql_connect("xxxx", "$user", "$pass");
if (!$connection) {
die("Database connection failed: " . mysql_error());
}
else {
echo "Everything is fine!<br />";
}
mysql_select_db("xxxx",$connection) or die(mysql_error());
$result = mysql_query("SELECT * FROM members WHERE usr='$username' and pass='$password'",$connection) or die(mysql_error());
$count=mysql_num_rows($result);
if($count==1){
session_start();
session_register("myusername");
session_register("mypassword");
header("location:Login_Success.php");
}
else {
echo "Wrong Username or Password";
}
?>
So it all continues well and transfers me to Login_Success.php, where the code looks like this
<?
if(!session_is_registered(myusername)){
header("location:MainPage.htm");
}
?>
<html>
-----my html code here, which makes no difference----
The problem is that it sends me to MainPage.htm and I can't really figure out why. As ive said im new to all of this. I figured that the session did not stay logged in, when it changed pages for some odd reason?
THANK YOU!