Solved

PHP not Passing Values

Posted on 2004-03-24
17
435 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
Comment Utility
Have you tried

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

print $user; ?>

0
 
LVL 1

Expert Comment

by:essage
Comment Utility
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
Comment Utility
Still nothing iam afraid :S
0
 
LVL 1

Expert Comment

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

Author Comment

by:mattleyland
Comment Utility
nope tried them both, with no luck
0
 
LVL 1

Expert Comment

by:allelopath
Comment Utility
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
Comment Utility
...valid value...
0
 
LVL 1

Expert Comment

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

just thinking out loud here.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Expert Comment

by:allelopath
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
points should have split, most definitely...sorry essage.

0
 

Author Comment

by:mattleyland
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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 count occurrences of each item in an array.

744 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

17 Experts available now in Live!

Get 1:1 Help Now