Not validating one of the search fields

Darkchaos

New Member
I want to check if either of my search fields are empty, and if they are i write out a failure message. For some reason the following code doesn't work when I try to submit empty values in both search fields, or leaving the q2 search field empty. It only writes out the failure message when I only insert a value into the first field. Hope you guys can help.\[code\]<div id="searchField"> <form name="searchField" action="" method="get"> <input type="search" name="q" id="submitQuery" autofocus="autofocus" value="http://stackoverflow.com/questions/15607649/<?= $_GET['q']; ?>" placeholder="enter one movie"/> <input type="search" name="q2" id="submitQuery2" value="http://stackoverflow.com/questions/15607649/<?= $_GET['q2']; ?>" placeholder="and then another one"/> <input type="hidden" id="v" name="v" value="http://stackoverflow.com/questions/15607649/2" /> <input type="hidden" id="b" name="b" value="" /> <button type="submit" id="loop" style="border:0px; background:transparent; vertical-align:middle; margin-left:-85px; margin-top:-3px;"> <img src="http://stackoverflow.com/questions/15607649/images/loop.png" width="75" height="75" alt="submit" /> </button> </form></div><div id="theData"><?if(str_replace(" ", "",$_GET['q'])!="" && str_replace(" ","",$_GET['q2'])!=""){ $qContent = $_GET['q']; $succes = mysql_query("SELECT*FROM film WHERE name='".$qContent."'"); include("searchMaster.php"); if(mysql_num_rows($succes)) { while($o = mysql_fetch_array($succes)){ echo $o['name']; if($o['trailer']){ echo '<div id="ytplayerWrap">'; echo '<iframe id="ytplayer" type="text/html" width="640" height="390" src="http://www.youtube.com/embed/'.$o['trailer'].'?http://amnestic.ueuo.com" frameborder="0"/>'; echo '</div>'; }else { echo '<span style="font-size:20px;">'; echo '<br /><br /> No trailer was found for <em>'.$_GET['q'].'</em> :('; echo '</span>'; } } }else{ echo 'You did the fuckup :('; }}else{echo 'You did the fuckup :(';}?>\[/code\]
 
Back
Top