SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast drownedbeaver's Avatar
    Join Date
    Aug 2011
    Location
    Philippines
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Search module using post + posting url variable

    This is a pre-historic code of search.

    Code:
    <?php 
    include("connection.php"); // YOUR CONNECTION DETAILS
    	if(isset($_POST['btnSubmit']))
    	{
    		$x = $_REQUEST['searchtxt'];	
    		$r= "SELECT * FROM `incan` WHERE `TITLE` LIKE '%$x%' OR `DESCRIPTION` LIKE '%$x%' UNION SELECT * FROM `incan2` WHERE `TITLE` LIKE '%$x%' OR `DESCRIPTION` LIKE '%$x%' ";
    		$d= mysql_query($r);
    	}
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <form action="main_search.php" method="post">
    	<input type="text" name="searchtxt" /><input type="submit" name="btnSubmit" value="SEARCH" />
        <?php if(isset($d))
    	{ ?>
        <table>
    	<?php
    	
    		
        	while($arr_Results = mysql_fetch_array($d))
    		{
    	?>
    	<tr>
        	<td><?php echo html_entity_decode($arr_Results['TITLE'])	; ?></td>
          	<td><?php echo html_entity_decode($arr_Results['DESCRIPTION']); ?></td>
        </tr>
        <?php
    	}
    	}
    	 ?>
    </table>
    </form>
    
    </body>
    </html>
    How can I improve this old code here?
    How can I put a variable in the url using post? www.yoursite.com?q=querystring+from+textbox.

    I am also preparing that the www.yoursite.com?q=querystring+from+textbox. will turn into
    http://www.yoursite.com/search/query...g-from-textbox

    Hope you can enlighten me on this.

    I am testing locally.
    I am running PHP 5 on my machine.

    Thank you very much!

  2. #2
    SitePoint Evangelist speda1's Avatar
    Join Date
    Jan 2002
    Posts
    550
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <form action="main_search.php" method="get">

  3. #3
    SitePoint Enthusiast drownedbeaver's Avatar
    Join Date
    Aug 2011
    Location
    Philippines
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    we really can't do it in method="post"?

    Thanks for the reply

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    POST is a different method then GET. Its all defined in the HTTP protocol.
    GET sends the data though the URL.
    POST sends the data though the body.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Enthusiast drownedbeaver's Avatar
    Join Date
    Aug 2011
    Location
    Philippines
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK I used GET as method.... I get this

    index.php?searchtxt=manager&btnSubmit=SEARCH

    Can I transform this to SEO FRIENDLY URLS?
    Thanks Guys

  6. #6
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Its already SEO friendly.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  7. #7
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SEO friendly?? but hes still use table..

  8. #8
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pociwasiats View Post
    SEO friendly?? but hes still use table..
    A table is for tubular data, which is being returned. The use of the table is valid. Furthermore, the use of a table does not make it "SEO unfriendly" which I'm guessing you are trying to claim.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  9. #9
    SitePoint Enthusiast drownedbeaver's Avatar
    Join Date
    Aug 2011
    Location
    Philippines
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    Its already SEO friendly.
    Really? I thought its the url with /slashes/category/12343

  10. #10
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by drownedbeaver View Post
    Really? I thought its the url with /slashes/category/12343
    Search Engines are not stupid, they know how to work with URLs that have query strings. In any case, you won't be able to get such a result from a form without extensive JavaScript intervention.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •