By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,719 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,719 IT Pros & Developers. It's quick & easy.

need help in activation-registration-login solution...

P: n/a
Hello, I have made my cms... and is working, but have some, let me say
"bugs"... And I don't know all reasons, please allow me slightly longer
and most probably confusing post (that "confusing" is mainly becaose of
my bad english, and that bad english is also reason why am I learning
php that slow...).
As first, what is problem:
some users after succsesfull registration and login can not see
"memeber_menu" and can not activly participate if forums, galleries
(they are not able to post or upload images)... cookie problem? but just
some of them? why not all of them? if I delete one "cookie" from my
dbase for them, problem is solved...
now,

-"introduction"-
I have old site (7 years will be now) with some old members. not
"registered" members because in past I have worked on all content
manualy. now, after many younger sites have been created with nuke,
mambo, phpbb and many other CMS scripts and after year of my search for
the best of them (CMSs), I have decided to learn and write my own. And I
did, and my cnms is working with allready mentioned problem which I will
try to explain now...
-I need sort of "activation" code for my old members which I have added
to my database manualy
-I need registration with aprooval for new members (as I don't want
members with wrong e-mail addres in my dbase)

-"short explanation of my solution"-
-activation of old members:
//just some basic lines of code!
in mail:
http://mysite.tld/?page=activate&activkey=9876qwerty
//in script
mysql_query("UPDATE user_basic SET active='yes' WHERE id='$activkey'");
<form method="post" action="index.php">
<input type="hidden" name="uname" value="$uname">
<!--uname will be used for cookie-->
<input type="submit" name="OK" value="log in">
<!--"OK" will activate cookie process on index-->
//index will be desribed at the end!

-registration of new mwmbers
//just some basic lines of code!
/*long registrtion form with checking of email,
duplicate email, duplicate uname...*/
$datum=time();
$body="password=$pwd\r\n".
"activation number=$datum\r\n".
"activation link:\r\n".
"http://mysite.tld/?page=registration&regin=$datum\r\n";
mail($to, $subject, $body, $headers);
mysql_query("INSERT INTO user_temp
(uname,email,pwd,regin,checked)
VALUES ('$uname','$email','$pwd','$datum','not')");
/*aprooval part: (user can enter activation number or
click on activation link in e-mail)*/

if ($_POST['regin']) {
$regin = $_POST['regin'];
} else {
$regin = $_GET['regin'];
}

mysql_query("UPDATE user_temp SET
checked='yes'
WHERE regin='$regin'");
mysql_query("INSERT INTO user_basic
VALUES (" . stuff from user_temp table . ");
mysql_query("DELETE FROM user_temp
WHERE (regin='$regin' AND checked='yes') LIMIT 1");

<form method="post" action="index.php">
<input type="hidden" name="uname" value="$uname">
<!--uname will be used for cookie-->
<input type="submit" name="OK" value="log in">
<!--"OK" will activate cookie process on index-->
//index will be desribed at the end!

-and now index.page with that ^%#$% Cookies. maybe PHP session would be
much better, but as for now I have no idea how to use them...

$uname = $_POST['uname'];
$pwd = $_POST['pwd'];
$OK = $_POST['OK'];
$enter = $_POST['enter'];
if ($_POST['page']) {
$page = $_POST['page'];
} else {
$page = $_GET['page'];
}

if($page == exit){
unset($_COOKIE['member']);
setcookie('member','',time()-31536000,"/",".mysite.tld");
unset($_COOKIE['kuki']);
setcookie('kuki','',time()-31536000,"/",".mysite.tld");
header('Location: index.php');
}

if(isset($_COOKIE['member']) && isset($_COOKIE['kuki'])) {
$logiran=test_is_user();
if($logiran) {
member_menu();
} else {
login_form();
}
}

elseif (isset($okej)) {
$check=random_cookie();
mysql_query("UPDATE user_basic SET kuki='$kuki'
WHERE uname='$_POST[uname]'");
setcookie("member","$uname",time()+31536000,"/",".mysite.tld");
setcookie("kuki","$kuki",time()+31536000,"/",".mysite.tld");
member_menu();
}

else {
if($enter) {
$who("SELECT * FROM user_basic
WHERE(uname='$uname' AND pwd='".md5($pwd)."')";
mysql_query($who);
if(mysql_num_rows($who) != 1) {
error_user();
} else {
$user_data=mysql_fetch_array($reza_who);
if($user_data[kuki]) {
$aproov=$user_data[kuki];
} else {
$aproov=random_cookie();
mysql_query("UPDATE user_basic SET kuki='$aproov'
WHERE uname='$_POST[uname]'");
}
setcookie("member","$uname",time()+31536000,"/",".mysite.tld");
setcookie("kuki","$kuki",time()+31536000,"/",".mysite.tld");
member_menu();
}
} else { // why do I have this line? some leftover?
login_form();
}
}
I hope that my "cuting" of my scripts didn't made my solution unridable,
and I hope that someone will find what I made wrong...
tnx in advance.

--
Jan ko?
http://fotozine.org/?omen=janimir
--
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
i forgot to tell what function test_is_user() does:

function test_is_user() {
if(isset($_COOKIE['member']) && isset($_COOKIE['kuki'])) {
$query="SELECT kuki FROM user_basic
WHERE uname='$_COOKIE[fotograf]'";
$result=mysql_query($query) or die ("$query");
list($procitan_kuki) = mysql_fetch_array($reza_kuki);
if ("$procitan_kuki" == $_COOKIE['provjera']) {
$logiran = "1";
} else {
$logiran = "0";
$errormsg="text about some discrepancy";
}
} else {
$errormsg="login or register";
}
return $logiran;
return $errormsg;
}

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.