PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Feb 24, 2020 10:32 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Jan 05, 2012 7:15 am 
Offline
Forum Newbie

Joined: Thu Jan 05, 2012 7:10 am
Posts: 1
I am using this login and registration form see
this checks user name and password and show form


Syntax: [ Download ] [ Hide ]
<head>
<title>login page</title>
</head>
<body bgcolor="black" style="color:gray">
<form action="index.php" method=get>
<h1 align="center" style="color:gray" >Welcome to this simple application</h1>
<?php
session_start();
if($_SESSION["logged"])
{
     print_secure_content();
}
else {
    if(!$_SESSION["logging"])
    {  
    $_SESSION["logging"]=true;
    loginform();
    }
     else if($_SESSION["logging"])
       {
         $number_of_rows=checkpass();
         if($number_of_rows==1)
            {    
             $_SESSION[user]=$_GET[userlogin];
             $_SESSION[logged]=true;
             print"<h1>you have loged in successfully</h1>";
             print_secure_content();
            }
            else{
                   print "wrong pawssword or username, please try again";    
                loginform();
            }
        }
     }


this is the functions

fucntion login form


Syntax: [ Download ] [ Hide ]
function loginform()
{
print "please enter your login information to proceed with our site";
print ("<table border='2'><tr><td>username</td><td><input type='text' name='userlogin' size'20'></td></tr><tr><td>password</td><td><input type='password' name='password' size'20'></td></tr></table>");
print "<input type='submit' >";    
print "<h3><a href='registerform.php'>register now!</a></h3>";    
}


it checks the passwords

Syntax: [ Download ] [ Hide ]
function checkpass()
{
$servername="localhost";
$username="root";
$conn=  mysql_connect($servername,$username)or die(mysql_error());
mysql_select_db("test",$conn);
$sql="select * from users where name='$_GET[userlogin]' and password='$_GET[password]'";
$result=mysql_query($sql,$conn) or die(mysql_error());
return  mysql_num_rows($result);
}


now it works fine but i want to show the other data from this table users
but i don't know how to get this
kindly help me


Top
 Profile  
 
PostPosted: Thu Jan 05, 2012 4:38 pm 
Offline
DevNet Master
User avatar

Joined: Sun Feb 15, 2009 12:08 pm
Posts: 2794
Location: .za
Syntax: [ Download ] [ Hide ]
<?php
$qry = "SELECT field FROM table";
$sql = mysql_query($qry);

while ($array = mysql_fetch_array($sql)) {
  echo $array['field'];
}
?>

This is the basic idea behind displaying data from the database. There is a query which selects which fields you want to display, the query is passed to the mysql_query() function. Then a function like mysql_fetch_array() is used to fetch data in the form of an array. Finally you access the data like you would in an array. You need to change 'field' to the fields you wish to display and change 'table' to the related database table.

_________________
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group