get id from buttons with same name in php - php

So I have a website that runs a cycle on a database as long as there is a record in it.
It also puts two buttons in each row within the table.
Each button has the same name.
If I press one of the buttons, how can I get the ID of that button (which points to a Youtube link from the database) to be included in a SQL query.
Here is my code:
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="style.css">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ruben MediaShare</title>
</head>
<body>
<form method='POST'>
<?php
session_start();
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true) {
echo "Welcome to the member's area, " . $_SESSION['modname'] . "!";
} else {
echo "Please log in first to see this page.";
}
$link = mysqli_connect("localhost", "asd", "asd", "mediareq");
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$sql = "SELECT * FROM requests";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table>";
echo "<tr>";
echo "<th>link</th>";
echo "<th>Twitch Név</th>";
echo "<th>Üzenet</th>";
echo "<th>Engedélyezés</th>";
echo "<th>Elutasítás</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
$link = $row['link'];
echo "<td>" . "<iframe width='560' height='315' src='$link' frameborder='0' allowfullscreen></iframe>" . "</td>";
echo "<td>" . $row['ttvname'] . "</td>";
echo "<td>" . $row['msg'] . "</td>";
echo "<td>" . "<input type='submit' id='$link' value='' name='enable'></input>" . "</td>";
echo "<td>" . "<input type='submit' id='$link' value='' name='eject'></input>" . "</td>";
echo "</tr>";
}
mysqli_free_result($result);
if (isset($_POST['enable'])) {
$ID = $_POST[$link];
echo $ID;
}
} else{
echo "Még nem kaptál videót, várjál már egy kicsit vagy csak tolj egy F5öt Pog Pog Pog";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
mysqli_close($link);
?>
</form>
</body>
</html>
The website looks like this: https://imgur.com/a/MWVj7L5
If it can't be done that way, what can I do in this case to keep the loop but since it has to be dynamic, and somehow get it to pick the link from each button that it stores in the ID (or some other way)

Related

Does not print everything from sql database

I am trying to build a forum for my school project. Now i want to get the data out of my database so i can print it and people can see and react to it. Now i have the problem that it only print the commenters post and not the creators post. I will ad some picture and the code so you guys can undestand. (PS. i have a form on the previous page where you can search)
Database
Website
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="./style.css">
<title><?php echo $_GET["search"];?></title>
</head>
<body>
<?php
//navbar
include "./include/nav.php";
//database connection
include "./include/conn.php";
$search = $_GET["search"];
if($search == ""){
// if empty return to index
echo "
<script>alert('thread does not exist')</script>
<script>window.location = './index.php'</script>
";
} else {
//check if data exist
$sql = "SELECT thread, post, username, status FROM post WHERE thread = ? ";
$query = $conn->prepare($sql);
$query->execute(array($search));
$data = $query->fetch();
if($data){
// print data if exist
echo "<div class='padding'>";
foreach ($query as $test) {
echo "<tr>";
echo "<td>" . $test["thread"] . "</td>";
echo "<td>" . $test["post"] . "</td>";
echo "<td>" . $test["username"] . "</td>";
echo "<td>" . $test["status"] . "</td>";
echo "</tr>" . "</br>";
}
echo "<button onclick='comment()'>Comment</button>";
echo "</div>";
echo "<div id='test'>";
} else {
// if data does not exist return to index
echo "
<script>alert('thread does not exist')</script>
<script>window.location = './index.php'</script>
";
}
}
?>
<script>
// if comment btn is pressed save thread name and send to comment.php
function comment() {
document.getElementById("test").innerHTML =
"<?php
session_start();
$_SESSION['thread'] = $data['thread'];
?>";
window.location.assign("./comment.php")
}
</script>
</body>
</html>
I never used the data that i got out of the database. I should have printed it like this:
if($data){
// print data if exist
echo "<div class='padding'>";
foreach ($data as $test) {
echo "<tr>";
echo "<td>" . $test["thread"] . "</td>";
echo "<td>" . $test["post"] . "</td>";
echo "<td>" . $test["username"] . "</td>";
echo "<td>" . $test["status"] . "</td>";
echo "</tr>" . "</br>";
}
echo "<button onclick='comment()'>Comment</button>";
echo "</div>";
echo "<div id='test'>";
} else {
// if data does not exist return to index
echo "
<script>alert('thread does not exist')</script>
<script>window.location = './index.php'</script>
";
}
}

