russ939 Posted August 20, 2010 Share Posted August 20, 2010 here is my part of the code which i am stuck on <?php $form = "<form action='login.php' method='post'> <center> <table> <tr> <td><input type='text' id='usernamebox' name='Username' value='Username' tabindex='1' class='textbox' onFocus='usernamebox_focus();' onBlur='usernamebox_blur();'></td> <td><a href='register.php'>Register</span></a></td> </tr> <tr> <td><input type='password' id='passwordbox' name='Password' value='Password' tabindex='2' class='textbox' onFocus='passwordbox_focus();' onBlur='passwordbox_blur();'></td> <td><input type='submit' name='loginbutton' value='Login'></td> </tr> </table> </center> </form>"; ******(on the website the rest under thiss is missing)******** if ($_POST['loginbutton']){ $user = $_POST['username']; $password = $_POST['password']; if ($user && $password && $user != 'Username'){ require("Scripts/connect.php"); $password = md5($password); $query = mysql_query("SELECT * FROM users WHERE username='$user' AND password='$password'"); $numrows = mysql_num_rows($query); if ($numrows = 1){ $rows = mysql_fetch_assoc($query); $dbuser = $rows['username']; $_SESSION['user'] = $dbuser; $_SESSION['id'] = $dbid; echo "<a href='index.php'> You are now loged in Click here to go to our Homepage</a>"; } else echo '<center>You did not submit a correct username and/or password!</center>'; echo '$form'; } else echo '<center>You did not submit a correct username and/or password!</center>'; echo '$form'; } else{ echo '$form'; } ?> Quote Link to comment Share on other sites More sharing options...
oliverj777 Posted August 20, 2010 Share Posted August 20, 2010 How is it not working - are you getting any error messages when you try and submit. Your problem is a bit faint. Help me out here, explain what you want doing, and what it is currently doing. Quote Link to comment Share on other sites More sharing options...
russ939 Posted August 20, 2010 Author Share Posted August 20, 2010 well i'm simply trying to get the code to work lol All this code is missing when i look at the source code on my website but when i look at the code in the login.php file on my ftp it's all thier if ($_POST['loginbutton']){ $user = $_POST['username']; $password = $_POST['password']; if ($user && $password && $user != 'Username'){ require("Scripts/connect.php"); $password = md5($password); $query = mysql_query("SELECT * FROM users WHERE username='$user' AND password='$password'"); $numrows = mysql_num_rows($query); if ($numrows = 1){ $rows = mysql_fetch_assoc($query); $dbuser = $rows['username']; $_SESSION['user'] = $dbuser; $_SESSION['id'] = $dbid; echo "<a href='index.php'> You are now loged in Click here to go to our Homepage</a>"; } else echo '<center>You did not submit a correct username and/or password!</center>'; echo '$form'; } else echo '<center>You did not submit a correct username and/or password!</center>'; echo '$form'; } else{ echo '$form'; } website is www.hostgamer.co.uk/login.php also onn dreamweaver with live view select the missing code shows under the login box (pic attached) :'( [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
oliverj777 Posted August 20, 2010 Share Posted August 20, 2010 PHP does not show up as a source code in a browser. All you will see is your HTML language. If you can see your PHP code within an editor (dreamweaver) then trust me ... its there. But like I said, PHP is not displayed in the source code from a browser, even if you 'save as' the web page, you will still not see any of the PHP code. On to the problem, let me get my understanding correct. Am I right in thinking that your login script is missing a load of code, causing it not to function? Quote Link to comment Share on other sites More sharing options...
russ939 Posted August 20, 2010 Author Share Posted August 20, 2010 ha well tahts confusing becouse it's connecting to my mySQL database but still wont log me into my acount using md5 encription for the password Quote Link to comment Share on other sites More sharing options...
oliverj777 Posted August 20, 2010 Share Posted August 20, 2010 When you attempt to login, what happens? Do you get an error message from your script like 'You did not submit a correct username and/or password!' or does it look like it simply refreshes the page? Or what ... Quote Link to comment Share on other sites More sharing options...
russ939 Posted August 21, 2010 Author Share Posted August 21, 2010 ye i get that anoying error even though i know i am entering the correct username and password 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.