How to check variable posted in the same page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maxjackie
    New Member
    • Apr 2007
    • 3

    How to check variable posted in the same page

    i have code below i want use $user and $password which LoginId and password in the html code please hel me
    <?php
    session_start() ;
    require_once('D B.php');
    function validate() {
    $user = $_POST['LoginID'];
    echo "$user <br>";
    $password = $_POST['Password'];
    echo "$password <br>";
    $dbcon = new DB();
    $result = $dbcon -> Check($user,$pa ssword);
    if($relult){
    $_SESSION['error'] = 0;
    return "AddProduct.php ";
    }
    else{
    $_SESSION['error'] = 1;
    return "LoginPage.php" ;
    }
    }

    ?>

    <html>
    <head>
    <title>Login Page</title>
    </head>
    <body>
    <?php
    if(!empty($_SES SION)){
    if($_SESSION['error'] == 1){
    echo "please enter correct Login ID and Password";
    }
    }
    ?>
    <table border ="1">
    <form action="<?php $string = validate(); print $string ;?>" method="post">
    <tr>
    <td>Login ID </td>
    <td><input type="text" name="LoginID" size="30"/></td>
    </tr>
    <tr>
    <td>Password </td>
    <td><input type="password" name="Password" size="30"/></td>
    </tr>
    <tr colspan="2">
    <td><input type="submit" value="Login"/></td>
    </tr>
    </form>
    </table>

    </body>
    </html>
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    Please Read the Posting Guidelines and include the error messages you receive.
    The LEAST you could do IF YOU WANT OUR HELP is to tell us WHAT IS GOING WRONG.

    Comment

    • maxjackie
      New Member
      • Apr 2007
      • 3

      #3
      Originally posted by Motoma
      Please Read the Posting Guidelines and include the error messages you receive.
      The LEAST you could do IF YOU WANT OUR HELP is to tell us WHAT IS GOING WRONG.
      sorry for that
      in above code when i try access the variables posted i.e. LOGINID AND PASSWORD i can't access them
      what i am thinking they are not getting posted

      Comment

      • code green
        Recognized Expert Top Contributor
        • Mar 2007
        • 1726

        #4
        Code:
        i can't access them
        What do you mean you can't access them? Read Motoma's post again

        Comment

        Working...