By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,796 Members | 1,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,796 IT Pros & Developers. It's quick & easy.

getting data out of <FORM> in php variable

P: n/a
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...

$user_name=$HTTP_POST_VARS['user_name'];


Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Mon, 13 Jun 2005 20:40:12 GMT, "Domestos" <ne*******@mind.net> wrote:
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...

$user_name=$HTTP_POST_VARS['user_name'];


Don't multipost. Post a minimal runnable script that demonstrates your
problem.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2

P: n/a
Try using $_POST['whatever']

Jul 17 '05 #3

P: n/a
Domestos (ne*******@mind.net) decided we needed to hear...
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...

$user_name=$HTTP_POST_VARS['user_name'];


What is the method attribute set to in your form tag? It should be set
to 'post' and defaults to 'get' if you don't specify it.

As an aside you should really be using $_POST instead of
$HTTP_POST_VARS which is deprecated.
--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)
Jul 17 '05 #4

P: n/a
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 !!!!
Jul 17 '05 #5

P: n/a


Domestos wrote:
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 !!!!


What happens if you remove the 'enctype="text/plain"' from your <form>?

If you change your register_new.php to

<?php
echo '<pre>';print_r($_POST);echo '</pre>';
?>

What displays on the screen?

Ken

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.