Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Form submission

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Form submission

Postby Xerpher » Sun Sep 01, 2002 7:48 am

Lets say I have a form like this:

<form method="post" action="http://www.terradesign.ws/index.php">
<input type="text" name="username" size="9" value="">
<input type="password" name="password" size="9" value="">
<input type="submit" value="Log In">
</form>

How would I get the username and pasword thats submitted?
Xerpher
New php-forum User
New php-forum User
 
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada

Postby DoppyNL » Sun Sep 01, 2002 8:53 am

there is a manual: http://www.php.net/manual in wich you can search.

in this case, use the variables $_POST['username'] and $_POST['password']

Greetz Daan
DoppyNL
 

Postby Kenneth » Sun Sep 01, 2002 6:19 pm

ya, you can also just do something like:

<?php

echo $username;

echo $password;

?>

Hope this helps.
Kenneth
New php-forum User
New php-forum User
 
Posts: 40
Joined: Fri Aug 09, 2002 11:53 am
Location: Rochester, NY

Postby DoppyNL » Mon Sep 02, 2002 12:36 am

Kenneth wrote:ya, you can also just do something like:

<?php

echo $username;

echo $password;

?>

Hope this helps.

yes, but only when "register_globals" is "on" in you're php.ini

Greetz Daan
DoppyNL
 

Postby cho@ » Mon Sep 02, 2002 2:07 am

$_GET and $_POST (depend on the method in your form)...are only available in version sup at 4.1.x

if u have an older version you will have to use $HTTP_GET_VARS or $HTTP_POST_VARS......



bye
Cho@
cho@
New php-forum User
New php-forum User
 
Posts: 39
Joined: Tue Aug 06, 2002 8:58 am
Location: UK

Postby Xerpher » Mon Sep 02, 2002 3:21 am

Well both what dvdbinternet and Kenneth told me to do worked.

I have 2 more questions...
1) I know this isn't so much a php question, but how do I make my submit button into a normal a href link (if possible)?
2) When a user clicks on a link, how could I pass vertain variables to the next page?
Xerpher
New php-forum User
New php-forum User
 
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada

Postby DoppyNL » Mon Sep 02, 2002 3:41 am

Xerpher wrote: 2) When a user clicks on a link, how could I pass vertain variables to the next page?

I find that the best way to do that is using sessions.

start a session on each page with
Code: Select all
session_start();

and the you can "store" variables you want with
Code: Select all
session_register($variable);

you can then acces them (after starting the session) on each following page with
Code: Select all
$_SESSION['variable']
$variable

the latter only when "register_globals" is on in you're php.ini (in you're case it is as seen in previous posts)

Greetz Daan
DoppyNL
 

Postby Jay » Mon Sep 02, 2002 10:38 am

Xerpher wrote:how do I make my submit button into a normal a href link (if possible)?

Try this:
<a href=# onClick="document.form.submit()">The link</a>
Jay
 


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.