SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 49 of 49
  1. #26
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    if i remove echo $message every time it is re directing to header("Location:login3.php");
    why it is used for
    Because that's what your code is set up to do when $rows is 0

    Code php:
    if ($rows > 0) { 
        ...
    } else { 
        //unsuccessful login 
        header("Location:login3.php");
        exit; 
    }
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  2. #27
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but i have 2 rows in my login table with 4 fields......

  3. #28
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,813
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    Thank you, Paul_w. That's what I mean by checking your logic. Your PHP is working, but the way you are setting up your if/then statements may not function the way you think. I recommend you make a flowchart ( on paper) and follow though, pretending you were the computer, and see where each possible input leads you.

    it also possible you may not be getting the input from your DB that you think you are.

  4. #29
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    but i have 2 rows in my login table with 4 fields......
    So, you need to test now if the database is returning what you expect to receive.
    It can be easier to test if you separate the query in to $sql and $result, so that you can var_dump $sql to check that things are as you expect them to be.

    Code php:
    $sql = "SELECT * from ...";
    var_dump($sql);
    $result = mysql_query($sql);
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #30
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    first when the session has started he need to go to the "products.php" page
    using the session name(here using time()).here username is the output of time()
    that should be stored in the database.
    tell me how to do this one....

  6. #31
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    So, you need to test now if the database is returning what you expect to receive.
    It can be easier to test if you separate the query in to $sql and $result, so that you can var_dump $sql to check that things are as you expect them to be.

    Code php:
    $sql = "SELECT * from ...";
    var_dump($sql);
    $result = mysql_query($sql);
    instead of if ($rows > 0) is it possible to check whether the user is already present or not

  7. #32
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    instead of if ($rows > 0) is it possible to check whether the user is already present or not
    Yes it is possible, just by adjusting your request to the database.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  8. #33
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not by using time() right.....

  9. #34
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    not by using time() right.....
    Which presence are you wishing to check? Presence within the database or presence as a sessioned user?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  10. #35
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    as a sessioned user

  11. #36
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    as a sessioned user
    Then you would check if $_SESSION['username'] is equal to the supplied username.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  12. #37
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that i have done alreagy in my below if statement right
    if ($rows > 0)
    {
    }

  13. #38
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    whether the below code is correct
    PHP Code:
    <?php 
    session_start
    ();
    mysql_connect("localhost","root","") or die("mysql_error()");
    mysql_select_db("shopping") or die("mysql_error()");
    $result mysql_query("SELECT * from login where username='" $_POST['username'] . "' AND password='" $_POST['password'] . "'"); 
    $rows=mysql_num_rows($result);
    if(!isset(
    $_SESSION['username']))
    {
     
    $_SESSION['username'] = $_POST['username'];

    else 
    {
      
    $_SESSION['username'] = time();
    }
    now tell me if the username is matching with the username in database
    then how to redirect to "products.php"

  14. #39
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    now tell me if the username is matching with the username in database
    That's where you want to learn about performing SQL queries.
    It should only take a modification to your already existing SQL query to achieve that.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  15. #40
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    reply

    k below i sthe way the code has to flow
    PHP Code:
    <?php 
    session_start
    ();
    mysql_connect("localhost","root","") or die("mysql_error()");
    mysql_select_db("shopping") or die("mysql_error()");
    $result mysql_query("SELECT * from login where username='" $_POST['username'] . "' AND password='" $_POST['password'] . "'"); 
    $rows=mysql_num_rows($result);
    if(isset(
    $_SESSION['username']))
    {
    //if the username is matching in the database go to page "products.php" 


    else 
    {
    //also go to page "products.php" by creating new user in the database
     
    }
    for this how the above code should be modified....

  16. #41
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    for this how the above code should be modified....
    Typically if the user doesn't exist, you would go instead to a new user page which confirms that the details are correct, typically through an email response loop, and then once successful redirects to the products page.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  17. #42
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes first part is correct.not understood the second part of ur question

  18. #43
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,506
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    not understood the second part of ur question
    It's not a question. You asked a question, Paul gave an answer.

  19. #44
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    below is the modified code
    PHP Code:
    <?php 
    session_start
    ();
    mysql_connect("localhost","root","") or die("mysql_error()");
    mysql_select_db("shopping") or die("mysql_error()"); 
    $result mysql_query("SELECT username FROM login WHERE username='" $_POST['username'] . "' AND password='" $_POST['password'] . "'"); 
    $rows=mysql_num_rows($result);
    if(!isset(
    $_SESSION['unique_id']))
    {
    $n time();
    $_SESSION['username'] = $_POST['username'];
    header("Location:products.php");

    else 
    {
    header("Location:products.php");
    }
    ?>
    it is redirecting to the "products.php" page.......
    how to check that for not registered user

  20. #45
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    it is redirecting to the "products.php" page.......
    how to check fo rthat not registered user
    If you want someone here to write the code for you, that can be done, but it will most likely not be up to the standards that you require.

    If you would like to learn how to write what you need though, then we can happily help you to learn about what you need to know.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  21. #46
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in my above code tell me how to register the username in the database

  22. #47
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ravi951 View Post
    in my above code tell me how to register the username in the database
    Well first of all, what is it that you require for someone to be considered to have appropriately registered?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  23. #48
    SitePoint Addict
    Join Date
    Jul 2011
    Location
    Hyderabad,India.
    Posts
    327
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i am not getting u

  24. #49
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,343
    Mentioned
    192 Post(s)
    Tagged
    4 Thread(s)

    You need a new approach - listen carefully

    @ravi951:There may be an issue with your command of English.
    But the 'tone' of your posts is not very polite. You are asking for advice in the form of "TELL ME HOW TO DO IT".
    Although we all are willing and anxious to help anyone learn and succeed when they encounter difficulty, your posts evoke an attitude that contains;
    • no willingness to learn
    • an insistence that someone provide the answer
    • lack of attention or attempt to honestly understand what is being [carefully and delicately] explained to you


    If I have misunderstood your intentions, correct me and accept my apologies. This message is NOT intended to demean or insult you. I wanted to provide you an objective perspective on the way you are presenting yourself.

    Please, please carefully re-read this entire thread; take notes if you must in order to collect the valuable information that has been presented here.
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains


Bookmarks

Posting Permissions

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