Using Submit buttons with $_POST

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Antoni

    Using Submit buttons with $_POST

    Hello,

    I wondered if anyone could advise further? In my script I was trying
    allow the user to enter a userid and password, and when the users
    clicks the login button. Pass these values passed to a method
    login_user, and finally display there record.

    I was hoping to display the record on this web page. I would appreicate
    some advice if my scrips looks correct? I unsure about the line
    if(isset($_POST['login'])){?

    Thank you

    <?php
    function login_form(){
    ?>
    <html>
    <head>
    <title></title>
    </head>

    <body>

    <div align="center">
    <form method="post">
    <table border="1">
    <tr>
    <th align="right">E-mail</th>
    <td nowrap>
    <input name="userid" size="25">
    </td>
    </tr>
    <tr>
    <th align="right">P assword</th>
    <td nowrap>
    <input name="password" size="25">
    </td>
    </tr>
    <tr>
    <td align="center">
    <input type="submit" name="login" value="Login">
    </td>
    </tr>
    </table>
    </form>
    <div>
    <?php
    }

    login_form();

    if(isset($_POST['login'])){
    $userid = $_POST["userid"];
    $password = $_POST["password"];
    $userRecord = login_user($use rid, $password);
    displayRecord($ userRecord);

    echo "</body>";
    echo "</html>";
    }
    ?>
Working...