Jump to content

[SOLVED] Noob problem with isset to prevent execution


colinsp

Recommended Posts

I am trying to prevent the execution of my php code until the user presses the submit button on a form. I have been at this for a few hours and I'll bet its something stupid but all the Google searching is just leading me in circles. Any thoughts most welcome.

 

<form name="new_advert" action="<?=$_SERVER['PHP_SELF'] ?>" method="POST"

then all my forum input stuff, then

<input type="submit" name="Submit" id="Submit" value="Submit" >
</form>

<?php 
if (isset($_POST['Submit'])) { } // wait until the submit button is pressed

 

then the rest of my php code. It is this that is being executed when I want it to wait for the submit button.

 

TIA

 

Colin

 

Submit should be submit.  Lower case 's'

 

Well, no because the name of the submit button is "Submit".

 

However...why don't you try something like this...?

 

if(!isset($_POST['Submit']))
{
echo '<form...';//forum stuff
}
else
{
//put the stuff you want to execute here
}

 

Also, just to let you know, you don't need PHP_SELF in your form action. You can just put action="" and it does the same thing.

 

Anyway, hope this helps.

Is it still executing? The code should work fine as long as you are aware that the code you want executed IF the submit button has been pressed, is inside those { & } brackets.

 

Doh, why didn't I spot that? Thanks very much one too many } in the wrong place.

 

Thanks for the other suggestions too.

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.