Home > Net >  how Stop icon search and replace it with the link
how Stop icon search and replace it with the link

Time:01-13

This code is connected to a database. It works on a search system, I just put the name and press search to show the details.

I want to modify this code instead of searching. I want to put the name at the top of the page instead of putting the name in the search box.

For example, I want it to search through the link https://dmoinname/?id=player&name=name

<p><form action="" method="POST">
<p>
    <input type="text" name="term" /> <input type="submit" value="Search player" />
    </p>
    </form>
    <?php
if(isset($_POST['term'])){
$term = mysql_real_escape_string(htmlentities(trim($_POST['term'])));}
    $errors = array();
    if (empty($term)){
    $errors[] = 'Please enter a username And You Should Close Account To Search About Information';
    } else if (strlen($term)<4) {
    $errors[] = 'Username must contain at least 4 characters';
    } else if (1==2) {
    $errors[] = 'User '.$term.' not found in our DataBase';
    }
    if (empty($errors)){
      $term = $_POST['term'];

$sql = mysql_query("select * from cq_user where name='$term'");
 
while ($row = mysql_fetch_array($sql)){
    echo '<br/> <font color=Silver size="2">Name :<font color=#008080 size="2"> '.$row['name'];
    echo '<br/> <font color=Silver size="2">Mate :<font color=#008080 size="2"> '.$row['mate'];
    echo '<br/> <font color=Silver size="2">Reborn :<font color=#008080 size="2"> '.$row['metempsychosis'];
    echo '<br/> <font color=Silver size="2">Level :<font color=#008080 size="2"> '.$row['level'];
    echo '<br/> <font color=Silver size="2">Supose :<font color=#008080 size="2"> '.$row['mate'];
    echo '<br/> <font color=Silver size="2">PK :<font color=#008080 size="2"> '.$row['pk'];
    echo '<br/> <font color=Silver size="2">Cps :<font color=#008080 size="2"> '.$row['emoney'];
    echo '<br/> <font color=Silver size="2">Strength :<font color=#008080 size="2"> '.$row['strength'];
    echo '<br/> <font color=Silver size="2">Vitality :<font color=#008080 size="2"> '.$row['health'];
    echo '<br/> <font color=Silver size="2">Agility :<font color=#008080 size="2"> '.$row['Speed'];
    echo '<br/> <font color=Silver size="2">Spirit :<font color=#008080 size="2"> '.$row['soul'];
    echo '<br/> <font color=Silver size="2">Unspent points :<font color=#008080 size="2"> '.$row['additional_point'];
    echo '<br/><br/>'; }
    } else {
    foreach($errors as $error) {
        echo $error, '</br>';
    }
    }
?>

CodePudding user response:

So basically you just have to use the method GET instead of POST.

<?php
    if(isset($_GET['id'])) { // checks if the word `id` is in the URL
        $player_name = $_REQUEST['name']; // get the value of the `name` from the URL

        // 1. ADD YOUR VALIDATIONS HERE
        // 2. EXECUTE QUERY AND OTHER THINGS HERE
    }
?>
  •  Tags:  
  • php
  • Related