After fixing my login issue where the query didnt find the username and password for the user. It now logs in but it logs into a blank page, its supposed to show a control panel with options to add,remove or edit contacts.
Here is the login.php
<?php
session_start();
<html>
<link rel="stylesheet" href="my_layout.css" type="text/css" />
<title>Alpine VW Extension List</title>
<body class="my_body">
<div id="my_divition">
<?php
$connect=mysql_connect ("localhost", "root", "^h1dDeN!");
mysql_select_db ("phonebook");
$username=$_POST['username'];
$password=$_POST['password'];
$sqlQuery="select * from members where username='$username' AND
password='$password'" ;
$result=mysql_query($sqlQuery);
$number=mysql_num_rows($result);
if($number>0)
{
$id=mysql_result($result,0,"id");
$_SESSION['id']=$id;
session_register('id');
include('Control.php');
}
else
echo"<h1> <br /><br />Sorry : invalid entery <br /><br /> </h1><a href=index.php >
go back </a>";
?>
</div>
</body>
</html>
control.php:
<?php
if(session_is_registered('id'))
{
echo "<br> <h2> Control panel :</h2>";
echo "<table border=1>
<form action=Add_contact.php method=post>
<input type=submit value='Add contact' />
</form>
<form action=Show_Contact.php method=post>
<input type=submit value='Show contacts' />
</form>
<form action=Search_for_contact.php method=post>
<input type=submit value='Search contacts' />
</form>
<form action=Remove_contact.php method=post>
<input type=submit value='Remove contact' />
</form>
<form action=logout.php method=post>
<input type=submit value='logout' />
</form> </table>";
}
?>
I also think my table is created wrong. Heres the show contacts.php code:
<? session_start();?>
<html>
<link rel="stylesheet" href="my_layout.css" type="text/css" />
<title>Alpine Motors VW</title>
<body class="my_body">
<div id="my_divition">
<?php
include('Control.php');
echo "<br> <b><u> Your contacts are :</u> </b><br><br>";
$connect=mysql_connect ("localhost", "root", "^h1dDeN!");
mysql_select_db ("phonebook");
$id=$_SESSION['id'];
$sqlQuery="Select * from contact where M_id='$id'";
$result=mysql_query($sqlQuery);
$number=mysql_num_rows($result);
echo "<table border=1> ";
echo "<tr><th>First name</th><th>Last name</th>
<? session_start();?>
<th>Phone number</th></tr>";
if($number>1)
while($number>0)
{
$fname=mysql_result($result,$number-1,"f_name");
$lname=mysql_result($result,$number-1,"l_name");
$phone=mysql_result($result,$number- 1,"phone_number");
echo "<tr><th>$fname</th><th>$lname</th>
<th>$phone</th></tr>";
$number--;
}
else
{
echo "<table>";
echo " <br/> The contacts list is empty ! ";
}
?>
</div>
</body>
</html>
If anyone can tell me why its showing blank i would really appreciate it ^^ By the way im still learning php and html so go easy on me :D