Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //if nothing entered in the form, the user is redirected back to the form
- if(empty($_GET['fname'])){
- header ("Location: http://gfkvardar.com/kirkata.php");
- exit;
- }
- ?>
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>Search Results</title>
- <style type="text/css">
- body, h2, tr { text-align: center }
- </style>
- </head>
- <body>
- <?php
- $servername = "localhost";
- $username = "putlocke_gfkuser";
- $password = "kire123";
- $dbname = "putlocke_gfkdb";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- //if the user is here the field is not empty
- $fname = mysqlclean($_GET['fname'], 50, $connection);
- //Constructing the sql query
- $query = "SELECT * FROM student WHERE firstname like '%$fname%'";
- //Runing the query through the connection
- if (!($result = @ mysql_query ($query, $connection)))
- dberror();
- //Displaying the Results
- $rowsFound = @ mysql_num_rows($result);
- if ($rowsFound > 0){
- echo "<h2>Students with first name: $fname</h2>";
- displayResults($result);
- }
- //Nothing matched
- else
- echo "<h2>No students with first name: {$_GET['fname']}</h2>";
- ?>
- <br/><a href="http://gfkvardar.com/kirkata.php"><< Back to Search</a>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement