Problem with submit button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ryan2345
    New Member
    • Mar 2008
    • 26

    Problem with submit button

    Hi,
    I have a search page. After the user enters the keyword to be searched and if he presses enter key to search then the page gets refreshed. But if he clicks on the submit button then the result is displayed.What is the problem in the below code. I want the result to be displayed even if user presses enter key.

    [code=php]
    if (!isset($_POST['Submit'])) {
    // form not submitted
    ?>
    <p><strong> Search By Key Skills for:
    <input type="text" name="search" />
    </strong></p>
    <p><a href="advancese arch.php">Advan ce Search</a> </p>
    <p> </p>
    <input type="submit" name="submit" value="Submit"/>
    [/code]
    Plz help me out.
  • DarkStar
    New Member
    • May 2008
    • 2

    #2
    You need to have a form.

    [code=html]
    <form action="myscrip t.php" method="post">
    <input type="text" name"search">
    <input type="submit">
    </form>
    [/code]

    Then to process the form...

    [code=php]<?php
    if (isset($_POST['search']))
    {
    $search = $_POST['search'];
    echo $search;
    }
    [/code]

    Comment

    Working...