unistake Posted October 23, 2010 Share Posted October 23, 2010 Hi all, I have been working on this script for over 5 hours, the script used to work but I have recreated some html code in the html form and I think it may have something to do with why the script does not work but I can not see it. Hopefully an extra pair of eyes can help. The I have tested what the $_POST['title'] below echos in the php script and it does carry the value to the php page, but the IF statement does not work. Here it is: html form in a php page: <form action="testform.php" method="post"> <fieldset style="border:none"> <ul class="controls"> <li> <label for="label">Title</label> <input name="title" id="title" type="text" class="text" maxlength="" value="grumman aa4" /> </li> <li> <label for="label">Aircraft Registration</label> <input name="reg" id="label" type="text" class="text" maxlength="6" value="G-qwea" style="text-transform:uppercase;" /> </li> <li> <input name="Button" type="submit" class="button centered" /> </li> </ul> </fieldset></form> The part of the PHP page that does not work is below. If the php below just says if ($_POST['reg'] == "")... it works but as soon as I put || $_POST['title'] it does not work. I have also tried if ($_POST['reg'] && $_POST['title'] == "")... which DOES work? testform.php <?php if ($_POST['reg'] || $_POST['title'] == "") { $fillinform = "Please fill in all the form to add a listing."; include("saleform.php"); exit(); } ?> Link to comment https://forums.phpfreaks.com/topic/216671-simple-_post-problem/ Share on other sites More sharing options...
PaulRyan Posted October 23, 2010 Share Posted October 23, 2010 The IF statement doesn't seem to work the way you want it too, I have had the same problem in the past. Try the following... <?php if ($_POST['reg'] == "" || $_POST['title'] == "") { $fillinform = "Please fill in all the form to add a listing."; include("saleform.php"); exit(); } ?> Tell me how this goes Regards, Paul. Link to comment https://forums.phpfreaks.com/topic/216671-simple-_post-problem/#findComment-1125724 Share on other sites More sharing options...
Vitamin Posted October 23, 2010 Share Posted October 23, 2010 I'm not exactly sure what you are trying to do, but if you want to make sure $_POST['reg'] has a value do if (isset($_POST['reg']) || $_POST['title'] == "") { Link to comment https://forums.phpfreaks.com/topic/216671-simple-_post-problem/#findComment-1125725 Share on other sites More sharing options...
unistake Posted October 23, 2010 Author Share Posted October 23, 2010 Paul: Ok will give it a try, I have the exact same script as the one I have just posted and it works fine. Ill let you know in a min if it works thanks. Vitamin: Yes that is what I am trying to do, but also checking if $_POST['title'] has a value. Link to comment https://forums.phpfreaks.com/topic/216671-simple-_post-problem/#findComment-1125726 Share on other sites More sharing options...
unistake Posted October 23, 2010 Author Share Posted October 23, 2010 Paul that works thanks! I have spent around 5 hours trying to do that today - your a genius lol! I have another 8 $_POST['values'] to put in so hope they all work. Thanks Link to comment https://forums.phpfreaks.com/topic/216671-simple-_post-problem/#findComment-1125727 Share on other sites More sharing options...
PaulRyan Posted October 23, 2010 Share Posted October 23, 2010 Yeahh well just make sure you check each one individually then they should work bud. If you have any more problems, just post here and we will help you out. Regards, Paul. Link to comment https://forums.phpfreaks.com/topic/216671-simple-_post-problem/#findComment-1125728 Share on other sites More sharing options...
wannabephpdude Posted October 23, 2010 Share Posted October 23, 2010 Try something like this... <?php if (empty($_POST['reg']) || empty($_POST['title'])) { $fillinform = "Please fill in all the form to add a listing."; // anything else you can think of here } else { // Then place your positive outcome here } ?> Good Luck - tony Link to comment https://forums.phpfreaks.com/topic/216671-simple-_post-problem/#findComment-1125729 Share on other sites More sharing options...
unistake Posted October 23, 2010 Author Share Posted October 23, 2010 Yeah they all work Paul. Cheers. Link to comment https://forums.phpfreaks.com/topic/216671-simple-_post-problem/#findComment-1125730 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.