Forum Moderators: coopster

Message Too Old, No Replies

Passing hidden input doesn't work in PHP 5

         

andrewshim

5:11 am on Jan 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have an ecards system that I put together with my self-taught PHP skills.

In php 4, when I pass on hidden inputs to the processing script, it works. After moving to php 5, the hidden input values aren't passed. Does php 5 handle hidden inputs differently?

example :


<form name="preview" method="post" action="process.php">
<input type = "hidden" name = "sendername" value = "andrewshim">
</form>

over at process.php, I do this :

$sendername = $_POST["sendername"];

No values are passed... am I doing it wrong?

cameraman

6:07 am on Jan 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, it's the same - something else is going on. I pasted your segments into a file, added a Submit button, and changed the form's action to use the same file to process the form (which isn't necessary but is easier to see what's going on). It worked fine under php 5.2.0


<?php
error_reporting(E_ALL);
if(isset($_POST['sendername']))
$sendername = $_POST["sendername"];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body bgcolor="#FFFFFF" text="#000000">
<?php if(isset($sendername)) echo "<p>$sendername</p>\n";?>
<form name="preview" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<input type = "hidden" name = "sendername" value = "andrewshim" />
<input type = "submit" name="submit" value="Submit" />
</form>
</body>
</html>

jatar_k

2:41 pm on Jan 21, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try something simple to see all of your $_POST vars at the top of your process.php script

echo '<pre>';
print_r($_POST);
echo '</pre>';
die;

tht will just dump all of your post vars to the screen so you can look at them, you might see something strange

I had one recently where I was redirecting the process script by accident, everything was working but the redirect would happen and then everything was blank

very frustrating

henry0

2:46 pm on Jan 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Could it be php.ini Globals related?

andrewshim

3:45 am on Jan 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Tried 2 fresh pages. A simple form with one of the hidden inputs, passing to a print page. I can see the variable is passed.

Crap. That means something is wrong with my pages, so I took them offline for a while and will re-construct the page, testing line by line, to see what's causing the problem. I know it's right in front of my nose... just can't see it... I hate it when that happens!

Time constraints make it difficult, but I guess it has to be done... Thank god this site doesn't bring in money directly, but is used as a secondary marketing tool.

vincevincevince

5:58 am on Jan 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Common error:

if ($_POST["sendername"]="") then print "Name required";

i.e. using = instead of == to test if the string is blank. This will actually set $_POST["sendername"] to "" - check for that mistake :)