PiggyPiglet
-
Posts
2 -
Joined
-
Last visited
Posts posted by PiggyPiglet
-
-
Hi, Currently i'm in the process of making a minecraft shop. I have a custom made plugin for the server that sends info to MySQL. It sends the UUID, player name and donation rank. When the donation rank is changed, the ingame rank is changed. Basically I wan't players to type their names in and then php searches for the name. If the name is there, they get accepted through to the store page. When a user buys a rank or perk, the website sends a query changing the donation rank number. I'm struggling with the search part atm. Heres my code.
<!DOCTYPE html> <form method="post" action="testy.php"searchform"> <input type="text" name="name"> <input type="submit" name="submit" value="Search"> </form
<?phpif(preg_match("/^[ a-zA-Z]+/", $_REQUEST['name'])){$name=$_REQUEST['name'];$servername = "removed";$username = "removed";$password = "removed";$dbname = "removed";// Create connection$conn = new mysqli($servername, $username, $password, $dbname);// Check connectionif ($conn->connect_error) {die("Connection failed: " . $conn->connect_error);}//-query the database table$sql="SELECT UUID, player_name, donation_rank FROM store_data WHERE player_name LIKE '%" . $player_name . "%' ";//-run the query against the mysql query function$result = $conn->query($sql);//-create while loop and loop through result setwhile($row=mysql_fetch_array($result)){$UUID =$row['UUID'];$player_name=$row['player_name'];$donation_rank=$row['donation_rank'];//-display the result of the arrayecho "<ul>\n";echo "<li>" . "<a href=\"search.php?id=$UUID\">" .$UUID . " " . "</a></li>\n" ;echo $donation_rank . " " . "</a>\n";echo "</ul>";}?>
Search function not working
in PHP Coding Help
Posted
I'm not sure. I just got this code from a website. Sorry i'm very new to php.
Cant find the website.. Really sorry. I think the $_REQUEST['name'] is in the html file tho. <input type="text" name="name">