FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Activation and approval !!





salman_500
hey guyz,

this is my 4th topic i guess lol ! im learning alot new things... and now i take step for somthin more difficult.. (for me)..

you see i have a tabel named "housesale"... and i have a form on a page that enter data into this table... now i have done the part where only members can enter the data but what i want is that when a member emters data into the form and presses submit, i want to send an activation link to that person's e-mail, so that he has to activate before we can move onto the nexzt step.. like in any php-nuke website (www.solothemes.com) where you ifrst have to activate in order to be member....

now the next step for this is that when a user activates his entry it is then forwarded to a place from where the adminsitration can activate it.... just like in php-nuke you get submission and you have the option to either accept or reject ... so i want to be able to accept or reject the activated entry.....

any1 who does this for me... like always i am willing to pay upto 50 or more than 50 Frih$'s depending on how difficlt it proves to be !

Thnx !
Marston
Code it yourself, it's fairly simple.
salman_500
Marston wrote:
Code it yourself, it's fairly simple.


maybe i asked for help because i CAN'T code it myself ! coz i dont know HOW !
Rhysige
To give you a general run down on how you would do this, you simply take something (lets say user ID) and you email them a link which goes to a page with id=theiruserid and run a script on that page which will edit something in the table to say they have been activated. Its really fairly simple.
hexkid
Add a "status" column to your housesale table.
Add a table with the housesale id, activation id, and date to your database.

When users fill the form and submit you get two new rows on these tables:
Code:
housesaleid | ... more data ... | status
        360 |        ...        |      0


housesaleid |   activationcode | submitteddate       | activationdate
        360 | 7e2b86a8c330ffa2 | 2006-08-02 12:14:33 | NULL


Of course you only show house sales with status = 1
The activationcode is something you generate randomly.

After inserting these records in the tables send the user a link to activate
http://example.com/activate.php?id=7e2b86a8c330ffa2
This activate.php script takes the id from the query string and updates the table
Code:
housesaleid |   activationcode | submitteddate       | activationdate
        360 | 7e2b86a8c330ffa2 | 2006-08-02 12:14:33 | 2006-08-02 16:17:18


And somewhere on your site, you have the administration page that shows you all housesales waiting for approval (select housesaleid from housesaleactivation where activationdate is not null) which you can then approve (change status to 1 and delete the activation record) or not.


Happy Coding Smile
salman_500
reading the above 2 posts this iis what i got ...

you see... what im gonna do and what i have done is this...

what i have done is that to my tabe "housesale" i added 2 new fields. one is status and the other is activationcode... for status i gave it a default value of "0" and for activationcode i set it up as "timestamp" (using this as the random code for the activation...

one more thig i have done is that where i display the records from the table "housesale" i set it to filter, showing only the ones with a status value of 1... meaning the one which have been activated....

(i wana do this part, need help with it) now what im planning to do is that once a person enters data into the table he is sent a mail at the provided E-mail address with the value of the field "activationcode" from the record he entered... meaning that from the record he entered.....

now that the user has the activation code with him, he will go to a page named as "activate.php" in that page there will be a form with one text field and a button.... the user will be asked to enter the activation code in the field.. and then press the button named "Activate" now when he does this a mysql query is activated.. what this query does it that it first check the table and finds the record who's activationcode matches the code that the user entered.. when it has succesfully found the record, it will then change the status value of that record from "0" to "1" hence activating it....

i see that i have planned it out nicely . Wink . but i cannot do the part that i said i have to do... now i need help of som1 who can tell me how can i get the activation code of the record that is entered by the user and how can i get it to mail to the user...

plz help me with this !!

Thnx ! Very Happy

hexkid wrote:
Add a "status" column to your housesale table.
Add a table with the housesale id, activation id, and date to your database.

When users fill the form and submit you get two new rows on these tables:
Code:
housesaleid | ... more data ... | status
        360 |        ...        |      0


housesaleid |   activationcode | submitteddate       | activationdate
        360 | 7e2b86a8c330ffa2 | 2006-08-02 12:14:33 | NULL


Of course you only show house sales with status = 1
The activationcode is something you generate randomly.

After inserting these records in the tables send the user a link to activate
http://example.com/activate.php?id=7e2b86a8c330ffa2
This activate.php script takes the id from the query string and updates the table
Code:
housesaleid |   activationcode | submitteddate       | activationdate
        360 | 7e2b86a8c330ffa2 | 2006-08-02 12:14:33 | 2006-08-02 16:17:18


And somewhere on your site, you have the administration page that shows you all housesales waiting for approval (select housesaleid from housesaleactivation where activationdate is not null) which you can then approve (change status to 1 and delete the activation record) or not.


Happy Coding Smile
hexkid
1) after you insert a record into the "housesale" table you need to fetch the timestamp
2) send that timestamp (I'd md5() it first to avoid people trying timestamps that do not belong to them) to the user
Code:
// 1)
$id = mysql_insert_id();
$sql = "select activationcode from housesale where housesaleid=$id";
$res = mysql_query($sql);
$timestamp = mysql_result($res, 0);

// 2)
$code = md5($timestamp);
mail($useraddress, 'Activation', "Your activation code is $code.");


Now the user goes to the activate.php and enters the code.
3) You need to update the status of the record with that code
Code:
// 3)
$code = mysql_real_escape_string($_POST['code']);
if (strlen($code) != 32) exit('Go away!');
$sql = "update housesale set status=1 where md5(activationcode)='$code'";
mysql_query($sql);
$changes = mysql_rows_affected($conn)
if ($changes == 0) {
  echo 'No rows updated.';
} else if ($changes > 1) {
  echo 'Oops. Something very wrong hapenned here.';
} else {
  echo 'Row updated successfully.';
}
Shirish
speaking in simple terms,

you should first create a random number or id from the email and username

now email this id to user

also add this id to Databse with a flag option which checks whether you have been approved or not..

Now when user clicks on the email link, he goes to s page ,
which runs a php script

which checks the id and then dets the flag to true.

so everytime you log in , it checks the approved flag option plain...


Do you get the thing now...
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.