Solved

PHP not Passing Values

Posted on 2004-03-24
17
441 Views
Last Modified: 2013-12-13
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
0
Comment
Question by:mattleyland
  • 8
  • 5
  • 4
17 Comments
 
LVL 1

Expert Comment

by:essage
ID: 10667572
Have you tried

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

print $user; ?>

0
 
LVL 1

Expert Comment

by:essage
ID: 10667726
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
 

Author Comment

by:mattleyland
ID: 10668609
Still nothing iam afraid :S
0
 
LVL 1

Expert Comment

by:allelopath
ID: 10668680
Does it need to be
$user=$_GET['users'];
('users' instead of users)
0
 

Author Comment

by:mattleyland
ID: 10668893
nope tried them both, with no luck
0
 
LVL 1

Expert Comment

by:allelopath
ID: 10669211
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
 
LVL 1

Expert Comment

by:allelopath
ID: 10669224
...valid value...
0
 
LVL 1

Expert Comment

by:allelopath
ID: 10669250
also try using $_POST insteand of $_GET
if that doesn't work, keep $_GET, but method="GET"

just thinking out loud here.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:allelopath
ID: 10669482
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
 
LVL 1

Expert Comment

by:essage
ID: 10670927
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
 
LVL 1

Accepted Solution

by:
allelopath earned 500 total points
ID: 10671528
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
 

Author Comment

by:mattleyland
ID: 10672435
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
 
LVL 1

Expert Comment

by:allelopath
ID: 10673587
geez...thanks for the points...but beware of register_globals being on, there are security risks:
http://us4.php.net/register_globals
0
 
LVL 1

Expert Comment

by:essage
ID: 10676149
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
 
LVL 1

Expert Comment

by:essage
ID: 10676175
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
 
LVL 1

Expert Comment

by:allelopath
ID: 10678873
points should have split, most definitely...sorry essage.

0
 

Author Comment

by:mattleyland
ID: 10682999
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now