Hi all.
Firstly I apologize if I don't use the correct 'terms' I am still learning. 🙂
Thanks for the help I've received so far.
I've managed to build a php login with two seperate forms using a switch statement to GET form actions. (that statement alone would have had me reading books for hours, 1 week ago). With each form taking the user to different pages. i.e. Distributors and Admin areas.
But its the admin area that I am now struggling with.
I can use forms to input data into a database sufficiently.
I am hoping to create a page that can select data from the database and display the data in tables.
using the below script I am able to pull info from the database and echo the fields elsewhere on the page
<?php
session_start();
if (@$_SESSION['auth'] !="yes")
{
header("location:index.php");
exit();
}
include("db.inc");
$connection = mysql_connect($hostname,$username,$password)
or die ("Could not connect to server");
$db = mysql_select_db($database,$connection)
or die ("Could not connect to database");
$sql = "SELECT FirstName,LastName FROM Distributors
WHERE Username ='{$_SESSION['logname']}'";
$result = mysql_query($sql)
or die("Couldn't execute query for result");
if(mysql_num_rows($result)>0) //there are results returned
{
$row = mysql_fetch_array($result);
extract($row);
}
?>
The echo being
<?php echo " Welcome $FirstName $LastName "; ?>
This took me a while to fix as the script which took info from the form posting this session information was written wrong.
I had used
$POST
instead of
$_POST
Which meant my session stored no information at all. 🙂
Anyway
If anyone can help me, using the above script to 'pull' data from the database, is it possible to display that info in a table. Obviously the above info would only display FirstName and LastName. I would edit this to display the info that I need.
Arnora