PHP not Passing Values

Hello

I have a form with the following

<form method="POST" action="makeconfig.php">
<input type="text" name="users" size="20" >
</form>

and on my second php page called makeconfig.php i have

<?php print $user; ?>

When the first value is entered on the form it should display this on the second page. But it isnet if i was to put the folloing into the php page

<? $user=30 ?>

It will display this fine so my prblem is that its not sending the varibles through, i have to check to see if it is my browser causing teh problem but its not so i think its a config problem ?

Iam running plesk 6.02 default installation, php version 4.2.2 and redhat 9

Thanks

matt
mattleylandAsked:
Who is Participating?
 
allelopathConnect With a Mentor Commented:
essage,
$_POST and $_GET are arrays.
method="POST" causes values to be stored in the $_POST array
so then in order get the value of users, wouldn't $_POST have to be accessed, not $_GET?
$users=$_POST['users'];
I could be wrong...if so, please explain.
 
0
 
essageCommented:
Have you tried

<?php
$user=$_GET[user];

print $user; ?>

0
 
essageCommented:
Excuse me for the typo:   after reading your form again

 "<form method="POST" action="makeconfig.php">
<input type="text" name="users" size="20" >
</form>"

I saw that user was plural, so the code I wrote above should be

<?php
$user=$_GET[users];

print $user; ?>

on makeconfig.php
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
mattleylandAuthor Commented:
Still nothing iam afraid :S
0
 
allelopathCommented:
Does it need to be
$user=$_GET['users'];
('users' instead of users)
0
 
mattleylandAuthor Commented:
nope tried them both, with no luck
0
 
allelopathCommented:
hmmm...i would also try double quotes, just to make sure, but i don't think that's it

can you verify that users is a valid valid on the html side?
<?php print $_GET["users"]; ?>
0
 
allelopathCommented:
...valid value...
0
 
allelopathCommented:
also try using $_POST insteand of $_GET
if that doesn't work, keep $_GET, but method="GET"

just thinking out loud here.
0
 
allelopathCommented:
if none of those work then, i see from now having actually looked it up, you may need to do session tracking, using the $_SESSION array

session_start();
$_SESSION['users'] = $_GET['users']

and then elsewhere:
session_start();
$users = htmlentities ($_SESSION['users']


0
 
essageCommented:
Here is another idea, try using this as your form,

<form method="POST" action="makeconfig.php?user=users">
<input type="text" name="users" size="20" >
</form>

the n in makeconfig, do
$user=$_GET['user'];

or something down that line of thought.   If none of these ideas work, can you give us the complete code for your two pages?

~essage
0
 
mattleylandAuthor Commented:
The script works now, in my php.ini registar_globals was turned off as default, now its working fine just with

<?php print $users; ?>


Thanks

Matt
0
 
allelopathCommented:
geez...thanks for the points...but beware of register_globals being on, there are security risks:
http://us4.php.net/register_globals
0
 
essageCommented:
allelopath, $_POST and $_GET ARE arrays, but $_GET is a degraded version of $_POST.   When you post and move to another page, the $_GET method will act more constantly over multiple platforms, but if you stay in the same page, $_POST is more consistent.
0
 
essageCommented:
Mattleyland, you should have split the points, because most of what allelopath said was the same (or very similar) as I said, and I answered first (except the session variables witch didn't help).

Allelopath is absolutly correct, you should try to aviod register_globals.
0
 
allelopathCommented:
points should have split, most definitely...sorry essage.

0
 
mattleylandAuthor Commented:
Iam not sure how to split the points as iam a very new member, essage i will post the same question again and you reply to it and i will award you the points. When i was acepting the comments i wonderd if i could split them but couldnet find a away so i didint award them to you because allelopath had been more active in the post
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.