Eggzorcist Posted July 3, 2009 Share Posted July 3, 2009 I've been trying to create an application which has hardly any php within the design files and a large core function files. I'm trying to create a login however it seems like it isn't working... I think my problem is in the design php file, though I will also attach my function that I've created. login_user function function login_user($username, $password){ $username1 = secure_var($username); $password1 = md5(secure_var($password)); if ($username != NULL and $password != NULL){ $login_query = mysql_query("SELECT * FROM user_info WHERE username = {$username1} AND password = {$password1}"); $login_status = mysql_num_rows($login_query); if($login_status == 1){ echo "good"; set_login_sessions($username, $password); } } else { echo "Please enter a Username and Password"; } That includes a config.php file also... design file <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>One Project Organizer </title> <link rel="stylesheet" type="text/css" href="onestylesheet.css"/> </head> <? require('functions.php'); ?> <body> <div id="onewrap"> <div id="oneheader"> <div class="oneheadertext">One Project Organizer</div> </div> <div id="onesubheader">Log-in</div> <div class="oneerror"></div> <div class="onecontent"><form id="form1" name="form1" method="post" action=""> <label>Username: <input type="text" name="username" id="username" /> </label> Password: <label> <input type="password" name="password" id="password" /> </label> <input type='button' onclick="<?php login_user($_POST['username'], $_POST['password']); ?>" value="Login"/> </form> </div> </div> </body> </html> Thanks for any help! Quote Link to comment Share on other sites More sharing options...
fooDigi Posted July 3, 2009 Share Posted July 3, 2009 first thing that i noticed... $login_query = mysql_query("SELECT * FROM user_info WHERE username = {$username1} AND password = {$password1}"); replace the curly brackets with quotes, cause they are chars, varchars, or strings of some sort $login_query = mysql_query("SELECT * FROM user_info WHERE username = '$username1' AND password = '$password1'"); Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted July 3, 2009 Author Share Posted July 3, 2009 I still don't get any response. I believe I'm using the onclick in a bad manner is it possible? Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted July 3, 2009 Author Share Posted July 3, 2009 The method I used to use was the isset($_POST['submit']), I know this is a possibility but it gets more messy with php in the design files, is there very clean way of doing it, because obviously the way I did it above isn't working. Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted July 3, 2009 Author Share Posted July 3, 2009 I added a checkpoint echo to see if the function was actually being used, and it seems like the function being called isn't making the function work. Am I doing something wrong? also changed a few things. But doesnt seem to make the function work or even being used either... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>One Project Organizer </title> <link rel="stylesheet" type="text/css" href="onestylesheet.css"/> </head> <?php include('functions.php'); ?> <?php if(isset($_POST['login'])){ login_user($_POST['username'], $_POST['password']);}?> <body> <div id="onewrap"> <div id="oneheader"> <div class="oneheadertext">One Project Organizer</div> </div> <div id="onesubheader">Log-in</div> <div class="oneerror"><?php echo $errormessage; ?></div> <div class="onecontent"><form id="form1" name="form1" method="post" action=""> <label>Username: <input type="text" name="username" id="username" /> </label> Password: <label> <input type="password" name="password" id="password" /> </label> <input name="Login" type='button' id="login" value="Login"/> </form> </div> </div> </body> </html> thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.