1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Undefined index in php.

Discussion in 'PHP' started by Roshaan.N, Apr 26, 2012.

  1. #1
    whenever i run this code i got error "undefined index" give me a solution or tell me what i have to do.

    code:

    <?php
    $a=$_POST['name'];
    $b=$_POST['password'];
    $con=mysql_connect("localhost","root","root");

    mysql_select_db("login",$con);

    $res= mysql_query("select * from login where ID ='$a' AND PASS ='$b' ");

    if(mysql_num_rows($res)=='1')

    echo "YOU ARE A MEMBER";
    else "incorrect id or password";

    ?>
     
    Roshaan.N, Apr 26, 2012 IP
  2. Roshaan.N

    Roshaan.N Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    *
    if(mysql_num_rows($res)=='1'){
    echo "YOU ARE A MEMBER";}
    else {echo "incorrect email id or password";}
     
    Roshaan.N, Apr 26, 2012 IP
  3. Rainulf

    Rainulf Active Member

    Messages:
    373
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #3
    Which line exactly does it give the error? Can you paste here the exact error? I don't see any problem as far as I can see.
     
    Rainulf, Apr 26, 2012 IP
  4. webshore88

    webshore88 Well-Known Member

    Messages:
    130
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    123
    #4
    Roshaan.N is right, but I guess your problem is somewhere at this line
    $res= mysql_query("select * from login where ID ='$a' AND PASS ='$b' ");
    check your DB field is same as you are mentioning in your query.
     
    webshore88, Apr 27, 2012 IP
  5. infotripro

    infotripro Member

    Messages:
    26
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    43
    #5
    check your table for an index
     
    infotripro, May 2, 2012 IP