Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.