seeking help in coding - dynamic page

Discussion in 'PHP' started by anurag.sharma, May 16, 2008.

  1. #1
    I am a beginner in php.. For the sake of experiment with that , I would like to create a page that contains a search box where a user can enter the search tearm and that query will be fed to google (of the form "http://www.google.co.in/search?q=") and the resulting page will be displayed below my search box in my page (ie. a dynamic frame in my page that will display the corresponding pages - as such - from Google).

    Can any one help me?

    PS: I don't mind in using seperate html templete files for these
     
    anurag.sharma, May 16, 2008 IP
  2. Altari

    Altari Peon

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'm not sure if this will work (I haven't used iframes in a long time).

    echo("<form method='POST'>");
    echo("<p><input type='text' name='search_var' value='Search terms...' /><input type='submit' name='search' value='Search' /></p>");
    echo("</form>");
    
    if(isset($_POST['search']) && !empty($_POST['search_var'])) {
    $search = $_POST['search_var'];
    echo("<p>You searched for ".$search.". Results below.</p>");
    echo("<iframe src='http://www.google.co.in/search?q=".$search."'>Some text in case the iframe cannot be display.</iframe>");
    } 
    PHP:
     
    Altari, May 16, 2008 IP
  3. anurag.sharma

    anurag.sharma Guest

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    sorry it didn't .. pls help
     
    anurag.sharma, May 18, 2008 IP
  4. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #4
    Umm...that should work, you need a HTML form to go with it:

    
    <form method="post" action="file.php">
        <input type="hidden" name="search"/>
        <input type="text" name="search_var"/>
        <input type="submit" value="Search" />
    </form>
    
    Code (markup):
     
    blueparukia, May 19, 2008 IP