Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2012
    Posts
    19

    Thumbs down Unanswered: 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 08:12.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    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 on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jan 2012
    Posts
    19
    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

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    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 on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •