Share My Creation (PHP/MySQL/API) User Login App

Web API






Android App




 
Last edited:

aeric

Expert
Licensed User
Longtime User
Very Nice.
That's what I'm also developing right now, only I don't want to use PHP, but everything with B4J.
Security plays a big role.
Please check this:
 

aeric

Expert
Licensed User
Longtime User

tsteward

Well-Known Member
Licensed User
Longtime User
I can see there are 2 slashes before user in the url. Try edit the config file so it shows only 1 slash.
I removed the trailing slash in the config file for "root_url"
PHP:
// PRODUCTION - using subdomain
define("ROOT_PATH", "/api/");
define("ROOT_URL", "https://locksdownunder.com");

define("DEVELOPMENT", "FALSE");
That gave this link and this error:
Your code is installed in locksdownunder.com/api/

 

aeric

Expert
Licensed User
Longtime User
There are 2 cases. Do you (1) create a subdomain called "api" or (2) a sub folder in the root?
If you use cPanel to create subdomain, then the folder "api" will become your document root. In this case:
PHP:
// PRODUCTION - using subdomain
define("ROOT_PATH", "/");
define("ROOT_URL", "https://api.locksdownunder.com/");

If you just copy the folder into the root, try:
PHP:
// PRODUCTION - using folder inside root
define("ROOT_PATH", "/api/");
define("ROOT_URL", "https://locksdownunder.com/api/");
Very likely the second settings are the right for you.
 
Last edited:

aeric

Expert
Licensed User
Longtime User
Okay seems to be all sorted out thank you, and thank you for all your hard work here.
Is there a way to add phpmailer to your code so I can send emails from my gmail account?
Yes. You can replace the SendEmail function to following:
PHP:
    private function SendEmail($user_name, $user_email, $activation_code)
    {
        require 'PHPMailerAutoload.php';

        $mail = new PHPMailer;

        // $mail->SMTPDebug = 3;                               // Enable verbose debug output

        $mail->isSMTP();                                      // Set mailer to use SMTP
        $mail->Host = 'smtp.gmail.com';                          // Specify main SMTP servers
        $mail->SMTPAuth = true;                               // Enable SMTP authentication
        $mail->Username = 'my_gmail_account@gmail.com';       // SMTP username
        $mail->Password = 'xxxxxxxx';                         // SMTP password
        $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
        $mail->Port = 587;                                    // TCP port to connect to

        $mail->setFrom('my_gmail_account@gmail.com', 'Mailer');
        $mail->addAddress($user_email, $user_name);
        // $mail->addReplyTo('xxxxxx@example.com', 'Support');
        // $mail->addCC('cccccc@example.com');
        // $mail->addBCC(ADMIN_EMAIL); // copy to Admin

        $mail->isHTML(true);                                  // Set email format to HTML

        $body = "Hi ".$user_name.",<br/>";
        $body .= "Please click on this link to finish the registration process:<br/>";
        $body .= ROOT_URL."/user/activate/".$activation_code;    

        $mail->Subject = APP_TRADEMARK;
        $mail->Body    = $body;
        $mail->AltBody = "Hi $user_name,\r\n";
        $mail->AltBody .= "Please click on this link to finish the registration process:\r\n";
        $mail->AltBody .= ROOT_URL."/user/activate/".$activation_code;

        if(!$mail->send()) {
            //echo 'Message could not be sent.';
            $msg_text = "[Mailer Error] ".$mail->ErrorInfo;
            $this->LogError("user/activate", $msg_text);
        } else {
            //echo 'Message has been sent';
            $msg_text = $eml;
            $this->LogUser("user/activate", "success", $msg_text, 0);
        }
    }

I get this guide: https://www.pepipost.com/tutorials/send-an-email-via-gmail-smtp-server-using-php/
 
Last edited:

Daniel44

Active Member
Licensed User
Thank you for sharing!
 

IsaacNcho

New Member
J'aimerais savoir pour la connexion d'application B4A et serveur web nécessite une connection internet ?
J'ai eu erreur comme :"failed toi connect toi/My_address_ip_pc(80) from /my_address_ip_phone(port 34534) After 30000ms, Réponse:"
 

aeric

Expert
Licensed User
Longtime User
J'aimerais savoir pour la connexion d'application B4A et serveur web nécessite une connection internet ?
J'ai eu erreur comme :"failed toi connect toi/My_address_ip_pc(80) from /my_address_ip_phone(port 34534) After 30000ms, Réponse:"
No, both the server and B4A can work within your WiFi network or hotspot. Make sure you set the IP address right.
 

winjiadh

Active Member
Licensed User
Longtime User
Hi,aeric
I downloaded your API. Zip file, unzip after uploaded to the VPS, VPS installed Apache Apache2.4.39+ MySQL5.7.26 + php5.6.9,
But the MVC seems installed incorrectly, appeared in the http://test.d99p.cn/views/home/
User (7)
The Password (3)
Click on them, jump to http://test.d99p.cn/views/home/ROOT_URL/user, suggests that cannot find the file, isn't me good MVC is not installed
I set the root directory under the API, set up under the views directory, set in the views/Home directory
Can you teach me?
thank you
 
Last edited:

aeric

Expert
Licensed User
Longtime User
It seems the variables are not replaced correctly.
What is your www directory structure?

Edit: I just saw you are using Nginx. This API requires Apache web server to work with .htaccess
 

winjiadh

Active Member
Licensed User
Longtime User
I WWW directory is the API.zip files are put forward in the stored in the root directory, as shown
And, I changed the Nginx to Apache
 

Attachments

  • api.jpg
    84.8 KB · Views: 287

aeric

Expert
Licensed User
Longtime User
I WWW directory is the API.zip files are put forward in the stored in the root directory, as shown
And, I changed the Nginx to Apache
try change the values in config.php

B4X:
// Define URL

// DEVELOPMENT (local server)
// define("ROOT_PATH", "/api/");
// define("ROOT_URL", "http://127.0.0.1:80/api");

// PRODUCTION - using subdomain
define("ROOT_PATH", "/");
define("ROOT_URL", "http://test.d99p.cn/");

define("DEVELOPMENT", "FALSE");
 

winjiadh

Active Member
Licensed User
Longtime User
yes
I changed,but no run,your can look it in http://test.d99p.cn/
 

Attachments

  • api.jpg
    91.4 KB · Views: 240

winjiadh

Active Member
Licensed User
Longtime User
yes, you are right
now the web is good
I run b4a app to register user in b4a 11.5 and it's error
<b>Fatal error</b>: Call to a member function prepare() on null in <b>C:\FTP\api\api\classes\Model.php</b> on line <b>35</b><br />
 

aeric

Expert
Licensed User
Longtime User
yes, you are right
now the web is good
I run b4a app to register user in b4a 11.5 and it's error
<b>Fatal error</b>: Call to a member function prepare() on null in <b>C:\FTP\api\api\classes\Model.php</b> on line <b>35</b><br />
I suspect something wrong in the db connection.
Make sure you have set up the MySQL username, password and generate the tables using the sql file.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…