Just my two cents =)
I dislike HTML stuffed in with PHP :P
<form action="blah" method="post">
<label for="search">Search:</label>
<input type="text" name="search" id="search" />
</p>
<input type="submit" value="Search" />
</form>
<?php
/*
PHP STUFF
*/
if(isset($_POST['search'])) {
$mysql = new mysqli('host', 'username', 'pass', 'db') or trigger_error('Error: '.mysqli_connect_error(), E_USER_ERROR);
$stmt = $mysql->prepare("SELECT `username` FROM `users` WHERE (`username` LIKE '%?%')");
$stmt->bind_param('s', strip_tags($_POST['search']));
$stmt->execute();
if($mysql->num_rows()) {
$stmt->bind_result($username);
while ($stmt->fetch()) {
echo 'Username: '.$username; //I hate using markup within PHP tags (reason there's no
</p> here).
}
} else {
//Error no results
}
$stmt->close();
$mysql->close();
}
I doubt the above is very functional (or practical) but I hope it gives you an idea :thumbup: