I have a simple form which I want to try out (before rewriting to do
something useful)... and am having problems getting the variable to output.
From what I read I have coded it to get around the "register_globals"
being off (both on my localhost and my ISP)... but I cannot get the
variable output, below is my HTML and PHP.
Basically, the HTML file contains a form with a select box which is
supposed to pass the variable to the PHP script so it can print the result
of the variable selected.
After much searching online and head scratching, I can't find what I've
done wrong. Can anyone help?
Dariusz
++HTML++
<HTML><HEAD><TITLE>Redirector test</TITLE></HEAD>
<BODY>
<FORM method="POST" action="redirector.php">
<select name="$_POST['album']">
<option value="a01-t01" SELECTED>Album 01, Track 01</option>
<option value="a01-t02">Album 01, Track 02</option>
</select>
<input type="submit" value="Submit">
</FORM>
</BODY>
</HTML>
++PHP++
<?
echo ('The results is: $album');
?> 5 2130
Dariusz wrote: I have a simple form which I want to try out (before rewriting to do something useful)... and am having problems getting the variable to output. From what I read I have coded it to get around the "register_globals" being off (both on my localhost and my ISP)... but I cannot get the variable output, below is my HTML and PHP.
You've got them backwards...
++HTML++ <select name="$_POST['album']">
<select name="album">
++PHP++ echo ('The results is: $album');
echo 'The results is: ',$_POST['album'];
--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended. ng@lycaus.plusYOURSHIT.com (Dariusz) schrieb: ++HTML++
<FORM method="POST" action="redirector.php"> <select name="$_POST['album']"> <option value="a01-t01" SELECTED>Album 01, Track 01</option> <option value="a01-t02">Album 01, Track 02</option> </select> <input type="submit" value="Submit"> </FORM>
<form method='post' action='redirector.php' name='myform'>
<select name='album'>
<option value='a01-t01' selected='selected'>
Album 01, Track 01</option>
<option value='a01-t02'>
Album 01, Track 02</option>
</select>
<input type='submit' name='submit' value='Submit'>
</form>
++PHP++
<? echo ('The results is: $album'); ?>
<?
echo ("The result is {$_POST['album']}");
?>
or better
<?php
if (isset($_POST['album'])) {
echo ('The result is: ' . $_POST['album']);
}
?>
Compare your code and my code and try to find out what you've done
wrong. If you really can't figure it out and need more explanations feel
free to ask again.
Regards,
Matthias
In article <jv*****************@news7.onvoy.net>, Justin Koivisto <sp**@koivi.com> wrote: You've got them backwards...
++HTML++ <select name="$_POST['album']">
<select name="album">
++PHP++ echo ('The results is: $album');
echo 'The results is: ',$_POST['album'];
Thanks for that... I thought it must be something simple as there was not
much code there to get wrong !!
Dariusz
In article <bp**********@usenet.esken.de>, Matthias Esken <ne******************@usenetverwaltung.org> wrote: ng@lycaus.plusYOURSHIT.com (Dariusz) schrieb:
Okay the HTML you you corrected I redid... ++PHP++ <? echo ("The result is {$_POST['album']}"); ?>
Now with the correct PHP code, the thing works. Thanks for that :-).
or better
<?php if (isset($_POST['album'])) { echo ('The result is: ' . $_POST['album']); } ?>
Compare your code and my code and try to find out what you've done wrong. If you really can't figure it out and need more explanations feel free to ask again.
Well, as you bring it up, what is the difference between the first PHP code
and the second? Which is better to use? Why? etc...
Dariusz ng@lycaus.plusYOURSHIT.com (Dariusz) schrieb: In article <bp**********@usenet.esken.de>, Matthias Esken <ne******************@usenetverwaltung.org> wrote: ng@lycaus.plusYOURSHIT.com (Dariusz) schrieb:
++PHP++ <? echo ("The result is {$_POST['album']}"); ?>
or better
<?php if (isset($_POST['album'])) { echo ('The result is: ' . $_POST['album']); } ?>
Compare your code and my code and try to find out what you've done wrong. If you really can't figure it out and need more explanations feel free to ask again.
Well, as you bring it up, what is the difference between the first PHP code and the second? Which is better to use? Why? etc...
If you call the php script without posting a value for 'album' it will
throw a warning in the first case. Then it will assume, that
$_POST['album'] might be an empty string (or maybe a number with the
value 0), create the variable $_POST['album'] and output the data. You
rely on the interpreters guess, what you really wanted to do.
In the second case the script checks if it received a value and will not
output anything if there was no value.
Regards,
Matthias This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Titus |
last post by:
Hi,
Just installed PHP, and Apache. Am having problems with the PHP to
get form data from an HTML file. Specifically, I can not obtain the
variable "tireqty" in a PHP file called by an HTML...
|
by: Tony |
last post by:
I'm working with someone on a PHP project. The other person is doing
testing of scripts on their personal machine using Apache as a web server.
The production server and the one I'm using are both...
|
by: Jim Johnstone |
last post by:
Some details of my HOME PC. I am running the following ....
Win2000 SP4; IE V6; 512MB RAM; H/Disk Space OK.
In the past couple of weeks I have installed/configured from binaries for ..
MySQL...
|
by: lian |
last post by:
Hi all,
I have installed a web-based software written in php which needs
that i should turn "register_globals" from off to on in the php.ini.
There are some comments for register_globals in...
|
by: Dave |
last post by:
Hi folks,
I seem to be using these newsgroups a good bit and probabely will be for the
next three or so months.
I wonder if there is a workaround to a problem I'm having. PHP always says
that...
|
by: wisptech |
last post by:
Here is the code that I used to test my server, very simple, right?
But when I click on submit, nothing.. I've also tried similar things
with php and mysql and all it did was create empty fields in...
|
by: Chuck Anderson |
last post by:
I have finally started coding with register_globals off (crowd roars -
yeay!).
This has created a situation that I am not sure how I should handle. I
have scripts (pages) that can receive an...
|
by: WhatsPHP |
last post by:
Hi
For some reason, at random posts, the post variables don't get thru to
the server. For example, if there is are two text fields: name and
email... (I have register_globals on)... When I try...
|
by: Eric.Thomas.Moore |
last post by:
Hey,
My old boss wrote an extensive work tracking system in php for
internal use. He left and the server he is running it on is very
outdated so I have been given the task of transfering it...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| | |