News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

How am I supposed to grab user's personal information (email & username) ?

Started by Aktoraman, June 08, 2010, 03:43:11 AM

Previous topic - Next topic

Aktoraman

Quote from: capady on June 15, 2010, 09:03:16 AM
Here with an if-statement. Tested as wel:


<?php

global $user_info, $smcFunc;

$_name = $user_info['name'];
$_email = $user_info['email'];

$pass=getPassword();

$headers = 'From: [email protected]'."\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8';

$to= $_email;
$subject="Welcome $_name";
$message="<p style='color:#000000'>Your game code of <b><span style='color:#FF0000; font-size:16px;'>MySMFforum</span></b> is <b><span style='color:#0000CC; font-size:16px;'>$pass</span></b></p>";

function
getPassword()
{
$s='abcdefghijklmnopqrstuvwxyz0123456789';
$temp='';
for(
$i=0; $i<8; $i++)
{
$r=rand(0, 35);
$temp .= substr ($s, $r, 1);
}
return
$temp;
}

function
generate()
{
global
$user_info, $smcFunc;
global
$to, $message, $subject;


   
$result = $smcFunc['db_query']('', '
       SELECT pass FROM {db_prefix}members
       WHERE id_member = {int:cur_member}
       LIMIT 1'
,
       array(
           
'cur_member' => $user_info['id'],
       )
   );

   if (!
$result) db_fatal_error();
   else  {
       
$row = $smcFunc['db_fetch_row']($result);
       
$code = $row[0];
   }
   
$smcFunc['db_free_result']($result);

   if (
$code == '')    {
       
$result = $smcFunc['db_query']('', '
           UPDATE {db_prefix}members
           SET pass = {string:pass}
           WHERE id_member = {int:cur_member}'
,
           array(
               
'cur_member' => $user_info['id'],
               
'pass' => getPassword(),
           )
       );

       
$m=mail($to, $subject, $message);

       if(
$m)
       {
           echo(
'<script language ="JavaScript">Alert(\'Email with code is send\')<script>');
       }
       else
       {
           echo(
'<script language = "JavaScript">Alert(\'Failed to send Email\')<script>');
       }
   }
   
redirectexit();
}

You are unbelievable  thank you very much!

Aktoraman

Quote from: capady on June 15, 2010, 09:03:16 AM
Here with an if-statement. Tested as wel:

<?php

global $user_info, $smcFunc;

$_name = $user_info['name'];
$_email = $user_info['email'];

$pass=getPassword();

$headers = 'From: [email protected]'."\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8';

$to= $_email;
$subject="Welcome $_name";
$message="<p style='color:#000000'>Your game code of <b><span style='color:#FF0000; font-size:16px;'>MySMFforum</span></b> is <b><span style='color:#0000CC; font-size:16px;'>$pass</span></b></p>";

function
getPassword()
{
$s='abcdefghijklmnopqrstuvwxyz0123456789';
$temp='';
for(
$i=0; $i<8; $i++)
{
$r=rand(0, 35);
$temp .= substr ($s, $r, 1);
}
return
$temp;
}

function
generate()
{
global
$user_info, $smcFunc;
global
$to, $message, $subject;


   
$result = $smcFunc['db_query']('', '
       SELECT pass FROM {db_prefix}members
       WHERE id_member = {int:cur_member}
       LIMIT 1'
,
       array(
           
'cur_member' => $user_info['id'],
       )
   );

   if (!
$result) db_fatal_error();
   else  {
       
$row = $smcFunc['db_fetch_row']($result);
       
$code = $row[0];
   }
   
$smcFunc['db_free_result']($result);

   if (
$code == '')    {
       
$result = $smcFunc['db_query']('', '
           UPDATE {db_prefix}members
           SET pass = {string:pass}
           WHERE id_member = {int:cur_member}'
,
           array(
               
'cur_member' => $user_info['id'],
               
'pass' => getPassword(),
           )
       );

       
$m=mail($to, $subject, $message);

       if(
$m)
       {
           echo(
'<script language ="JavaScript">Alert(\'Email with code is send\')</script>');
       }
       else
       {
           echo(
'<script language = "JavaScript">Alert(\'Failed to send Email\')</script>');
       }
   }
   
redirectexit();
}

Iam so sorry to bother you again, i need some extra help here.
I try to create the button in the Pages of SimplePortal in html environment of Add Page (SimplePortal) like this :

<form method="get"  action="pass.php" >
<input type="button" value="get pass" onclick="generate()" />
</form>

