graham23s Posted June 16, 2007 Share Posted June 16, 2007 Hi Guys, on the forum i'm developing iv added a search forum option the code is: echo '<center><b>Options: </b><a href="forums.php?action=search">Search Forum</a><br /><br />'; $action = $_GET['action']; #################################################################################### if ($action == "search") { ## isset code ###################################################################### if(isset($_POST['submit'])) { echo '<br /><center><h4>Search Results</h4></center>'; include("includes/footer.php"); exit; } else { echo '<br /><center><h4>Search Forums</h4></center>'; echo '<table width="300" border="1" cellpadding="0" cellspacing="0" /> <form action="" method="POST" /> <th align="center" bgcolor="#004E98" /><font color="#ffffff">Type In Keywords To Search Forum</th> </tr> <tr> <td align="center"><input type="text" name="search_forum" size="40" /></td> </tr> <tr> <td align="right" bgcolor="#004E98" /><input type="submit" name="submit" value="Search Forum" /></td> </table></form><br />'; include("includes/footer.php"); exit; } ## isset code ###################################################################### i was wondering if i could use POST instead of GET when the form is submitted is there a preference you guys would choose? thanks guys Graham Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 16, 2007 Share Posted June 16, 2007 looks ok what the problam then. Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 16, 2007 Share Posted June 16, 2007 $action = $_GET['action']; <<< dont need this #################################################################################### if ($action == "search") { to this if ($_GET['action'] == "search") { } Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 16, 2007 Share Posted June 16, 2007 my version <?php if ($_GET['action'] == "search") { ## isset code ###################################################################### if(isset($_POST['submit'])) { echo '<br /><center><h4>Search Results</h4></center>'; include("includes/footer.php"); exit; } else { ?> <br><center><h4>Search Forums</h4></center>'; <table width="300" border="1" cellpadding="0" cellspacing="0" > <form action="<?php $_SERVER['PHP_SELF'];?cmd=search ?>" method="POST" > <th align="center" bgcolor="#004E98" /><font color="#ffffff">Type In Keywords To Search Forum</th> </tr> <tr> <td align="center"><input type="text" name="search_forum" size="40" ></td> </tr> <tr> <td align="right" bgcolor="#004E98" ><input type="submit" name="submit" value="Search Forum" ></td> </table></form><br> <?php include("includes/footer.php"); if($_GET['cmd']=="search"){ //search query } } ?> Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 16, 2007 Share Posted June 16, 2007 know were getting somewere ok. <?php if ($_GET['action'] == "search") { if(isset($_POST['submit'])) { echo "<br><center><h4>Search Results</h4></center>"; ?> <br><center><h4>Search Forums</h4></center> <table width="300" border="1" cellpadding="0" cellspacing="0" > <form action=" <?php $_SERVER['PHP_SELF']?>?cmd=search" method="POST" > <th align="center" bgcolor="#004E98" /><font color="#ffffff">Type In Keywords To Search Forum</th> </tr> <tr> <td align="center"><input type="text" name="search_forum" size="40" ></td> </tr> <tr> <td align="right" bgcolor="#004E98" ><input type="submit" name="submit" value="Search Forum" ></td> </table></form> <br> <?php include("footer.php");?> <?php if($_GET['cmd']=="search"){ //search query } } } ?> Quote Link to comment Share on other sites More sharing options...
graham23s Posted June 16, 2007 Author Share Posted June 16, 2007 hi mate, thanks for that, i implemented the new code works great:) thanks again mate Graham 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.