Jump to content
php.lv forumi

Advancēta ielogošanās/reģistrēšanās sistēma (#1)


daGrevis

Recommended Posts

Tātad problēma ir pavisam vienkārša, nesaprotu kādēļ tiek izmests paziņojums "Error!", pat ja visi lauciņi ir aizpildīti...

 

if(isset($_GET['action']) and $_GET['action'] == "signup") {
$username = $_POST['username'];
$email = $_POST['email'];	
$password = md5($_POST['password']);

$error = array();

if(empty($username)) {
	$error['username'] = true;
}
if(empty($email)) {
	$error['email'] = true;
}
if(empty($password)) {
	$error['password'] = true;
}

if(count($error) <= 1) {
	echo "Error!";
} else {
	mysql_query("INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$password')") or die(mysql_error());
}

message("announcment", "You have successfully signup!");
//header("Refresh: 3; url=login.php");
}

Link to comment
Share on other sites

Paldies, bet nestrādā.

Mēģinu piereģistrēt lietotāju bez epasta, un arī piereģistrēju... :(

Citas idejas?

 

Labojums.

 

Nē, strādā gan, tikai ir tāda nopietna problēma ar md5 hashoto paroli...

Neieraktot neko paroles lauciņā, lietotājs tiek piereģistrēts tāpat, un db tiek ierakstīts "d41d8cd98f00b204e9800998ecf8427e", kas atbilst tukšumam.

Idejas?

Edited by daGrevis
Link to comment
Share on other sites

Šadi?

 

<?php
if(isset($_GET['action']) and $_GET['action'] == "signup") {
$username = $_POST['username'];
$email = $_POST['email'];	
$password = $_POST['password'];

$error = array();

if(empty($username)) {
	$error['username'] = true;
}
if(empty($email)) {
	$error['email'] = true;
}
if(empty($password)) {
	$error['password'] = true;
} else {
	$password = $encryptedPassword;
	$encryptedPassword = md5($_POST['encryptedPassword']);
}

if(count($error) > 0) {
	message("error", "Missing from data!");
} else {
	mysql_query("INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$encryptedPassword')") or die(mysql_error());
	message("announcment", "You have successfully signup!");
	//header("Refresh: 3; url=login.php");
}
}
?>

 

Tik problēma tā pati - saglabājas viss tukšā hashā... :(

Edited by daGrevis
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.

Guest
Reply to this topic...

×   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.

Loading...
×
×
  • Create New...