473,387 Members | 1,942 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,387 software developers and data experts.

Storing input values as variables?

Hello,

I wondered if anyone could advise? I am trying to write a basic
script, which allows user's to enter there username, password in text
fields. Then we take these values and pass them to the method
login_user($userid, $password);

I was unsure how to take the text fields values, and store them in
variables, when the submit button is clicked?

Is this code correct?

Thank you

<?php

function login_form(){
global $PHP_SELF, $userid, $password;
?>
<html>
<head>
<title></title>
</head>

<body>

<div align="center">
<form method="post" enctype="multipart/form-data" action="<?php
echo $PHP_SELF ?>">
<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="submit" value="Login">
</td>
</tr>
</table>
</form>
<div>
</body>
</html>
<?php
}

login_form();
$user_info = login_user($userid, $password);

?>
Jul 17 '05 #1
3 1780
On Thu, 12 Aug 2004 02:51:32 -0700, Antoni wrote:
You posted this exact same post yesterday.. why the repeat post? Hounding
users for an answer is _not_ the best practice...

Hello,

I wondered if anyone could advise? I am trying to write a basic
script, which allows user's to enter there username, password in text
fields. Then we take these values and pass them to the method
login_user($userid, $password);

I was unsure how to take the text fields values, and store them in
variables, when the submit button is clicked?

Is this code correct?

No.
Thank you

<?php

function login_form(){
global $PHP_SELF, $userid, $password; ^^^^^^^^^ ^^^^^^^ ^^^^^^^^^
Assumes register_globals is enabled. See php.net as to why this doesn't
work anymore.
[ snip ]

login_form();
$user_info = login_user($userid, $password);

Search php.net for 'register_globals' and all your prayers will be
answered.

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #2
You're told your form to submit with the "post" method (<FORM method="post">)
All form values will be avail in the $_POST array.
ie $_POST['userid'] and $_POST['password']

An***********@aol.com (Antoni) wrote in message news:<93**************************@posting.google. com>...
Hello,

I wondered if anyone could advise? I am trying to write a basic
script, which allows user's to enter there username, password in text
fields. Then we take these values and pass them to the method
login_user($userid, $password);

I was unsure how to take the text fields values, and store them in
variables, when the submit button is clicked?

Is this code correct?

Thank you

<?php

function login_form(){
global $PHP_SELF, $userid, $password;
?>
<html>
<head>
<title></title>
</head>

<body>

<div align="center">
<form method="post" enctype="multipart/form-data" action="<?php
echo $PHP_SELF ?>">
<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="submit" value="Login">
</td>
</tr>
</table>
</form>
<div>
</body>
</html>
<?php
}

login_form();
$user_info = login_user($userid, $password);

?>

Jul 17 '05 #3
Thank you.

I wondered if this changed code seemed correct?

And if I could also ask, do you know of any approach once the user
clicks the submit button to test the userid and password have been
entered, and the text field is not empty.

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="submit" value="Login">
</td>
</tr>
</table>
</form>
<div>
</body>
</html>
<?php
}

login_form();
$user_info = login_user($_POST['userid'], $_POST['password'];
?>
Jul 17 '05 #4

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

Similar topics

5
by: Paul C-T | last post by:
Hi, Am I trying to be too clever here? I am trying to write a PHP page to enable me to enter values into a form then write those values to a text file. I want to use the form & table that...
2
by: Mark Hannon | last post by:
I am trying to wrap my brain around storing form elements inside variables & arrays before I move on to a more complicated project. I created this simple example to experiment and as far as I can...
1
by: bloy.d | last post by:
Hi, I'll be honest I'm a newbie at all this and I'm need to get a small JS working as soon as possible - please can anybody help? I have a small insentive if needed ;) What i need is a spot...
2
by: Jax | last post by:
Say for example a user of my website makes a selection on the site and I want to store that value for use on a later page what is the best way to do that? My only method at the moment that I know...
2
by: UJ | last post by:
I have an aspx page that does some database look ups on the initial load. I then need to do stuff later after an autopostback based on some of the values. So I put some variables in input variables...
22
by: guitarromantic | last post by:
Hey everyone, I run a site with staff-submitted reviews, and most of them are written by one author. However, we also do "multiple" reviews. Up until now I just had a userid for a 'Multiple'...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
4
by: =?Utf-8?B?YmFzdWxhc3o=?= | last post by:
Hi; I want to store a datatable (or an arraylist) as a session variable but when I try; Session = al_RecNo; I get an error that; "Cannot implicitly convert type...
10
by: drago | last post by:
Hello guys again! Back with invoice problems. Just want to know how to store data in the main database in different tables and fields using a form. I have a datasheet view of a form where i have to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.