473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Using $_POST with Submit button

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>
Jul 17 '05 #1
1 12288
"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

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-_POST-Su...ict139727.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=467354
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Matt | last post by:
In the following code, I have 2 questions regarding submit button with image. 1) Does this code <input type="image" name="populate" src="populate.gif"> behave the same as an HTML submit button...
6
by: JSjones | last post by:
Hi all, I'm new to these boards and my javascript experience is fairly limited and basic so please bear with me. Anyway, on to the question and some background. I'm developing using ColdFusion...
1
by: reneecccwest | last post by:
Hello, I'd like to pass the "levelbtn" value when I click the filter button, but there are also other submit form buttons. I defined as "document.testform.submit();" in the javascript, but I...
2
by: Ghafran Abbas | last post by:
Call this function from the Page_OnLoad event of your asp.net page. This will prevent the user from doing multiple post backs or button clicks. This was designed to not disable the button, because...
1
by: derek | last post by:
Hello, I have been trying for a while but have been unable to do this: I have two drop down lists and a submit button. After choosing appropriate values in the dropdowwnlists, I hit the submit...
7
by: David T. Ashley | last post by:
Hi, For a web page, I want a SUBMIT button that commits the form data and a CANCEL button that goes to a different target (i.e. a different script). I haven't figured out how to do this,...
23
by: Bjorn | last post by:
Hi. Every time i post data in a form the contents are being checked for validity. When i click the back-button, all data is gone and i have to retype it. It's obvious that only a few or none of...
3
by: JimO | last post by:
Is there a way to force a post without using submit button? Thanks, Jim
3
by: Daniel | last post by:
Hi all, I am using .NET 1.1. I have a form with a cancel button, something like this: <form method="post"....> <input type="submit" value="Submit"> <input type="submit" value="Cancel"...
1
by: abcdriver | last post by:
Later edit: Too complex: The only thing I should know is: The submit button's NAME (and value) will only be sent if that particular button was used to submit the form, so you should be able to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.