As you see iam trying to call the pass.php form and execute the generate() function (as you made for me)
I have already create the pass field (PhpMyAdmin) in smf_members table
But unfortunately nothing happens.....
What iam doing wrong ?
Is the php form wrong?
Is the way iam calling it?
I should call the getPassword() function instead?
Is the Add Page of SimplePortal not appropriate for this kind of actions? :-[
Please help me!!!!! :'(

CapadY

This wil never gonna work.

HTML is a clientsite language.
function Generate is a PHP action, so it is a serverside action

The HTML page don't know anything about the function Generate() because it's not included anywehere. So, the function will never be executed.

Why not just adding a menubutton in the default menubar ? It's the most easiest way and if you want you can hide that button for guests and for members that already have a password.
Please, don't PM me for support unless invited.
If you don't understand this, you will be blacklisted.

Aktoraman

Quote from: capady on June 17, 2010, 10:06:41 AM
This wil never gonna work.

HTML is a clientsite language.
function Generate is a PHP action, so it is a serverside action

The HTML page don't know anything about the function Generate() because it's not included anywehere. So, the function will never be executed.

Why not just adding a menubutton in the default menubar ? It's the most easiest way and if you want you can hide that button for guests and for members that already have a password.
Thanx for your answer!
Which mod i must use to add a new menu button and work this function for me?
Maybe with Custom Tab?
And how can i use it?

CapadY

when you attach your source/subs.php and root/index.php in your next post I'll fix it for you.
Please, don't PM me for support unless invited.
If you don't understand this, you will be blacklisted.

Aktoraman

Quote from: capady on June 17, 2010, 04:26:14 PM
when you attach your source/subs.php and root/index.php in your next post I'll fix it for you.
Ok Done...
I have attached source/subs.php & root/index.php
If you want please markup with a note the things you are going to fix in those forms, so i may figure out what changes have took place in there.
Thank you again Mr. Capady.

CapadY

Sorry, my car is broken and for me that's more important than your site :)

I've added some code but didn't test it.
Also the button is shown when allready a code has been send. The button isn't showed for guests.

I can't add comment in the code because the changes are made in an array.

In index.php one line of code is added on line 329
In subs.php 7 lines of code are added from line 4272

When you want to change the text on the button just edit the text in subs.php line 4273. The new button will now show "New Button".

Don't forget to empty the forumcache after youve made the changes. Otherwise the new button is probably not shown.

Good Luck
Please, don't PM me for support unless invited.
If you don't understand this, you will be blacklisted.

Aktoraman

Quote from: capady on June 18, 2010, 04:08:50 AM
Sorry, my car is broken and for me that's more important than your site :)

I've added some code but didn't test it.
Also the button is shown when allready a code has been send. The button isn't showed for guests.

I can't add comment in the code because the changes are made in an array.

In index.php one line of code is added on line 329
In subs.php 7 lines of code are added from line 4272

When you want to change the text on the button just edit the text in subs.php line 4273. The new button will now show "New Button".

Don't forget to empty the forumcache after youve made the changes. Otherwise the new button is probably not shown.

Good Luck
Thank you again....iam sorry about your car, good luck also to you...

Aktoraman

Quote from: capady on June 18, 2010, 04:08:50 AM
Sorry, my car is broken and for me that's more important than your site :)

I've added some code but didn't test it.
Also the button is shown when allready a code has been send. The button isn't showed for guests.

I can't add comment in the code because the changes are made in an array.

In index.php one line of code is added on line 329
In subs.php 7 lines of code are added from line 4272

When you want to change the text on the button just edit the text in subs.php line 4273. The new button will now show "New Button".

Don't forget to empty the forumcache after youve made the changes. Otherwise the new button is probably not shown.

Good Luck
So i have uploaded my pass.php & Subs.php in Source folder and the inde.php in root, then i empty the cache and the button was there!
When i clicked on it nothing changed in my pass filed inside smf_members table..... ???

CapadY

Only the field "Pass" in your own memberrecord should change. Before klicking the button the Pass field in your memberrecord should be empty. If not empty, nothing happens cause you have a code received then before.
Please, don't PM me for support unless invited.
If you don't understand this, you will be blacklisted.

Aktoraman

Quote from: capady on June 18, 2010, 06:35:09 AM
Only the field "Pass" in your own memberrecord should change. Before klicking the button the Pass field in your memberrecord should be empty. If not empty, nothing happens cause you have a code received then before.
Ok DONE it worked just fine!
Thank you very much!
But... i just wanted a code to insert in this field, the code, without getting involved the SMF function. (can i do it without SMF function, just PHP code?)
Now, i think, its very hard for me to add some things in it .... :(
Anyway
THANK YOU Mr. CAPADY! Your AWESOME!

CapadY

Oh yes, it can be done, I think it's not to hard.

But I'm not gonna start over again, so good luck :)
Please, don't PM me for support unless invited.
If you don't understand this, you will be blacklisted.

Advertisement: