I have a website in which members of a gaming community are highlighted for achievements. When a gamer achieves certain goals, they send me the screenshot and I make a page on my website
(website.com/players/username)
I want to make a database of usernames, and add a search function that will bring up the username when searched. I then want viewers to be able to click the username and be brought to their page.
How do I do this? I have been watching Mysql tutorials but I'm not sure if this is what I need to be doing. Any help would be great. Thanks.
use mysql's select and a form
html
<form method="post">
Username: <input type="text" name="name"><br>
<input type="submit" name="submit">
</form>
mysql query after submit
<?php
if($_POST['submit']){
$con=mysqli_connect("example.com","peter","abc123","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM users WHERE name = '".$_POST['name']."'");
while($row = mysqli_fetch_array($result))
{
echo '<a href="website.com/players/'.$_POST['name'].'"></a>';
echo "<br>";
}
mysqli_close($con);
}
?>