Delete / Modify user from Database with a button

When I click the delete button it should delete the user from that row from the Database. I also want help for my modify button in this table if I click the modify button it should change the user type (Admin, Chief, user). I already tried everything but I don't know how a can solve it that's why I'm asking your help.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pannel</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<style type="text/css">
body {
font: 14px sans-serif;
text-align: center;
}
</style>
</head>
<body>
<div class="page-header">
<h1> Admin Pannel</h1>
</div>
<div>
</div>
</body>
</html>
<?php
session_start();
require 'config.php';
$strSQL = "SELECT username, email, type FROM benutzer";
$rs = mysqli_query($link, $strSQL);
echo "<table border='1' style='margin: 0 auto'>
<tr>
<th class='text-center'>Name / Vorname</th>
<th class='text-center'>Email</th>
<th class='text-center'>Type</th>
<th class='text-center'>Modify</th>
<th class='text-center'>Delete</th>
</tr>";
while ($row = mysqli_fetch_array($rs)) {
echo "<tr>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['type'] . "</td>";
echo "<td><input type='submit' value='Modify' class='btn' name='modify'></td>";
echo "<td><input type='submit' value='Delete' class='btn' name='delete'></td>";
echo "</tr>";
}
echo "</table>";
if (isset($_POST['modify'])) {
$username = $row['username'];
$modify_query = mysqli_query($link, "UPDATE benutzer SET type='Mitarbeiter, Chef' WHERE username=$username");
if ($modify_query) {
mysqli_close($link);
header("location:welcome.php");
exit;
} else {
echo mysqli_close($link);
}
}
if (isset($_POST['delete'])) {
$username = $row['username'];
$delete_query = mysqli_query($link, "DELETE FROM benutzer WHERE id=$username");
if ($delete_query) {
mysqli_close($link);
echo "Record deleted successfully";
exit;
} else {
echo mysqli_close($link);
}
}
?>
Try this you were missing hidden input types so the php can't see your code you submitted.
Since you are showing alot of username's you will need to create a bunch of input hidden types with name=username1, name=username2 etc.. or it won't work well I can show you a easier way to do it (look below this code)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pannel</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<style type="text/css">
body {
font: 14px sans-serif;
text-align: center;
}
</style>
</head>
<body>
<div class="page-header">
<h1> Admin Pannel</h1>
</div>
<div>
</div>
</body>
</html>
<?php
session_start();
require('config.php');
$strSQL = "SELECT username, email, type FROM benutzer";
$rs = mysqli_query($link, $strSQL);
echo "<table border='1' style='margin: 0 auto'>
<tr>
<th class='text-center'>Name / Vorname</th>
<th class='text-center'>Email</th>
<th class='text-center'>Type</th>
<th class='text-center'>Modify</th>
<th class='text-center'>Delete</th>
</tr>";
while ($row = mysqli_fetch_array($rs)) {
echo "<tr>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['type'] . "</td>";
echo "<form action='pannel.php' method='post'>";
echo "<input type='hidden' id=username' name='username' value='".$row['username']."'>";
echo "<input type='hidden' id=email' name='email' value='".$row['email']."'>";
echo "<input type='hidden' id=type' name='type' value='".$row['type']."'>";
echo "<td><input type='submit' value='Modify' class='btn' name='modify'></td>";
echo "<td><input type='submit' value='Delete' class='btn' name='delete'></td>";
echo "</form>";
echo "</tr>";
}
echo "</table>";
if (isset($_POST['modify'])) {
$username = $_POST['username'];
$modify_query = mysqli_query($link, "UPDATE benutzer SET type='Mitarbeiter, Chef' WHERE username=$username");
if ($modify_query) {
mysqli_close($link);
header("location:welcome.php");
exit;
} else {
echo mysqli_close($link);
}
} else if (isset($_POST['delete'])) {
$username = $_POST['username'];
$delete_query = mysqli_query($link, "DELETE FROM benutzer WHERE username=$username");
if ($delete_query) {
mysqli_close($link);
echo "Record deleted successfully";
exit;
} else {
echo mysqli_close($link);
}
}
EDIT:
Easier way to do it
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pannel</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<style type="text/css">
body {
font: 14px sans-serif;
text-align: center;
}
</style>
</head>
<body>
<div class="page-header">
<h1> Admin Pannel</h1>
</div>
<div>
</div>
</body>
</html>
<?php
session_start();
require('config.php');
$strSQL = "SELECT username, email, type FROM benutzer";
$rs = mysqli_query($link, $strSQL);
echo "<table border='1' style='margin: 0 auto'>
<tr>
<th class='text-center'>Name / Vorname</th>
<th class='text-center'>Email</th>
<th class='text-center'>Type</th>
<th class='text-center'>Modify</th>
<th class='text-center'>Delete</th>
</tr>";
while ($row = mysqli_fetch_array($rs)) {
echo "<tr>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['type'] . "</td>";
echo "<td><a href='pannel.php?delete=".$row['username']."'>Delete ".$row['username']."</a></td>";
echo "<td><a href='pannel.php?modify=".$row['username']."'>Modify ".$row['username']."</a></td>";
echo "</tr>";
}
echo "</table>";
if (isset($_GET['modify'])) {
$username = $_GET['modify'];
$modify_query = mysqli_query($link, "UPDATE benutzer SET type='Mitarbeiter, Chef' WHERE username=$username");
if ($modify_query) {
mysqli_close($link);
header("location:welcome.php");
exit;
} else {
echo mysqli_close($link);
}
} else if (isset($_GET['delete'])) {
$username = $_GET['delete'];
$delete_query = mysqli_query($link, "DELETE FROM benutzer WHERE username=$username");
if ($delete_query) {
mysqli_close($link);
echo "Record deleted successfully";
exit;
} else {
echo mysqli_close($link);
}
}

