php - Using a variable to direct traffic -
i sure error variable not being gotten table. can not see error asking data @ same time asking username , password. table consists of [username],[password],[company]. goal have user directed based on name in company after username , password have been verified. keep getting echo @ end.
here code
function registeruser($usename, $password, $company) { // hash pwd $hpwd = hash('sha256',$password); $q ='insert users values(username, password, company) values(?,?,?)'; $stmt = pdo::prepare($q); $stmt->exectue(array( $username, $hpwd, $company)); } // validate user , return company if successfull function validateuser($username, $password, &$company) { $hpwd = hash('sha256',$password); $q ='select company users username=? , password=?'; $stmt = pdo::prepare($q); $stmt->exectue(array( $username, $hpwd)); if( ($company = $stmt->fetch(pdo::fetch_column)) === false ) { $company = header( 'location: login.php' ); } elseif($company == "monkeynones"){ header( 'location: admin1.php' ); }
your query wrong:
$sql = "select 'password' , 'company' users 'username' = '$username';";
should
$sql = "select `password`, `company` `users` `username` = '$username'";
use backticks, not quotes, around identifiers. and
replaced comma, , trailing semicolon in query isn't required.
Comments
Post a Comment