...

View Full Version : I'm going crazy, please help!



erickkz
01-12-2006, 03:08 PM
Hi!

I'm building my php scripts in one computer and i don't have any problem, but when I test the same programs in other (win xp ie) don't work at all, specially whe you do submit. I tried testing with this simple script:

<?php
if($_POST["test"]){
print "test ok";
print $testa;
}
?>
<HTML>
<HEAD>
</HEAD>
<BODY>
<form action="<?$_SERVER['PHP_SELF']?>" method="post" name="forma" enctype="multipart/form-data">
<input type="submit" name="test" value="submit">
<input type="text" name="texta" size="20">
</form>
</BODY>
</HTML>

When you submit the form, print "test ok", but no the value of $testa variable. I use this way to send data and always works. (wamp5)

I checked the services wampapache and wampmysqld and both are working then i tried printing phpinfo() and it works too.

the problem is, i guess, that the form in not sending data!

Pennimus
01-12-2006, 03:20 PM
Could it be that the name of the input is 'texta' and you are trying to print 'testa'?

Masterslave
01-12-2006, 03:20 PM
<?php
if($_POST["test"]){
print "test ok";
print $testa;
}
?>


<input type="text" name="texta" size="20">
It think you've made a typo...

erickkz
01-12-2006, 04:16 PM
:D oh! sorry, my mistake, but the real code is:

<?php
if($_POST["test"]){
print "test ok";
print $texta;
}
?>
<HTML>
<HEAD>
</HEAD>
<BODY>
<form action="<?$_SERVER['PHP_SELF']?>" method="post" name="forma" enctype="multipart/form-data">
<input type="submit" name="test" value="submit">
<input type="text" name="texta" size="20">
</form>
</BODY>
</HTML>

And how I said before, don't send data!

Pennimus
01-12-2006, 04:45 PM
Don't you need to assign the contents of the text field to a $var via $_POST before trying to print/echo it?



$texta = $_POST["texta"];
print $texta;

jabbic
01-12-2006, 05:05 PM
I was also thinking that.

erickkz
01-12-2006, 05:32 PM
Nice!

But don't work either:( .

Maybe is the php.ini configuration. Any<way, I think i give up!

thanks people!

erickkz
01-12-2006, 05:45 PM
:confused: I'll give a last try editing php.in and the httpd.conf.

But why the scripts run nice in my computer and the other not?
that supposed is the same installation.

marek_mar
01-12-2006, 06:07 PM
Don't you need to assign the contents of the text field to a $var via $_POST before trying to print/echo it?



$texta = $_POST["texta"];
print $texta;

No you don't.

Velox Letum
01-12-2006, 07:13 PM
If register_globals is off (which it is by default, and should stay that way), then you can only access POST variables by the $_POST superglobal array. Also, I wonder if the enctype="multipart/form-data" is malfunctioning in IE, as it's usually used in conjunction with a file upload field.

marek_mar
01-12-2006, 10:51 PM
It shouldn't as I used it in forms and it worked.

firepages
01-13-2006, 01:20 AM
You have the "texta" field AFTER the submit button , so it does not get sent, also if you are using the superglobals (as you should be) $_POST in one place then use it everywhere...



<?php
if($_POST["test"]){
print "test ok";
print $_POST['texta'];
}
?>

maltrecho
01-13-2006, 07:47 AM
You should never rely in submit's names:
Edited: Why? Explorer won't always send their values.

<?php
if (isset($_POST['test'])) {
print "test ok";
if (isset($_POST['texta'])) {
$texta = stripslashes($_POST['texta']);
print htmlentities($texta);
}
}
?>
<HTML>
<HEAD>
</HEAD>
<BODY>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="forma" enctype="multipart/form-data">
<input type="text" name="texta" size="20">
<input type="hidden" name="test" value="1">
<input type="submit" value="submit">
</form>
</BODY>
</HTML>

firepages
01-13-2006, 10:35 AM
You should never rely in submit's names:
Edited: Why? Explorer won't always send their values.

?? yes it will if it is well formed

the issue was the ordering of the inputs which your form corrects, adding the extra field however is redundant.

erickkz
01-13-2006, 04:08 PM
At last!

:D finally, it was my php.ini configuration!

thanks people!
Your advices are very usefull to avoid further problems. I will change my poor programming style.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum