This topic is locked

Update Created Date and Expiry Date After Succesful Registration

3/20/2008 9:26:35 AM
PHPRunner General questions
C
ckapote author

Please help,

I have the following fields on registration page:

User

Pass

Datecreated

Dateexpiry ( after 30 days of date that the account was created)
I wish fields Datecreated automatically updated to now and dateexpiry to 30 days after datecreated after succesful registration.

Please help as always , thank you.
Furthermore , when user is log in i need a script to check the dateexpiry field if is more than today and

inform user , cancelling log in .
Thank you very much!

Alexey admin 3/20/2008

Chris,
you can do this with Events.

In the BeforeRegisterevent save the dates in the $values array.

I.e.

$values["Datecreated"]=date("Y-m-d");

$values["Dateexpiry"]=date("Y-m-d",time()+30243600);


Then use BeforeLoginevent to check if account expired or not.

Return falsethere if account expired and trueif not.

C
ckapote author 3/20/2008

Chris,

you can do this with Events.

In the BeforeRegisterevent save the dates in the $values array.

I.e.
Then use BeforeLoginevent to check if account expired or not.

Return falsethere if account expired and trueif not.


Thank you very much but what script I need to check if account expired ,
please help !

Alexey admin 3/20/2008

Chris,
unfortunately we don' t have a ready to go solution for this.
Inspect this article, you can find some examples there:

http://www.xlinesoft.com/articles/system_access_lock.htm

C
ckapote author 3/21/2008

Chris,

unfortunately we don' t have a ready to go solution for this.
Inspect this article, you can find some examples there:

http://www.xlinesoft.com/articles/system_access_lock.htm


Thanks and I understand your point.
But if you can help it will appreciated , I have created the following script before log in :

global $conn;

$sql = "select expire from tbluser where UserName='".$userdata["UserName"]."'";

$rs = db_query($sql,$conn);

$data = db_fetch_array($rs);
if ($data["expire"]<now())

{

echo "<p align=center>
<font color=red><b>Access denied account expired </b> <font></p>";

return false;

}

else

{

return true;

}
but is not working , can you have a look please ??

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=27201&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />

J
Jane 3/21/2008

Chris,
make sure that all field names are correct and your query returns value:

$sql = "select expire from tbluser where UserName='".$userdata["UserName"]."'";

echo $sql;

$rs = db_query($sql,$conn);

$data = db_fetch_array($rs);
print_r($data);

C
ckapote author 3/21/2008

Chris,

make sure that all field names are correct and your query returns value:


Thanks Jane ,

after various checkings final I found a script that it seems that is working .

Just for the records :

global $conn;
$sql = "select expiry from user where user='".$username."'";
$rs = db_query($sql,$conn);
$data = db_fetch_array($rs);
if ($data["expiry"]<now())
{
echo "<p align=center>
<font color=red><b>Access denied account expired </b> <font></p>";
return false;
}
else
{
echo "<p align=center>
<font color=blue><b>Access ok </b> <font></p>";
return true;
}
Thank you for your continuous support