hello, all my normal forums cannot help me and i saw this forum so i am going to see if you guys can. I am trying to make a home server so my family can access it over the internet and view my files/pictures. before i used Windoes Home Server and it works great for what i need but is not worth the $100 and not as much customizability as making my own, i am usung ubuntu/apache/php/sql and so far can get on and log on, before i figure out anything else i figured i need to get the user login/permissions down. Its been a long time and i am stuck at passing information between sites, so far here is where i am at.
Index.html has
Code:
<html >
<body>
<h2><span>User Login</span></h2>
<form name="login" action="checklogin.php" method="post">
<div id="field_username">
<strong><span>Log in:</span></strong>
<input type="text" name="myusername" />
</div>
<div id="field_password">
<strong><span>Password:</span></strong>
<input type="password" name="mypassword"/>
</div>
<div id="button_enter">
<input value="login" type="submit" />
</div>
</form>
</body>
</html>
this so far correctly displays a form and will send the user to checklogin.php which has
Code:
<?php ob_start();
$host="localhost"; //Host Name
$username="XXXXXX"; // Mysql username
$password="XXXXXXx"; // Mysql password
$db_name="XXXXXXX"; // Database name
$tbl_name="XXXXXX"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
session_start();
$_SESSION["NAME"]=myusername;
echo("Login successful, <a href=\"site.php\">Please click here</a>");
}
else
{
echo "Wrong Username or Password";
}
ob_flush(); ?>
so far from what i can tell, this will correctly tell the difference between users/passes, but i cannot get the user (or any other information) sent to the next page. here is site.php
Code:
<?php
session_start();
?>
<html>
<body>
<h1>Welcome
<?php
if(!empty($_SESSION["NAME"]))
{
echo $_SESSION["NAME"];
}
else
{
echo "nobody";
} ?></h1>
</body>
</html>
which if i remember correctly (its been a while since i had to html/php program) this should display a user if the $_SESSION["NAME"] has one in there, but i tryied with the if statement both was and it either displayed "Welcome NOBODY" or "Welcome ", what am i doing wrong?
Also does anyone have a tutorial or template dealing with something like this? i have tried looking up tutorials to make forums to keep the user logged in each page and to keep different permission levels (users, premium users, admin) but none of them work for me.
Also i found this : Single File PHP Gallery 4.0.0 (cannot display urls

)
since you guys are experts, do you have any recomendations on this or others? so far i like the layout of this page but it displays red X's for all my pictures until i click on them to enlarge them.
Thanks for any help in advance.