Jump to content

PiggyPiglet

New Members
  • Posts

    2
  • Joined

  • Last visited

PiggyPiglet's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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">
  2. 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 <?php if(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 connection if ($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 set while($row=mysql_fetch_array($result)){ $UUID =$row['UUID']; $player_name=$row['player_name']; $donation_rank=$row['donation_rank']; //-display the result of the array echo "<ul>\n"; echo "<li>" . "<a href=\"search.php?id=$UUID\">" .$UUID . " " . "</a></li>\n" ; echo $donation_rank . " " . "</a>\n"; echo "</ul>"; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.