Jump to content

php form submit code not working


FirstBorn

Recommended Posts

Hi,

 

Thank you for reading.

 

I'm using the form submit code

Code:

 

<?php print $_SERVER["PHP_SELF"]; ?>

 

and it does not work for some reason...

 

Here is sample code for what I'm using:

 

<?php

if($_POST["submit"]) {

echo "Submit!";

} else {

?>
<html>
<head><title>Test Submit</title>
</head>
<body>
<form action="<?php print $_SERVER["PHP_SELF"]; ?>" method="post">
	<INPUT TYPE="submit" value="submit">
	<input type="reset" value="Reset">
</FORM>		
	<!-- form code ends here! -->
</body>
</html>
<?php } ?>

Why is this not working?

 

What I mean by 'not working' is that when

you press the button, it seems to reload the page

and doesn't seem to count the button click as a 'submit'

at all...

 

Any Ideas?

 

Thank you for your help!

 

Thanks,

FirstBorn

 

PS.  I've used two different webservers / hosts to test this out on,

and this script works on NEITHER of them.

(Dreamhost and HostGator Servers...)

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/138536-php-form-submit-code-not-working/
Share on other sites

You need to give the submit button a name for it to be transmitted. BTW, if your script submits to itself, you don't need an action:

<form action="" method="post">
	<INPUT TYPE="submit" name="submit" value="submit">
	<input type="reset" value="Reset">
</FORM>

 

Ken

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.