Plugin Coding: Form troubles

jmstacey

Verified User
Joined
Feb 12, 2004
Messages
4,106
Location
Colorado
I'm trying to create a form for a plugin I'm trying to develop but not having much luck passing information from a form into a php variable. To test it out I'm using just a simple script which works perfectly run as a normal php script but will not pass the information when running it through DirectAdmin.

Heres the script:

Code:
#!/usr/local/bin/php -c /usr/local/lib/php.ini

<?php
if (isset($_POST['test']))
{
$test = $_POST['test'];
echo "$test";
die;
}


echo "<form method='post' enctype='multipart/form-data'>";
echo "<input type='text' name='test' size='25'>";
echo "<input type='submit' name='install' value='Install'>";
echo "</form>";

?>

How else can I get form data into php so I can use the information collected in my scripts.
 
DirectAdmin does not populate the PHP super global variables.

This is more or less what I do in Installatron:
PHP:
$_COOKIE = $_POST = $_GET = array();

// load up cookies
$cookie = split('; ',$_SERVER['HTTP_COOKIE']);
foreach ( $cookie as $pair )
{
	$pair = split('=',$pair,2);
	$_COOKIE[$pair[0]] = $pair[1];
}
unset($cookie);

// get DA HTTP GET & POST data
parse_str($_SERVER['QUERY_STRING'],$_GET);
parse_str($_SERVER['POST'],$_POST);

// get rid of slashes if magic quotes is enabled
if (get_magic_quotes_gpc())
{
	foreach ( $_GET as $key => $value )
	{
		$_GET[$key] = stripslashes($value);
	}

	foreach ( $_POST as $key => $value )
	{
		$_POST[$key] = stripslashes($value);
	}

}
 
If your interested, have more time and feel like working on this a little more.
I have found that it does not pass Arrays. After some debugging I found that it appears to not parse it correctly. For example if I store the _Post information to a variable such as $data and echo it
echo $data[0]
echo $data[1] and so one through 5

It comes out to be "Array"
where $data[0] is "A"
$data[1] is "r"
:p
 
Hello,

That is because of the get_magic_quotes_gpc() block I'd say. Remove it, or modify it to work with arrays, and arrays should work.

Phi1.
 
Back
Top