wesleypipes Posted October 30, 2006 Share Posted October 30, 2006 Basically this is what i would like to do i will also post the code ive made. With a php program i would like to connect to my database, collect data from a form and save it into variables and create a query to search the user table to see if the user can basically login or not. I have create my Form, php program and database. Below is the copy of my php code:<?mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("memberdir") or die(mysql_error());?><? $appusername=$_POST['login_name']; $apppassword=$_POST['password'];$result = mysql_query(" SELECT * FROM 'user' WHERE username = $appusername AND password = $apppassword ")if (mysql_num_rows($result) > 0) {$_SESSION["authenticatedUser"] = $appusername; header("Location: loggedon.php"); }else{ $_SESSION["message"] = "Could not connect as $appusername "; header("Location: login.php");}?>i really wish you can help. BAsically when i submit my 'login' form i get a parse error at line 12 Link to comment https://forums.phpfreaks.com/topic/25586-help-with-creating-simple-php-login-session/ Share on other sites More sharing options...
ruano84 Posted October 30, 2006 Share Posted October 30, 2006 Hi, you did forget a ";"$result = mysql_query(" SELECT * FROM 'user' WHERE username = $appusername AND password = $apppassword ");if (mysql_num_rows($result) > 0) {$_SESSION["authenticatedUser"] = $appusername; Link to comment https://forums.phpfreaks.com/topic/25586-help-with-creating-simple-php-login-session/#findComment-116765 Share on other sites More sharing options...
HuggieBear Posted October 30, 2006 Share Posted October 30, 2006 That's not the problem, the code should look like this:[code]<?phpmysql_connect("localhost", "root", "") or die(mysql_error());mysql_select_db("memberdir") or die(mysql_error());$appusername = $_POST['login_name'];$apppassword = $_POST['password'];$result = mysql_query("SELECT * FROM `user` WHERE username = '$appusername' AND password = '$apppassword'");if (mysql_num_rows($result) > 0) { $_SESSION['authenticatedUser'] = $appusername; header("Location: loggedon.php");}else { $_SESSION['message'] = "Could not connect as $appusername"; header("Location: login.php");}?>[/code]RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/25586-help-with-creating-simple-php-login-session/#findComment-116771 Share on other sites More sharing options...
wesleypipes Posted October 30, 2006 Author Share Posted October 30, 2006 Thankyou very much huggiebear. This has solved the my problem. Was it my php opening tags that confused the program. CHEERS. Ive only been doing this for 2 weeks and im not that good at it, but as i said THANKYOU VERY MUCH ! Link to comment https://forums.phpfreaks.com/topic/25586-help-with-creating-simple-php-login-session/#findComment-116776 Share on other sites More sharing options...
HuggieBear Posted October 30, 2006 Share Posted October 30, 2006 If you're putting quotes around table names they should really be backticks ( ` ) not single quotes ( ' ) and your values should be enclosed in single quotes.RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/25586-help-with-creating-simple-php-login-session/#findComment-116779 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.