LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Mandriva
User Name
Password
Mandriva This Forum is for the discussion of Mandriva (Mandrake) Linux.

Notices


Reply
  Search this Thread
Old 10-19-2003, 01:33 PM   #1
nvargas
Member
 
Registered: Jan 2002
Location: Managua, Nicaragua
Distribution: Mandriva, SuSE, Ubuntu
Posts: 46

Rep: Reputation: 15
Problems with PHP in Mandrake 9.1


Hi,

I've been working with Quanta, PHP & Apache since version 8.1 and had no problems before.

Right now, I'm developing a simple mailing form with Mandrake 9.1 and it doesn't seem to pass the variables to the script.

I made a simple script for testing purposes and it still doesn't work.

This is the script:

<?PHP

echo phpinfo();
echo "<HTML><BODY><FORM ACTION =\"prueba.php\" method=\"POST\">\n";
if(empty($textoprueba))
echo "Prueba: <INPUT TYPE=\"text\" NAME=\"textoprueba\" SIZE =15 MAXLENGTH=15>\n";
else
echo "Prueba: <INPUT TYPE=\"text\" NAME=\"textoprueba\" SIZE =15 MAXLENGTH=15 VALUE=\"$textoprueba\">\n";
echo "Texto Prueba: $textoprueba";
echo "<INPUT TYPE=\"submit\" name=\"enviar\" value=\"Enviar\">\n";
echo "</form></body></html>";
?>


Whenever I send the form, phpinfo reports the query string as
prueba.php?textoprueba=Prueba&Enviar=enviar
but it processes the query as if textoprueba was empty (see script).

Any help will be greatly appreciated.
 
Old 10-19-2003, 05:09 PM   #2
g00$e
Member
 
Registered: Sep 2003
Location: Norfolk, VA
Distribution: Slackware
Posts: 119

Rep: Reputation: 15
It appears you are missing some curly braces { } which for some reason show up as brackets in the PHP code option.

PHP Code:
<?PHP
 
echo phpinfo();
echo 
"<HTML><BODY><FORM ACTION =\"prueba.php\" method=\"POST\">\n";
if(empty(
$textoprueba)) {
echo 
"Prueba: <INPUT TYPE=\"text\" NAME=\"textoprueba\" SIZE =15 MAXLENGTH=15>\n";
} else {
echo 
"Prueba: <INPUT TYPE=\"text\" NAME=\"textoprueba\" SIZE =15 MAXLENGTH=15 VALUE=\"$textoprueba\">\n";
echo 
"Texto Prueba: $textoprueba";
}
echo 
"<INPUT TYPE=\"submit\" name=\"enviar\" value=\"Enviar\">\n";
echo 
"</form></body></html>";
?>
 
Old 10-19-2003, 05:20 PM   #3
nvargas
Member
 
Registered: Jan 2002
Location: Managua, Nicaragua
Distribution: Mandriva, SuSE, Ubuntu
Posts: 46

Original Poster
Rep: Reputation: 15
nope, that's not it....
 
Old 10-19-2003, 08:16 PM   #4
nvargas
Member
 
Registered: Jan 2002
Location: Managua, Nicaragua
Distribution: Mandriva, SuSE, Ubuntu
Posts: 46

Original Poster
Rep: Reputation: 15
And the answer is....

Hi,

I found the answer somewhere else and here it is, hope it is useful to someone else


That is because GET/POST variables are not set in the global scope by default in PHP in newer installs. It was changed starting on version 4 I think.

You need to access the variable like this

echo $_GET['text'];

or if it came from a POST form ...

echo $_POST['text'];

it is $_POST['name'] //notice the underscore

You can turn register_globals on in php.ini and have the variables registered automatically, but it isn't a good idea.

Registering globals is a potential security risk. There is a reason the php consortium decided to discontinue the convenience. I say get in the habit of using your superglobals:

$_POST & $_GET. Only grab the vars you need.

ex.
$var=$_POST['var'];

I recommend adopting this style for all your future scripts. For old scripts, I say if you don't want to bother fixing them, and I don't blame you, throw these lines at the top of each script:

extract($_POST);
extract($_GET);
$PHP_SELF=$_SERVER['PHP_SELF'];


The order of POST and GET in the above might matter if you like to submit forms with query strings in the action.

This will also make your scripts more portable if you have to move them to a server where you don't get to edit the php.ini file.
 
Old 10-26-2003, 05:54 PM   #5
azornoz
Member
 
Registered: Apr 2003
Posts: 52

Rep: Reputation: 15
Gracias hermano, me has hecho un gran favor, tengo un libro de php de hace un par de aņos y me estaba volviendo loco con los forms get and post.

Thanks to nvargas.
Saludos a la gente de Nicaragua.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
slackware, apache and PHP from .tgz - problems with PHP szymon Slackware 2 09-06-2004 04:57 PM
Firebird+PHP+Mandrake 10 z_darius Mandriva 0 05-24-2004 11:11 AM
problems with the apache & Php server of mandrake linux 9.1 krotaz Linux - Networking 6 11-21-2003 08:24 PM
PHP on mandrake 9.1 men$an Linux - Software 7 04-21-2003 05:55 PM
Updating php 4.3.1 from tar and keeping current php configuration with mandrake 9.1 mrjeep Linux - General 0 04-02-2003 07:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Mandriva

All times are GMT -5. The time now is 11:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration