...

View Full Version : Resolved Simple Form Submission



coolcamo8642
08-27-2009, 01:10 AM
I'm working on a script which [is supposed to] submit a form to itself, process data, and display it.

I've watered down the code to the form-specific elements:


<?php
echo'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP Form Test</title>
</head>';

if ($_GET['act'] == "Submit") {
$_POST["Text"];
}

echo'
<body>
<form action="test.php?act=Submit" method="post" name="Test">
<input name="Text" type="text" />
<input name="submit" type="submit" />
</form>';

echo '<p>'; echo $Text; echo '</p>';

echo'
</body>
</html>';
?>


In theory, that script should show whatever's entered into the text field in a paragraph after submission. But it doesn't. I've been pondering over this for some time and have yet to find a viable explanation. The code that this was derived from has worked in the past, however, right now I'm only testing it on a localhost setup.

Any input would be appreciated.

funnymoney
08-27-2009, 01:14 AM
probably here is the problem


if ($_GET['act'] == "Submit") {
$Text = $_POST["Text"];
}

coolcamo8642
08-27-2009, 02:04 AM
Okay, wow. That was so simple even I didn't expect it, but it worked. I know that it has worked in the past as I posted it, but I suppose a newer version of PHP could have a more strict syntax.

Thanks for your help!

whizard
08-27-2009, 02:08 AM
It has to do with register_globals being turned off by default in newer versions of PHP to prevent against manipulation where a hacker could add info via say, $_GET and override a session variable which told the script whether you were logged in or not.

Dan



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum