advancedfuture Posted January 3, 2009 Share Posted January 3, 2009 I am trying to execute some PHP code, I've done this before on my godaddy hosting account, but for some reason the code isn't working now that I ported it over to my private server. It WORKS if i put the PHP on a seperate page and send the info through action=... but the if statement is not working if i try to execute the code on the same page ): Here's the stripped down version of the code.... <form name="signup" id="signup" method="post" action=""> <div align="center"> First Name: <input type="text" name="first_name" id="first_name" /> <input type="submit" id="dosubmit" name="dosubmit" value="Sign Up!" /> </div> </form> <?php if(isset($_POST['dosubmit'])) { echo "CHEESE!"; } ?> am I doing something wrong? The code just isnt executing... Link to comment https://forums.phpfreaks.com/topic/139295-issue-with-php-form-submit/ Share on other sites More sharing options...
ram4nd Posted January 3, 2009 Share Posted January 3, 2009 in you action should be this like that: action="<?php echo $PHP_SELF; ?>" Link to comment https://forums.phpfreaks.com/topic/139295-issue-with-php-form-submit/#findComment-728591 Share on other sites More sharing options...
dezkit Posted January 3, 2009 Share Posted January 3, 2009 <?php if(isset($_POST['dosubmit'])){ echo "CHEESE!"; } ?> <form name="signup" id="signup" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <div align="center"> First Name: <input type="text" name="first_name" id="first_name" /> <input type="submit" id="dosubmit" name="dosubmit" value="Sign Up!" /> </div> </form> Link to comment https://forums.phpfreaks.com/topic/139295-issue-with-php-form-submit/#findComment-728601 Share on other sites More sharing options...
PFMaBiSmAd Posted January 3, 2009 Share Posted January 3, 2009 An empty action value causes a form to submit to the same page, so $_SERVER['PHP_SELF'] is actually not necessary. What is the file name you are using for the single page? Link to comment https://forums.phpfreaks.com/topic/139295-issue-with-php-form-submit/#findComment-728627 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.