Jump to content
  • 0

Форма входа...


vvsh
 Share

Question

Recommended Posts

  • 0

Спасибо!

А тут:

if (mysql_num_rows($result) != 1) {
$error = 'Bad Login';
include 'login.html';

} else {
$_SESSION[?username?] = '$username';
include ?memberspage.php?;
}

?

Пишет:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:apachetestwwwlogin.php on line 24

как исправить?

Link to comment
Share on other sites

  • 0
И еще:

где ошибка:

$query = ?select * from users where username=?$username? and password=?$password??;

в принципе построения запроса ;) RTFM по SQL-Injections

Один - с имене пользователя. Другой - со статусом. А третий - с зашифрованым паролем.

не фонтан, зачем нужна кука статуса? слабо себе представляю, если честно

Link to comment
Share on other sites

  • 0

Вот у меня код файла login.php, не могли бы вы поправить его?:

<?php

//Database Information

$dbhost = "localhost";
$dbname = "база";
$dbuser = "user";
$dbpass = "pass";

//Connect to database

mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

session_start();

$username = $_POST[?username?];
$password = md5($_POST[?password?]);

$query = 'select * from users where username=?$username? and password=?$password?';

$result = mysql_query($username);

if (mysql_num_rows($result) !== 1 )


{
$error = 'Bad Login';
include 'login.html';

} else {
$_SESSION[?username?] = '$username';
include ?memberspage.php?;
}

?>

Помогите!ПлиЗ!

Link to comment
Share on other sites

  • 0
<?php

$dbhost = "localhost";
$dbname = "база";
$dbuser = "user";
$dbpass = "pass";

mysql_connect($dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

session_start();

$username = isset($_POST['username']) ? $_POST['username'] : "";
$password = isset($_POST['password']) ? md5($_POST['password']) : "";

if (!$result = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'")) echo mysql_error();


if (!mysql_num_rows($result)) {
$error = "Bad Login";
include "login.html";
} else {
$_SESSION['username'] = $username;
include "memberspage.php";
}

?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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. See more about our Guidelines and Privacy Policy