[CLOSED] How to check if user already exists
Posted: Thu Jan 29, 2015 11:28 am
Hello, I have this code that I will include below and I am not sure on how to create an if statement for it to check whether $steamprofile['steamid'] is already in the table called steam_users and a row called steamid and if it is, for it to return an echo saying "Already registered" and if not for it to insert the $steamprofile['steamid'] into a new row for steamid.
I have already looked for this on other threads, but everything that I have tried either gave me an error, or just kept inserting the steamid into the database each time I refreshed my page.
I would appreciate some help.
Thanks!
I have already looked for this on other threads, but everything that I have tried either gave me an error, or just kept inserting the steamid into the database each time I refreshed my page.
I would appreciate some help.
Thanks!
Code: Select all
$servername = "localhost";
$username = "root";
$password = "";
include (ROOT_PATH . 'steamauth/userInfo.php');
try {
$conn = new PDO("mysql:host=$servername;dbname=database", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
$conn = null;