Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

PHP not Passing Values

Posted on 2004-03-24
17
449 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to fix Datetime in MySQL? 4 47
How to display div value on input field value in php 11 53
Ajax and PHP 4 29
Force PDF to open inline as opposed to dowload 16 22
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

809 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