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 Link to comment https://forums.phpfreaks.com/topic/172965-problem/ 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. Link to comment https://forums.phpfreaks.com/topic/172965-problem/#findComment-911607 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 Link to comment https://forums.phpfreaks.com/topic/172965-problem/#findComment-911728 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>"; Link to comment https://forums.phpfreaks.com/topic/172965-problem/#findComment-911735 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 Link to comment https://forums.phpfreaks.com/topic/172965-problem/#findComment-911908 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.