Forum Moderators: coopster
i have been searching for this script since long and i have done everything to find it out. i want a PHP script which allows to invite people with auto generated password and Email as ID to view my Profile. but i m not able to find it out. so please if u have any kind of stuff than give me suggestion what should i Do?
Note:
Invited people will not be a member of my website they are just visitors and can view only profile of the person who has invited him....
waiting for your reply....
Thanks
u have any kind of stuff than give me suggestion what should i Do?
Welcome aboard little dinosaur!
Here is one logic approach. This is not "working code" but should outline an idea of what you could do, and should not be that difficult for even a beginning coder. "Fill in the blanks" from the tutorials at W3 Schools [w3schools.com] and the PHP Manual [php.net].
Start with a form or something to enter the invite. Let's say it's an email address field:
<input type="text" name="invite">
<input type="hidden" name="page" value="example.com/mypage">
When submitted, you do this (But do not use $_POST variables directly, cleanse the data.) $from_person should not be a hidden field in the form, look it up by ID or something and get it from the database.
$from=$from_person;
$subj='See my Page';
$email = $_POST['invite'];
$page = $_POST['page'];
$random_pass = createPassword();
$email_message = composeEmail($email,$random_pass,$userpage);
send_email($email,$from,$subj,$email_message);
return_response_to_browser();
You will have to write the code for the functions. createPassword() would do something like this (untested, a bit on the inefficient side, but should work:)
function createPassword() {
// Eliminate the letter O so it doesn't get confused for a zero
// and the lower case L so it doesn't get confused for a one.
$passLength = 7;
$letters = Array ('a','B','c','d','E','F','g','H','I','j','K','L','m',
'n','p','Q','R','s','T','u','V','w','X','y','Z');
for ($i=1;$i<=$passLength;$i++) {
$randNum = rand(0, 23);
$loginKey .= $letters[$randNum];
}
return $loginKey;
}
composeEmail() would create the message itself, personalizing to the recipient:
function composeEmail($recipient,$pass,$url) {
$message = "
Dear $recipient,
Here is my page:$url
here is your login password:$pass
";
return $message;
}
Then send_email function would accept the to, from, subject, etc., and use the PHP mail function to send the mail.
function send_email($to,$recipient,$subject,$body) {
......
}
And of course, when done, return a response to the browser.