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_me nu" 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,
-"introducti on"-
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:
//in script
mysql_query("UP DATE user_basic SET active='yes' WHERE id='$activkey'" );
<form method="post" action="index.p hp">
<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=registrat ion®in=$datu m\r\n";
mail($to, $subject, $body, $headers);
mysql_query("IN SERT INTO user_temp
(uname,email,pw d,regin,checked )
VALUES ('$uname','$ema il','$pwd','$da tum','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("UP DATE user_temp SET
checked='yes'
WHERE regin='$regin'" );
mysql_query("IN SERT INTO user_basic
VALUES (" . stuff from user_temp table . ");
mysql_query("DE LETE FROM user_temp
WHERE (regin='$regin' AND checked='yes') LIMIT 1");
<form method="post" action="index.p hp">
<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('memb er','',time()-31536000,"/",".mysite.tld" );
unset($_COOKIE['kuki']);
setcookie('kuki ','',time()-31536000,"/",".mysite.tld" );
header('Locatio n: index.php');
}
if(isset($_COOK IE['member']) && isset($_COOKIE['kuki'])) {
$logiran=test_i s_user();
if($logiran) {
member_menu();
} else {
login_form();
}
}
elseif (isset($okej)) {
$check=random_c ookie();
mysql_query("UP DATE user_basic SET kuki='$kuki'
WHERE uname='$_POST[uname]'");
setcookie("memb er","$uname",ti me()+31536000,"/",".mysite.tld" );
setcookie("kuki ","$kuki",time( )+31536000,"/",".mysite.tld" );
member_menu();
}
else {
if($enter) {
$who("SELECT * FROM user_basic
WHERE(uname='$u name' AND pwd='".md5($pwd )."')";
mysql_query($wh o);
if(mysql_num_ro ws($who) != 1) {
error_user();
} else {
$user_data=mysq l_fetch_array($ reza_who);
if($user_data[kuki]) {
$aproov=$user_d ata[kuki];
} else {
$aproov=random_ cookie();
mysql_query("UP DATE user_basic SET kuki='$aproov'
WHERE uname='$_POST[uname]'");
}
setcookie("memb er","$uname",ti me()+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?
--
"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_me nu" 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,
-"introducti on"-
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:
//in script
mysql_query("UP DATE user_basic SET active='yes' WHERE id='$activkey'" );
<form method="post" action="index.p hp">
<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=registrat ion®in=$datu m\r\n";
mail($to, $subject, $body, $headers);
mysql_query("IN SERT INTO user_temp
(uname,email,pw d,regin,checked )
VALUES ('$uname','$ema il','$pwd','$da tum','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("UP DATE user_temp SET
checked='yes'
WHERE regin='$regin'" );
mysql_query("IN SERT INTO user_basic
VALUES (" . stuff from user_temp table . ");
mysql_query("DE LETE FROM user_temp
WHERE (regin='$regin' AND checked='yes') LIMIT 1");
<form method="post" action="index.p hp">
<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('memb er','',time()-31536000,"/",".mysite.tld" );
unset($_COOKIE['kuki']);
setcookie('kuki ','',time()-31536000,"/",".mysite.tld" );
header('Locatio n: index.php');
}
if(isset($_COOK IE['member']) && isset($_COOKIE['kuki'])) {
$logiran=test_i s_user();
if($logiran) {
member_menu();
} else {
login_form();
}
}
elseif (isset($okej)) {
$check=random_c ookie();
mysql_query("UP DATE user_basic SET kuki='$kuki'
WHERE uname='$_POST[uname]'");
setcookie("memb er","$uname",ti me()+31536000,"/",".mysite.tld" );
setcookie("kuki ","$kuki",time( )+31536000,"/",".mysite.tld" );
member_menu();
}
else {
if($enter) {
$who("SELECT * FROM user_basic
WHERE(uname='$u name' AND pwd='".md5($pwd )."')";
mysql_query($wh o);
if(mysql_num_ro ws($who) != 1) {
error_user();
} else {
$user_data=mysq l_fetch_array($ reza_who);
if($user_data[kuki]) {
$aproov=$user_d ata[kuki];
} else {
$aproov=random_ cookie();
mysql_query("UP DATE user_basic SET kuki='$aproov'
WHERE uname='$_POST[uname]'");
}
setcookie("memb er","$uname",ti me()+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?
--
Comment