I am having trouble with pdo and php because I am a php noob and dont know much. I am trying to connect to a database(which I did)then search the query (or something) for a matching string. Basically so a user cant make a account with the same username. This is the connection code.
$conn = new PDO("mysql:host=localhost;dbname=users;","root","");
and here is the confirmation code that is not working :(
$sql = 'SELECT username FROM users ORDER BY username';
foreach ($con->query($sql) as $row) {
if($username1 !== $row['username']) {
$acceptCounter++;
$username = $_GET['username'];
}
}
please help me :)