But I'm trying to create an SQL query so I can pull from two tables at once from the database for my site. I'm trying to eventually pull a logged in USER's avatar and some other user info based on a query.
Here is my posted code. Understand this is just testing code not live and full of security issues, I'm just trying to understand how to make a valid SQL statement pulling from multiple tables.
<? if ((!$_POST[username]) || (!$_POST[password])) { header ( "Location: show_login.php"); exit; $db_name = "*****"; $table_user = "*****"; $table_pw = "*****"; $connection = @mysql_connect("localhost", "*****", "*****") or die(mysql_error()); $db = @mysql_select_db($db_name, $connection) $sql = "SELECT * FROM $table_user WHERE username = '$_POST[username]' AND FROM $table_pw WHERE password = password('$_POST[password]')" or die(mysql_error()); $result = @mysql_query($sql,$connection) or die(mysql_error()); $num = mysql_num_rows($result); if ($num !=0) {$msg = "<p>Authorized</p>";} else {header("location: show_login.html}; exit; ?>
$sql = "SELECT * FROM $table_user WHERE username = '$_POST[username]' AND FROM $table_pw password = password('$_POST[password]')"
or die(mysql_error());
I of course hidden sensitve info with "*" I was hoping someone can guide me correctly. Bold text shows the invalid code... This is an action script from the submit of a logg-in text field with password.