Jump to content

Can't get login system to work


russ939

Recommended Posts

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';
}

?>

Link to comment
https://forums.phpfreaks.com/topic/211315-cant-get-login-system-to-work/
Share on other sites

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) :confused::wtf:  :'(

 

[attachment deleted by admin]

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.