If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Want to print data

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-04-12, 13:15
altafhpatel altafhpatel is offline
Registered User
 
Join Date: Jan 2012
Posts: 2
Thumbs down Want to print data

I am using this login and registration form see

this checks user name and password and show form

Code:
<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

Code:
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 passwords1

Code:
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 also like
it grab user city and user cell
but i don't know what to do kindly help me

Last edited by altafhpatel; 01-05-12 at 07:12.
Reply With Quote
  #2 (permalink)  
Old 01-05-12, 07:28
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
so where do you expect to 'print' the other data
what are those columns called
what is the function print_secure_content();

'all' you need to do is add the columns to your exsiting output
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 01-05-12, 10:53
altafhpatel altafhpatel is offline
Registered User
 
Join Date: Jan 2012
Posts: 2
Quote:
Originally Posted by healdem View Post
so where do you expect to 'print' the other data
what are those columns called
what is the function print_secure_content();

'all' you need to do is add the columns to your exsiting output
Code:
$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);
this checks the result of username and passwords
but i want to print data agianst that user name suppose i choose
google as username
so it outputs the data of google like google username city and cell number so tell me what i try

$return=mysql_num_rows($result);
echo $return[city];
but nothing output
Reply With Quote
  #4 (permalink)  
Old 01-06-12, 04:44
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
so youneeed to retrieve the data returned form the query result

PHP: mysql_query - Manual
PHP Code:
while ($row mysql_fetch_assoc($result)) 
{  echo 
$row['acolumn'];
    echo 
$row['anothercolumn'];
    echo 
$row['somedata'];
    echo 
$row['lastcolumn'];

__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On