Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Using $_POST with Submit button

 
   Database Forums (Home) -> PHP RSS
Next:  When a field value is empty how do you not show i..  
Author Message
Antoni2

External


Since: May 15, 2004
Posts: 2



(Msg. 1) Posted: Sat Aug 14, 2004 4:54 pm
Post subject: Using $_POST with Submit button
Archived from groups: comp>lang>php (more info?)

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>

 >> Stay informed about: Using $_POST with Submit button 
Back to top
Login to vote
steve




Joined: Jan 06, 2004
Posts: 660



(Msg. 2) Posted: Sat Aug 14, 2004 8:13 pm
Post subject: Re: Using $_POST with Submit button [Login to view extended thread Info.]

Antoni wrote:
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>


I did not go thru the code fully, so I leave that to others to comment on.

(isset($_POST['login']))... refers to detecting that the form has been submitted. The value of $_POST['login'] would be set when the submit button has been pressed. As your form and your form-processing logic are both on the same script, this is the way of detecting when $_POST values are present for processing

 >> Stay informed about: Using $_POST with Submit button 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Submit Button - How can I use a graphic button instead of the usual grey SUBMIT button?

passing radio button values to a submit button (gif) - Hello, How do i pass the value of the radio button to be put of the action that includes the value as part of the URL being submitted - "/ picked.php?pick_num=". Any help with be appreciated. Thanks <form method="post"..

$_POST - Can i put a variable inside $_POST. like this: $_POST['$var_name']; It doesnt work, neither does: $_POST[var_name]; thanks Wes

When is $_POST set and unset? - I have a script that submits form data via a "post" method to another script. I have an href link in the destination script that links back to itself for processing form data on that page with some "get" data appended to the URL. I ...

Foreach element in $_POST? - Hey Is there a way to go through each element in the $_POST supervariable? I'm making a page with dynamic forms, so I don't know for sure how many $_POST variables there will be (the number of textboxes, radio buttons, etc changes). How can I either..
   Database Forums (Home) -> PHP All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]