Jarod Posted November 2, 2009 Share Posted November 2, 2009 Lol, I'm trying to make a login on my home page to work for me, it's not doing it though, any reason why? <?php require_once($_SERVER['DOCUMENT_ROOT']."/includes/connectDB.php"); ?> <!-- start sidebar --> <div id="sidebar"> <ul> <li id="login"> <?php if(isset($_POST['submit']) { // lul $username = $_POST['user']; $password = $_POST['pass']; $sql = mysql("SELECT * FROM `members` WHERE `user_name`='".$username."' AND `user_pass`='".$password."'") or die(mysql_error()); $count = mysql_fetch_row($sql); if($count != 0) { while($row = mysql_fetch_assoc($sql)) { $member_username = $row['user_name']; $member_password = $row['user_pass']; } if($username == $member_username && $password == $member_password) { ?> <h2>Hello there <b><?php echo $member_username ?></b>!</h2> I've not seen you for some time now, how about getting engaged in discussions on the forums before you leave again? // check to seee if pass and user match. <?php } else { ?> <h2><b class="text1">Login</b></h2> <div style="color: #900; font-weight: bold; text-align: left;">Username or password was entered incorrect! Try again...</div> <form method="post" action="<?php $_SERVER['PHP_SELF'] ?>"> <fieldset> <div class="supscript">This don't even work lul.</div> <input type="text" class="sideBarInput_Login" id="userinp" name="user" value="Username" onclick="setInputFieldNewValue('','userinp');" /><br /> <input type="password" class="sideBarInput_Login" id="passinp" name="pass" value="Password" onclick="setInputFieldNewValue('', 'passinp');" /> <input type="submit" name="submit" class="sideBarInputBUTTON" value="Search" /> </fieldset> </form> <?php } } else { ?> <h2><b class="text1">Login</b></h2> <form method="post" action="<?php $_SERVER['PHP_SELF'] ?>"> <fieldset> <div class="supscript">This don't even work lul.</div> <input type="text" class="sideBarInput_Login" id="userinp" name="user" value="Username" onclick="setInputFieldNewValue('','userinp');" /><br /> <input type="password" class="sideBarInput_Login" id="passinp" name="pass" value="Password" onclick="setInputFieldNewValue('', 'passinp');" /> <input type="submit" name="submit" class="sideBarInputBUTTON" value="Search" /> </fieldset> </form> <?php } ?> </li> <li> <h2><b>Site</b>roll</h2> <ul> <li><a href="http://tritonforums.net/">Triton Forums</a></li> <li><a href="http://www.phpfreaks.com/">PHP Freaks</a></li> <li><a href="http://www.rsbot.org/">RSBot Community</a></li> </ul> </li> </ul> </div> <!-- end sidebar --> Link to comment https://forums.phpfreaks.com/topic/179939-confused-myself-lol/ Share on other sites More sharing options...
trq Posted November 2, 2009 Share Posted November 2, 2009 Lol, I'm trying to make a login on my home page to work for me, it's not doing it though, any reason why? Could be any number of reasons. Instead of telling us it doesn't work, why not explain what you think it should do and what it is actually doing? Link to comment https://forums.phpfreaks.com/topic/179939-confused-myself-lol/#findComment-949204 Share on other sites More sharing options...
Do the sk8 Posted November 2, 2009 Share Posted November 2, 2009 if (isset($_POST['Submit'])) { //lul $username = $_POST['username']; $password = $_POST['pass']; $sql = mysql("SELECT * FROM `members` WHERE `user_name`='".$username."' AND `user_pass`='".$password."'") or die(mysql_error()); $count = mysql_fetch_row($sql); if($count != 0) { while($row = mysql_fetch_assoc($sql)) { $member_username = $row['user_name']; $member_password = $row['user_pass']; } } ? Link to comment https://forums.phpfreaks.com/topic/179939-confused-myself-lol/#findComment-949209 Share on other sites More sharing options...
Jarod Posted November 2, 2009 Author Share Posted November 2, 2009 the login feature on my home page is suppose to grab the matching username and password from my database, but if such username and/or password doesn't match it will throw an error while logging in (ex: wrong username and/or password!). Almost like this website's login feature when u put in the wrong username and/or password you get an error. I want that so my members can log in. Also the is being made from scratch and I'm still learning PHP (as you may have notice :'()... I just wanna log in with the stored username and password from my database's table members. Link to comment https://forums.phpfreaks.com/topic/179939-confused-myself-lol/#findComment-949210 Share on other sites More sharing options...
Do the sk8 Posted November 2, 2009 Share Posted November 2, 2009 Explain, does it login with any random names, or does it not show? Link to comment https://forums.phpfreaks.com/topic/179939-confused-myself-lol/#findComment-949211 Share on other sites More sharing options...
Jarod Posted November 2, 2009 Author Share Posted November 2, 2009 if (isset($_POST['Submit'])) { //lul $username = $_POST['username']; $password = $_POST['pass']; $sql = mysql("SELECT * FROM `members` WHERE `user_name`='".$username."' AND `user_pass`='".$password."'") or die(mysql_error()); $count = mysql_fetch_row($sql); if($count != 0) { while($row = mysql_fetch_assoc($sql)) { $member_username = $row['user_name']; $member_password = $row['user_pass']; } } ? if your looking at where I implemented the username member type via the http url, then let me explain: the username and password is requested and handled from the $_POST array, which grabs the submitted username and password from the form by the way. The username and password being handled by the query then, they are sent to request a matching row of usernames and passwords. If the row is not found it should output an error via the presentational page (my home page with the error Username or password was entered incorrect! Try again...). If the row does match then it should output that the user is logged in, which I cannot seem to figure out why it's doing such a thing with no error at all . Link to comment https://forums.phpfreaks.com/topic/179939-confused-myself-lol/#findComment-949214 Share on other sites More sharing options...
unitechy Posted November 2, 2009 Share Posted November 2, 2009 What is this? if($count != 0) { while($row = mysql_fetch_assoc($sql)) { $member_username = $row['user_name']; $member_password = $row['user_pass']; } Link to comment https://forums.phpfreaks.com/topic/179939-confused-myself-lol/#findComment-949227 Share on other sites More sharing options...
Jarod Posted November 2, 2009 Author Share Posted November 2, 2009 What is this? if($count != 0) { while($row = mysql_fetch_assoc($sql)) { $member_username = $row['user_name']; $member_password = $row['user_pass']; } I was instantiating the rows from the table members (speaking of instantiating, I should of just used explode instead >.>...) Link to comment https://forums.phpfreaks.com/topic/179939-confused-myself-lol/#findComment-949321 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.