php - send variable to next page by link -


i need help.

how can call variable(within url) after successful search result in index.php next page view.php can view complete data of variable?

heres code

"index.php"

<form method="post" action="index.php?go" id="searchform"> <input type="text" name="name" size = "50"> <br/> <input type="submit" name="submit" value="search"> <button type="reset" value="reset">reset</button> </form>   <?php      $db=mysql_connect ("localhost", "root", "") or die ('i cannot connect database because: ' . mysql_error());      $mydb=mysql_select_db("emp_dba");      if(isset($_post['submit'])){     if(isset($_get['go'])){     if(preg_match("/[a-z | a-z]+/", $_post['name'])){     $name=$_post['name'];     $letter=$_get['by'];      $sql="select emp_id, fname, lname,mname emp_tbl fname '%" . $name . "%' or lname '%" . $name ."%' or mname '%" .$name . "%'";     $result=mysql_query($sql);       $numrows=mysql_num_rows($result);      echo "<p>" .$numrows . " results found " . stripslashes($name) . "</p>";       while($row=mysql_fetch_array($result)){      $fname =$row['fname'];     $mname =$row['mname'];     $lname=$row['lname'];     $id=$row['emp_id'];          echo "<ul>\n";          echo "<li>" . "<a href=\"view.php?id=$fname\">"  .$fname . " " . $mname. " " . $lname . "</a></li>\n";         echo  "</ul>";                                             }                                                     }         else{         echo "<p>please enter search query</p>";             }                               }     } 

?>

you url parameters $_get environment variable, while field did put inside form (given chose post form method) read $_post["name"].

as little piece of advice, try resort method few times possible. parameters received method seen in url, while parameters received post method aren't.

and, of course, sanitize get/post data before using it.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -