variable value is not passed

Discussion in 'PHP' started by kharearch, Jan 11, 2008.

  1. #1
    I am executing following program but value of 'pass' is not being received.
    Please help me. my code is following.


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <?php
    $con = mysql_connect("localhost","sanganak_manish","manish");
    //$con = mysql_connect("localhost","root","");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }mysql_select_db("sanganak_mydata",$con);
    $result = mysql_query("SELECT name,password from login where name='".$_POST[name]."' and password ='".$_POST[pass]."'");
    //$num = mysql_numrows($result)
    if(mysql_numrows($result))
    {
    echo "valid user";
    }
    else
    {
    echo "not a valid user";
    }
    //echo $row['name'];
    //echo $row['date_diff'];
    //echo $row['e_mail'];
    //$to = $row['e_mail'];
    //echo $to;
    mysql_close($con);
    ?>
    </body>
    </html>
     
    kharearch, Jan 11, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Can you post the code of the HTML form?
     
    nico_swd, Jan 11, 2008 IP
  3. kharearch

    kharearch Member

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    my form code is following -

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <div align="center">
    <p>Index.php
    </p>
    <table width="100%" height="87" border="0">
    <tr>
    <td width="71%" valign="top">LOGO</td>
    <td width="29%" valign="top">ADMINISRATOR PANEL </td>
    </tr>
    </table>
    <p>&nbsp;</p>
    <p>ADMINISTRATOR LOGIN </p>
    <table width="45%" border="0">
    <tr>
    <td width="33%" valign="top"><p>USER NAME</p>
    <p>PASSWORD</p> </td>
    <td width="67%"><form name="form1" method="post" action="pass_check.php">
    <p>
    <input type="text" name="name">
    </p>
    <p>
    <input type="text" name="pass">
    </p>
    <p>
    <input type="submit" name="Submit" value="Submit">
    </p>
    </form></td>
    </tr>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp; </p>
    </div>
    </body>
    </html>
     
    kharearch, Jan 11, 2008 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    nico_swd, Jan 11, 2008 IP
  5. kharearch

    kharearch Member

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    I have used 'echo $_post[pass]' but it did not print anything. It is just returning not a valid user.
     
    kharearch, Jan 11, 2008 IP
  6. Brewster

    Brewster Active Member

    Messages:
    489
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    60
    #6
    Try using quotes in your post values like this:

    $_POST['pass']
    PHP:
    Do the other posted values show when you do print_r( $_POST ) ?

    Brew
     
    Brewster, Jan 11, 2008 IP
  7. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #7
    Did you echo $_post[pass] or $_POST[pass]? (Note that POST should be all uppercase.)

    Your HTML form is correct, so the error must be in your PHP script. Would you mind giving me the output of this though?
    
    print_r($_POST);
    
    PHP:
    Just to see what you receive at all.
     
    nico_swd, Jan 11, 2008 IP
  8. kharearch

    kharearch Member

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #8
    when I use 'echo $_POST[name]' it prints it value.
     
    kharearch, Jan 11, 2008 IP
  9. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #9
    Please answer our questions.
     
    nico_swd, Jan 11, 2008 IP