Help - Search - Member List - Calendar
Full Version: Problems using <FORM> tag...
WorkTheWeb Forums > Webmaster Resources > PHP Help
Support our Sponsors!
Domestos
Hi all - please help...

using <FORM> HTML tag for user input and need to get get data from it and
store in php variable...

<input type="text" name="user_name" size="18" maxlength="16"
class="input_left" tabindex="11" />



using the following to try and get user_name, but $user_name comes back
blank in both cases...

$user_name=$HTTP_POST_VARS['user_name'];

$user_name=$_POST['user_name'];


TIA

Tony
Domestos wrote:
QUOTE
Hi all - please help...

using <FORM> HTML tag for user input and need to get get data from it
and store in php variable...

<input type="text" name="user_name" size="18" maxlength="16"
class="input_left" tabindex="11" /

using the following to try and get user_name, but $user_name comes
back blank in both cases...

$user_name=$HTTP_POST_VARS['user_name'];

$user_name=$_POST['user_name'];

What is the full <FORM> tag?

--
Tony Garcia
http://www.dslextreme.com/~tony23/

Domestos
heres the html code...

<?php
$user_name=' ';
require_once('includes.php');
do_html_header('register');
?>
<form action="register_new.php" method="post" enctype="text/plain"
name="register">
<fieldset><legend>Personal Details</legend>
<p>
<label for="user_name" class="label_left"> Login Username :</label>
<input type="text" name="user_name" size="18" maxlength="16"
class="input_left" tabindex="11" />
</form>
<?php
?>


and here is the file register_new.php


<?php
require_once('includes.php');
//create short variable names
$user_name=$_POST['user_name'];

echo $user_name;

?>


And it leaves a blank screen !!!!

Geoff Berrow
I noticed that Message-ID: <voHre.23276$[Email Removed]>
from Domestos contained the following:

QUOTE

And it leaves a blank screen !!!!

Standard advice, strip code down to the shortest snippet that shows the
error.

--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011

Kimmo Laine
"Domestos" <[Email Removed]> kirjoitti
viestiss:voHre.23276$[Email Removed]...
QUOTE
heres the html code...

<?php
$user_name=' ';
require_once('includes.php');
do_html_header('register');
?
<form action="register_new.php" method="post" enctype="text/plain"
name="register"
<fieldset><legend>Personal Details</legend
<p
<label for="user_name" class="label_left"> Login Username :</label
<input type="text" name="user_name" size="18" maxlength="16"
class="input_left" tabindex="11" /

Dude! Where's My Submit button??

QUOTE
</form
<?php
?


and here is the file register_new.php


<?php
require_once('includes.php');
//create short variable names
$user_name=$_POST['user_name'];

echo $user_name;

?

Try debugging by making sure you get variables outside php in _some_ cases.
Easy code in other words.
Make page.php that you call with page.php?foo=bar
contets of said page:
<?php
var_dump($_GET);
var_dump($_POST);
var_dump($HTTP_GET_VARS);
var_dump($HTTP_POST_VARS);
var_dump($_REQUEST);
?>

['foo']=bar should appear at least in three arrays: request, get and
http_get_vars. If it doesn't, contact administrator.

Next add to said page.php the following code
<form method="POST">
<input type="submit" name="foo" value="bar">
</form>

Click the button bar. Again ['foo']=bar should appear at least in three
arrays: request, post and http_post_vars. If it doesn't, contact
administrator.

--
"I am pro death penalty. That way people learn
their lesson for the next time." -- Britney Spears

[Email Removed]

insekta
hi all,

don't you need () around the $_POST?

as in .. $user_name = ($_POST['user_name']);

<snip>

QUOTE
$user_name=$_POST['user_name'];

echo $user_name;


</snip>

just wondering...

p.j.

(i'm relatively new to all of this stuff too.)

Kimmo Laine
"insekta" <[Email Removed]> kirjoitti
viestiss:42b055d8$0$11710$[Email Removed]...
QUOTE
hi all,

don't you need () around the $_POST?

as in .. $user_name = ($_POST['user_name']);


No. Who ever gave you that idea?

--
"I am pro death penalty. That way people learn
their lesson for the next time." -- Britney Spears

[Email Removed]


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.