Jump to content

[SOLVED] isset post question


graham23s

Recommended Posts

Hi Guys,

 

i have a button on a form just a basic one:

 

<input name="submit" class="button" type="submit" value="Submit">

 

i tried to do:

 

     if (isset($_POST['submit'])) {
     
     echo 'DO CODE HERE!!';
     include("includes/footer.php");
     exit;
     
     }
     

 

i dont want to actually do a form just execute the code once the submit button is pressed is that possible or do i need to do the <form  action , method etc> code?

 

thanks guys

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/64313-solved-isset-post-question/
Share on other sites

The $_POST array doesn't receive the submit key and value unless it is sent to it using the POST method. There is no way for php to catch html events, (such as button presses) Javascript can, though. If you want to run php after a button is pressed, the button has to redirect to that php page, somehow.

u can use isset() on another form element rather then the button, as its value is passed to the post superglobal only if the button is pressed. Usually people fill in data and just press enter which doesnt pass the button's value to post. Hope im clear with this lol.

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.