Support

Need help with a tutorial? You may post in the tutorial topic itself so if other people are having the same problem they can find it quickly and easily!
All tutorials are copyright © by Faintmedia.com. You may not copy these tutorials.
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Make your own PHP text box link to Google Rate Topic: -----

#1 User is offline   Riley Wiebe 

  • Faintmedia CTO
  • Icon
  • View blog
  • Group: Admin
  • Posts: 209
  • Joined: 06-May 08
  • Gender:Male
  • Location:Canada
  • Creator of Faintmedia Raive Studios/Decade Creations Member Northern Storms Admin Creator of Led Salad Coffee Addict Most Posts Purchased 1 - 3 products Reported a bug

Posted 18 November 2008 - 06:56 PM

This is just a simple tutorial that shows you a few techniques.

In this tutorial I will show you how to create a text box so that when you click search it will search Google.

Start off by creating a form in your php file.

    echo '<form name="form1" method="post" action="page_name.php">
     <input type="text" name="search">
     <input type="submit" name="Submit" value="Search">
     </form>';
 }
 ?>


Make sure you replace "page_name.php" with the name of your file.

Now you are done the search form.



Now add this script ABOVE the one you just put, this is were it will connect what you have typed to Google.

<?php
$post = (isset($_POST['Submit'])) ? true : false;
if($post)
{
    $searchtext = $_POST['search'];
    echo '<meta http-equiv="Refresh" content="1; URL=http://www.google.ca/search?hl=en&amp;q=' . $searchtext . '&amp;btnG=Google+Search&amp;meta="><b>CONNECTING TO GOOGLE...</b>'; 
}
else
{


Now lets learn a little about this part of the script.

The variable $post basically checks to see if the form has been submitted. This occurs when the user presses the button.

The part that has been echoed is a meta refresh that sends the user to Google's search results page. content="1; means that there is going to be a 1 second delay before the user is sent. URL=... tells the path that the user will be redirected to. As you can see it is Google's results page and in the link it has q=' . $searchtext . ' this is passing what the user has search over to Google.

The $_POST['search'] is getting the content that was entered into the textbox which is named search.

Here is the final code.

<?php
 $post = (isset($_POST['Submit'])) ? true : false;
 if($post)
 {
     $searchtext = $_POST['search'];
     echo '<meta http-equiv="Refresh" content="1; URL=http://www.google.ca/search?hl=en&amp;q=' . $searchtext . '&amp;btnG=Google+Search&amp;meta="><b>CONNECTING TO GOOGLE...</b>'; 
 }
 else
 {
    echo '<form name="form1" method="post" action="page_name.php">
     <input type="text" name="search">
     <input type="submit" name="Submit" value="Search">
     </form>';
 }
 ?>


Like This Tutorial? Join the Community Today!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users