Thread subject: Official Home of the PHPFusion CMS :: Concerning register.php in Fusion8

Posted by Grimloch on 06-02-2023 17:55
#1

I need help with this. When a new user registers: code from register.php
Code
 if (dbrows($result) > 0) {
 add_to_title($locale['global_200'].$locale['u155']wink;

 $data = dbarray($result);
 -----------------> $user_info = unserialize(base64_decode(($data['user_info']wink)); <------------------

 $result = dbquery("INSERT INTO ".DB_USERS." (".$user_info['user_field_fields']."wink VALUES (".$user_info['user_field_inputs']."wink"wink;
 $result = dbquery("DELETE FROM ".DB_NEW_USERS." WHERE user_code='".$_GET['code']."' LIMIT 1"wink;

 opentable($locale['u155']wink;
 if ($settings['admin_activation'] == "1"wink {
 echo "<div style='text-align:center'><br />n".$locale['u171']."<br /><br />n".$locale['u162']."<br /><br />n</div>n";
 } else {
 echo "<div style='text-align:center'><br />n".$locale['u171']."<br /><br />n".$locale['u161']."<br /><br />n</div>n";
 }
------------------------> include BASEDIR."welcome_letter.php"; <-------------------
 closetable();
 } else {
 redirect("index.php"wink;
 }

I have annotated the info in question. I need to know if it's possible and proper to do this in my welcome_letter.php script:
Code
   $to_email = $user_info['user_email'];
   $to_name = $user_info['user_name'];

After the user receives the notice that they are now registered and can login I want to send them a welcome letter.

Edited by Chan on 09-02-2023 06:40

Posted by MathiasHU on 06-02-2023 21:47
#2

Do you this want? That's true v9

https://marketplace.phpfusion.com/?id...m/?id=1257

Posted by Grimloch on 07-02-2023 00:40
#3

Maybe I'll take a look at it and see if I can use any of it. But I'm on Fusion8.

Posted by Grimloch on 07-02-2023 06:47
#4

That doesn't help me a bit. Thanks for trying.

Posted by Grimloch on 07-02-2023 07:18
#5

Still trying. Please tell me what is wrong with this code I added in register.php:
Code
 if (dbrows($result) > 0) {
 add_to_title($locale['global_200'].$locale['u155']wink;
 $data = dbarray($result);
 $user_info = unserialize(base64_decode(($data['user_info']wink));
 $result = dbquery("INSERT INTO ".DB_USERS." (".$user_info['user_field_fields']."wink VALUES (".$user_info['user_field_inputs']."wink"wink;
    $lastid = db_lastid();
 $result = dbquery("DELETE FROM ".DB_NEW_USERS." WHERE user_code='".$_GET['code']."' LIMIT 1"wink;
opentable($locale['u155']wink;
 if ($settings['admin_activation'] == "1"wink {
 echo "<div style='text-align:center'><br />n".$locale['u171']."<br /><br />n".$locale['u162']."<br /><br />n</div>n";
 } else {
 echo "<div style='text-align:center'><br />n".$locale['u171']."<br /><br />n".$locale['u161']."<br /><br />n</div>n";
   }
      $result = dbquery("SELECT user_name, user_email FROM ".DB_USERS." WHERE user_id = '".$lastid."'"wink;
         while ($data = dbarray($result)) {
         $email = $data['user_email'];
         $name = $data['user_name'];
      include BASEDIR."welcome_letter.php";
   }
closetable();

And in the welcome_letter.php besides the html content I have this:
Code
<?php
require_once INCLUDES."sendmail_include.php";
   $to_name = $name;
   $to_email = $email;
   $subject = "Letter of Welcome";
$content
   $message = $content;
   $from_name = "Tom Wills";
   $from_email = 'twills@ohs1962.org';

      sendemail($to_name, $to_email, $from_name, $from_email, $subject, $message, $type = "html", $cc = "", $bcc = "terry@whisperwillow.com"wink;
?>

Edited by Grimloch on 07-02-2023 16:05

Posted by Chan on 09-02-2023 06:34
#6

What's in $user_info ? if it contains user name and user email you can use it without doing anything else.
I cannot see anything wrong without the array debug output except for the reliance of dblastid in the last query. We have also mentioned before that lastid is unreliable if server lags.

Posted by Grimloch on 09-02-2023 07:17
#7

The db_lastid (which is the way it is in ver8) works fine I tested it. It does grab the last username and email that was inserted from users table. The problem is it just refuses to send the email; no error codes in the log. I'm still plugging away at it but so far no luck.

Posted by Grimloch on 09-02-2023 07:53
#8

When I submit the registration it gives the proper message on the screen. But then when I click the link in the verification email that I get this is the result on the website. The email that I am trying to send never comes through.

Posted by Grimloch on 09-02-2023 14:38
#9

I just do not understand why this won't work. I spent some time cleaning up and simplyfying the code. The end result is still the same (see image in previous post); user is validated and confirmed but no welcome email is sent. Here is the code now:
Code
 if (dbrows($result) > 0) {
 add_to_title($locale['global_200'].$locale['u155']wink;
 $data = dbarray($result);
 $user_info = unserialize(base64_decode(($data['user_info']wink));
 $result = dbquery("INSERT INTO ".DB_USERS." (".$user_info['user_field_fields']."wink VALUES (".$user_info['user_field_inputs']."wink"wink;
         $lastid = db_lastid();
 $result = dbquery("DELETE FROM ".DB_NEW_USERS." WHERE user_code='".$_GET['code']."' LIMIT 1"wink;
opentable($locale['u155']wink;
 if ($settings['admin_activation'] == "1"wink {
 echo "<div style='text-align:center'><br />n".$locale['u171']."<br /><br />n".$locale['u162']."<br /><br />n</div>n";
 } else {
 echo "<div style='text-align:center'><br />n".$locale['u171']."<br /><br />n".$locale['u161']."<br /><br />n</div>n";
   }
// New coding to send welcome letter
      $result = dbquery("SELECT user_name, user_email FROM ".DB_USERS." WHERE user_id = '$lastid'"wink;
         while ($data = dbarray($result)) {
         $email = $data['user_email'];
         $name = $data['user_name'];

require_once INCLUDES."sendmail_include.php";

      $to_name = $name;
      $to_email = $email;
      $from_name = "xxx xxxx";
      $from_email = "xxxx@xxxx";
      $subject = "Letter of Welcome";
      include "welcome_tpl.php";
      sendemail($to_name, $to_email, $from_name, $from_email, $subject, $message, $type = "html"wink;
}
// End new welcome letter coding
closetable();

The 'welcome_tpl.php' is a non-image html template in the root folder from my newsletters infusion that I have used successfully for many years now. I do not suspect a problem there. Can someone please try to help me with this. It's the final step in making my friends closed membership alumni website complete. It would be greatly appreciated!

Edited by Grimloch on 09-02-2023 14:52

Posted by Grimloch on 09-02-2023 17:10
#10

Well my friends it now works like a charm! I have never been afraid of admitting when I am wrong and this time is no exception! I had multiple errors in my template file. No errors in Fusion and I discovered them by looking at the Host error log. Anyway this puppy can be put to bed!

Posted by MathiasHU on 10-02-2023 22:10
#11

Have you created a new user?

Posted by Grimloch on 11-02-2023 06:22
#12

[quote name=MathiasHU post=212103]@MathiasHU - Have you created a new user?[/quote]
Yes multiple times. It works perfectly.

Posted by Grimloch on 13-02-2023 15:06
#13

To anyone running a version 8 site. If you might be interested in doing this just PM me and I can supply you with all the details not shown here.

Posted by MathiasHU on 22-02-2023 11:42
#14

It works, I get a welcome email

Code
            // New coding to send welcome letter
 $result = dbquery("SELECT user_name, user_email FROM ".DB_USERS." WHERE user_id = '".$lastid."'"wink;
 while ($data = dbarray($result)) {
 $email = $data['user_email'];
 $name = $data['user_name'];

require_once INCLUDES."sendmail_include.php";

 $to_name = $name;
 $to_email = $email;
 $from_name = $settings['siteusername'];
 $from_email = $settings['siteemail'];
 $subject = "Letter of Welcome ".$lastid."";
      $message = "Letter of Welcome test message";
 //include "welcome_tpl.php";

 sendemail($to_name, $to_email, $from_name, $from_email, $subject, $message, $type = "html"wink;

}
// End new welcome letter coding