PHP files involving 'submit' not working in XAMPP

Problems with the Windows version of XAMPP, questions, comments, and anything related.

PHP files involving 'submit' not working in XAMPP

Postby redzucan » 20. April 2007 06:07

Hye. I'm a newbie here. Im using XAMPP 1.6 for Windows. And currently I've been facing problems with my php code which isnt working while using XAMPP. I've tried using other webservers and the code does work. The problem is that when the php involves 'submit' button, it seems that it does not execute nor does it writes in the database.

I tried browsing through the forum to find similar problems. Perhaps one of the best solutions that I found is as below.


DocBoje wrote:Ah, I've figured it out. Apparently my school has the register_globals = on, so that's why my code was working on their server and not locally.


The question is, how do you register_globals = on ? Or is there some other things that is going wrong. I have checked that all my php codes are using <?php instead of <?.

Kindly please help me. Cheers :)
redzucan
 
Posts: 2
Joined: 20. April 2007 03:30

Postby Wiedmann » 20. April 2007 08:46

The question is, how do you register_globals = on ?

If this is your problem, you should correct your code and not change this setting....

BTW:
This setting can be changed in the "php.ini".

BTW:
Please read the PHP manual about how to use external variables.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby redzucan » 22. April 2007 22:17

Unfortunately the problem has not been solved. Have been changing "register_globals = on", I still don't understand on the use of external variables and why it is labelled as 'incorrect' as a programming way. I'm not very good in understanding terms but as far as what I have seen and done, I do not see what makes the system not fully working in xampp.
redzucan
 
Posts: 2
Joined: 20. April 2007 03:30

Postby Wiedmann » 22. April 2007 23:43

I still don't understand on the use of external variables

That's really easy:
if you have this form (method="get") element
Code: Select all
<input type="text" name="test">

or this URI:
Code: Select all
http://localhost/file.php?test=xxx


you can acces this in PHP with:
Code: Select all
$_GET['test']


In a form with method="post" it is:
Code: Select all
$_POST['test']
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby ldivinag » 30. April 2007 00:03

ditto if you use a POST method:

Code: Select all
$var = $_POST["form_element"];
leo d.
User avatar
ldivinag
 
Posts: 40
Joined: 19. April 2006 04:18

Postby DocBoje » 01. May 2007 08:42

First off, could you post the code that you're having trouble with?

Secondly, if what you're trying to do is pass data from a form to another page that is called from the submit button, and register_globals is OFF on your server (which I believe is default), then you need to call your form variables in a different manner. You need to import the variables from that form using the function "import_request_variables(string $types [, string $prefix]);". Basically, 'string $types' will be a letter (g, p, or c) specifying what method you used to send your data (get, post, or a cookie). The prefix specifies a prefix that will be appended to the beginning of the variable name. When I had this problem, I put this line at the top of my php code:
Code: Select all
import_request_variables("p", "form_");


Then, when I referred to my variables, I referred to them as the variable name in the form with 'form_' in front of it. So if I had a variable called 'txtName' in my form, I would refer to it as 'form_txtName' in my php code.

Hope that helps!

DocBoje
Dealer? I'm alllllllll in!
DocBoje
 
Posts: 4
Joined: 29. March 2007 18:27

Postby Dave_L » 01. May 2007 14:14

import_request_variables is a solution, but is also a security risk.

It's better to use $_GET or $_POST as described in the previous posts. Then you know exactly which variables you're accessing.
User avatar
Dave_L
 
Posts: 212
Joined: 23. October 2004 00:43


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 67 guests