Using $_POST with Submit button

From: Antoni (AntoniRyszard_at_aol.com)
Date: 08/15/04


Date: 14 Aug 2004 15:54:49 -0700

Hello,

I wondered if anyone could further advice? 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 page. I would appreicate
some advice if my scrips looks corrects? 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">Password</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($userid, $password);
   displayRecord($userRecord);

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

</body>
</html>


Quantcast