use SQL data selected from html dropdown list

NEWBIE ALERT
Ive been reading for hours but cannot see how to do what I want. I have an SQL DB with a list of medication and dosages etc. Im trying to create an 'edit' page so i can select the medication from a dropdown list(this appears to work), and edit certain parts of it(size, box quantity, doseage etc.
the problem is i cant get the selected medication item(from dropdown) to become a variable or if neccessary, forward to a 2nd PHP page.
Ive left a couple of attempted edits in there but they caused errors (TRIED NOT WORK)
As it is, It is loading editmed.php to load my edit page on submit. (not sure if this is the best way of doing it).
Any help would be great thanks
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Editor</title>
<link rel="stylesheet" href="global.css">
</head>
<body>
<div class="header">
<h1>Edit Medication Item</h1>
</div>
<div class="topnav">
Home
<a class="active" href="edit.php">Edit Medication</a>
Prescription Collection
Add New Medication
Pillbox refill
Individual refill
</div>
<?php
// server connect
$mysqli = new mysqli("localhost:port", "USERNAME", "PASSWORD", "prescription")
or die ('Cannot connect to db');
// select medication name field from db
echo "<p><b><U><i><p style='color:red'>Select Medication</I></U></p><p style='color:black'></b></p>";
$sqlSelect="select Medication from general";
$result = $mysqli -> query ($sqlSelect);
//$medselect=$result['Medication'];**TRIED NOT WORK**
echo "<form action='editmed.php'>";
echo "<select id=`Medication` name=`medselect`>";
while ($row = mysqli_fetch_array($result)) {
echo "<option value='" . $row['Medication'] . "'>" . $row['Medication'] . "</option>";
}
//$medselect=$result['Medication'];**TRIED NOT WORK**
echo "</select>";
echo "<input type='submit' value='submit'>";
// echo "<input type='submit' value='<$medselect>' name='medselect'/>" ; **TRIED NOT WORK**
echo "</form>" ;
echo "</body>";
echo "</html>";
?>
</body>
</html>
editmed.php >
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Editor</title>
<link rel="stylesheet" href="global.css">
</head>
<body>
<div class="header">
<h1>Edit Medication Item</h1>
</div>
<div class="topnav">
Home
<a class="active" href="edit.php">Edit Medication</a>
Prescription Collection
Add New Medication
Pillbox refill
Individual refill
</div>
<?php
// server connect
$link = mysqli_connect("localhost:port", "user", "password",
"prescription")
or die ('Cannot connect to db');
// $sql = "SELECT ID, Medication, dosagedaily, Box_Size, Boxed_remain,
grandtotal, last_collected, Dosage, countdown FROM general where
`Medication` = $medselect";
$sql = "SELECT ID, Medication, dosagedaily, Box_Size, Boxed_remain,
grandtotal, last_collected, Dosage, countdown FROM general where
`Medication` = 'Esomeprazole 40mg'";
// you check sql and link true
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table>";
echo "<tr>";
echo "<th>Index</th>";
echo "<th>Medication</th>";
echo "<th>Daily Dosage</th>";
echo "<th>Box Size</th>" ;
echo "<th>Boxed Remaining</th>" ;
echo "<th>Grand Total</th>";
echo "<th>Last presc collection</th>";
echo "<th>Dosage</th>";
echo "<th>Pills Remaining</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['ID'] . "</td>";
echo "<td>" . $row['Medication'] . "</td>";
echo "<td>" . $row['dosagedaily'] . "</td>";
echo "<td>" . $row['Box_Size'] . "</td>";
echo "<td>" . $row['Boxed_remain'] . "</td>";
echo "<td>" . $row['grandtotal'] . "</td>";
echo "<td>" . $row['last_collected'] . "</td>";
echo "<td>" . $row['Dosage'] . "</td>";
echo "<td>" . $row['countdown'] . "</td>";
echo "</tr>";
}
echo "</table>";
// Free result set
mysqli_free_result($result);
} else{
echo "No records matching your query were found.";
}
}
else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);
i dont know how to assign the variables from the input form, thats where my issue is.If i get a variable assigned then i can create the actual editing part.

