need php help - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > PHP Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-01-2010, 10:05 PM   #1 (permalink)
Junior Member
 
Join Date: Jun 2010
Posts: 1
Default need php help

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.
htmlandphptrouble is offline   Reply With Quote
Sponsored Links
Old 06-14-2010, 09:21 AM   #2 (permalink)
Junior Member
 
Join Date: Jun 2010
Posts: 5
Default Re: need php help

Hi,

Please find all latest php interview questions here www-phpinterviewquestion-com
sana is offline   Reply With Quote
Old 10-25-2010, 02:00 PM   #3 (permalink)
Junior Member
 
Join Date: Sep 2010
Posts: 6
Default Re: need php help

Please check global_register setting please set to off
eziscript is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 07:50 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting