robert_gsfame Posted September 3, 2009 Share Posted September 3, 2009 if((!empty($_POST['title'])) && (!empty($_POST['text']))){ $check="success.php";}else{ $check="failed.php";}?> <form method = "post" action="<?php echo $check;?>"> Which part is wrong as i always go to failed.php although both text and title are not empty i've tried with !isset but it didn't work either...need someone suggestion.. Thanks in advance Quote Link to comment Share on other sites More sharing options...
Bricktop Posted September 3, 2009 Share Posted September 3, 2009 Hi robert_gsfame, action= will always be "failed.php" because the action= attribute is taken from the moment you press the "Submit" button. Because PHP is server-side, the PHP code you posted does not get processed until after the "Submit" button has been pressed. Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted September 3, 2009 Author Share Posted September 3, 2009 yeah i know..i've put the submit button, once clicked then it goes to failed.php although i've made a condition using IF Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 3, 2009 Share Posted September 3, 2009 although both text and title are not empty Prove it. What do you get when you use the following - echo "<pre>",print_r($_POST,true),"</pre>"; Quote Link to comment Share on other sites More sharing options...
lihman Posted September 3, 2009 Share Posted September 3, 2009 Try this: Make a new file called action.php and in it place the following code: <?php if((!empty($_POST['title'])) && (!empty($_POST['text']))){ INSERT INTO HERE WHATEVER IS IN success.php (excluding <?php and ?>) ; } else { INSERT INTO HERE WHATEVER IS IN failed.php (excluding <?php and ?>) ; } ?> Change the code on the form to this: <form method="POST" action="action.php"> Maybe you should try that Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.