Cannot access or assign login username variable - mysql - php

I cannot find a way to access the username I used to log in with on my php web form.
I have had a look at these posts but I think my case varies slightly as they both declare the username variable at the top. I simply log in using a sql query.
Here is the login script
<?php
$uname=$_POST['uname'];
$password=$_POST['password'];
session_start();
$con=mysqli_connect("localhost","root","g7trj98o6fyr5","login");//mysqli("localhost","username of database","password of database","database name")
$result=mysqli_query($con,"SELECT * FROM `login_info` WHERE `uname`='$uname' && `password`='$password'");
$count=mysqli_num_rows($result);
if($count==1)
{
echo "Login success";
$_SESSION['log']=1;
header("refresh:2;url=welcome.php");
}
else
{
echo "please fill proper details";
header("refresh:2;url=index.php");
}
?>
I'm expecting to be able to do a if check using the currently logged in user to differentiate them from all other users online.
I have this if check which should only put the edit button next to the user who is logged in.
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['uname'] . "</td>";
echo "<td>" . $row['clickrate'] . "</td>";
if($logedInUsername == $row['uname'])
echo "<td>" . $row['yourword'] . "<a href='edityourword.php?edit=$row[yourword]'> edit</a></td>";
else
echo "<td>" . $row['yourword'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
welcome.php (where the if statement is)
<?php
function add_ant(&$connection)
{
mysqli_query($connection, "UPDATE `login_info` SET `clickrate`=`clickrate`+'1' WHERE `uname`='rvbvakama' && `password`='pass'");
}
session_start();
if(isset($_SESSION['log']))
{
$_SESSION['uname'] = $_POST['uname'];
echo "<script type='text/javascript'>alert('$logedInUsername');</script>";
$con=mysqli_connect("localhost","root","pass","login"); //mysqli("localhost","username of database","password of database","database name")
if(array_key_exists('add',$_POST))
{
add_ant($con);
}
$result = mysqli_query($con,"SELECT * FROM login_info");
if (!$result)
{
printf("Error: %s\n", mysqli_error($con));
exit();
}
echo "<table border='1'>
<tr>
<th>username</th>
<th>clickrate</th>
<th>yourword</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['uname'] . "</td>";
echo "<td>" . $row['clickrate'] . "</td>";
if($logedInUsername == $_SESSION['uname'])
echo "<td>" . $row['yourword'] . "<a href='edityourword.php?edit=$row[yourword]'> edit</a></td>";
else
echo "<td>" . $row['yourword'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>Add ants</h1>
<button type='button' name="add">ADD</button> <br/> <br/>
<a href="index.php" >logout</a>
</body>
</html>
<?php
}
else
{
echo "please fill proper details";
header("refresh:2;url=index.php");
}
?>
Thanks.
Not safe, but put:
<?php
$uname=$_POST['uname'];
$password=$_POST['password'];
session_start();
$con=mysqli_connect("localhost","root","g7trj98o6fyr5","login");//mysqli("localhost","username of database","password of database","database name")
$result=mysqli_query($con,"SELECT * FROM `login_info` WHERE `uname`='$uname' && `password`='$password'");
$count=mysqli_num_rows($result);
if($count==1)
{
echo "Login success";
$_SESSION['log']=1;
$_SESSION['uname'] = $_POST['uname'];
header("refresh:2;url=welcome.php");
}
else
{
echo "please fill proper details";
header("refresh:2;url=index.php");
}
?>
and then check:
if($logedInUsername == $_SESSION['uname'])
...
also you need to set $logedInUsername to $row['uname'] in welcome.php
or check
if($row['uname'] == $_SESSION['uname'])
in login.php after login success execute this
$_SESSION['uname'] = $_POST['uname'];
in welcome.php execute this
$logedInUsername = $_SESSION['uname'];
Now the currently logged in username is stored in $logedInUsername for use in welcome.php, this is because SESSION is a global var in php and can be accessed from anywhere.
The while loop and if statement in it should now look like this:
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['uname'] . "</td>";
echo "<td>" . $row['clickrate'] . "</td>";
if($row['uname'] == $logedInUsername)
echo "<td>" . $row['yourword'] . "<a href='edityourword.php?edit=$row[yourword]'> edit</a></td>";
else
echo "<td>" . $row['yourword'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>

php script for searching a string which contains a space in the string

I have a problem in searching a string which consist of space(manish pandey). php script used to search for only (manish) instead of full name (manish pandey).
I am using here get functions:
image, image2
<!doctype html>
<html lang="en-US">
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset="UTF-8">
</head>
<body>
<?php
/*
Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password)
*/
$link = mysqli_connect("localhost", "root", "root123", "sample");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Attempt select query execution
$sql = "SELECT * FROM qcdataa1 Where project_id='".$_GET['pid']."'";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table>";
echo "<tr>";
echo "<th>sno</th>";
echo "<th>project_id</th>";
echo "<th>project_name</th>";
echo "<th>application</th>";
echo "<th>investigator</th>";
echo "<th>created_by</th>";
echo "<th>creation_date</th>";
echo "<th>last_modified</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" .$row['sno']. "</td>";
echo "<td>" .$row['project_id'] . "</td>";
echo "<td>" .$row['project_name']. "</td>";
echo "<td>" .$row['application']. "</td>";
echo "<td>" .$row['investigator']."</td>";
echo "<td>" .$row['created_by']. "</td>";
echo "<td>" .$row['creation_date']. "</td>";
echo "<td>" .$row['last_modified']. "</td>";
echo "</tr>";
}
echo "</table>";
// Close result set
mysqli_free_result($result);
} else{
echo "No records matching your query were found.";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);
?>
</body>
</html>
<!doctype html>
<html lang="en-US">
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset="UTF-8">
</head>
<body>
<?php
/*
Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password)
*/
$link = mysqli_connect("localhost", "root", "root123", "sample");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Attempt select query execution
echo $_GET['iid'];
$sql = "SELECT * FROM qcdataa2 Where first_name='".$_GET['iid']."'";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table>";
echo "<tr>";
echo "<th>sno</th>";
echo "<th>first_name</th>";
echo "<th>last_name</th>";
echo "<th>userid</th>";
echo "<th>password</th>";
echo "<th>emailid</th>";
echo "<th>creation_date</th>";
echo "<th>last_modified</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" .$row['sno']. "</td>";
echo "<td>" .$row['first_name'] . "</td>";
echo "<td>" .$row['last_name']. "</td>";
echo "<td>" .$row['userid']. "</td>";
echo "<td>" .$row['password']. "</td>";
echo "<td>" .$row['emailid']. "</td>";
echo "<td>" .$row['creation_date']. "</td>";
echo "<td>" .$row['last_modified']. "</td>";
echo "</tr>";
}
echo "</table>";
// Close result set
mysqli_free_result($result);
} else{
echo "No records matching your query were found.";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);
?>
</body>
</html>
Try sending data with urlencode() and decode it with urldecode()
First make your search term safe and then use it in query using LIKE instead of =.
$safe = mysqli_real_escape_string($link, $_GET['iid']);
$safe = trim($safe);
Then query could be,
$sql = "SELECT * FROM qcdataa2 Where first_name LIKE '$safe%' ";

Categories