document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. //Login From DataBase [2 Methods](login.php)
  2. // https://imgur.com/a/fFlF1jE
  3. /*
  4. con.setPost(false);
  5. con.addArgument("name", tnom.getText());
  6. */
  7.  
  8.  
  9. package com.mycompany.myapp;
  10.  
  11. import com.codename1.io.ConnectionRequest;
  12. import static com.codename1.ui.CN.*;
  13. import com.codename1.ui.Display;
  14. import com.codename1.ui.Form;
  15. import com.codename1.ui.Dialog;
  16. import com.codename1.ui.Label;
  17. import com.codename1.ui.plaf.UIManager;
  18. import com.codename1.ui.util.Resources;
  19. import com.codename1.io.Log;
  20. import com.codename1.io.NetworkManager;
  21. import com.codename1.ui.Button;
  22. import com.codename1.ui.TextField;
  23. import com.codename1.ui.Toolbar;
  24. import java.io.IOException;
  25. import com.codename1.ui.layouts.BoxLayout;
  26.  
  27. /**
  28.  * This file was generated by <a href="https://www.codenameone.com/">Codename
  29.  * One</a> for the purpose of building native mobile applications using Java.
  30.  */
  31. public class MyApplication {
  32.    
  33.     private Form current;
  34.     private Resources theme;
  35.    
  36.     public void init(Object context) {
  37.         theme = UIManager.initFirstTheme("/theme");
  38.  
  39.         // Enable Toolbar on all Forms by default
  40.         Toolbar.setGlobalToolbar(true);
  41.  
  42.     }
  43.    
  44.     public void start() {
  45.         if (current != null) {
  46.             current.show();
  47.             return;
  48.         }
  49.         Form hi = new Form("Hi World", BoxLayout.y());
  50.         TextField tnom = new TextField("", "nom");
  51.         TextField tpassword = new TextField("", "password");
  52.         tpassword.setConstraint(TextField.PASSWORD);
  53.         Button btnConne = new Button("connect");
  54.        
  55.         hi.addAll(tnom, tpassword, btnConne);
  56.        
  57.         ConnectionRequest con = new ConnectionRequest();
  58.         btnConne.addActionListener((e) -> {
  59.        
  60.         //Method 1 ( Login From server ) :
  61.        // String url = "http://localhost/codenameoneRessource/login.php?" + "name=" + tnom.getText() + "&password=" + tpassword.getText();
  62.  
  63.             //Method 2 ( Login From server ) :
  64.                String url = "http://localhost/codenameoneRessource/login.php";
  65.                    con.setPost(false);
  66.                    con.addArgument("name", tnom.getText());
  67.                    con.addArgument("password", tpassword.getText());
  68.          
  69.                  
  70.                   con.setUrl(url);
  71.             NetworkManager.getInstance().addToQueueAndWait(con);
  72.         });
  73.        
  74.        
  75.         con.addResponseListener((e) -> {
  76.             String repo = new String(con.getResponseData());
  77.             System.out.println(repo);
  78.            
  79.             if(repo.trim().equalsIgnoreCase("OK"))
  80.             {
  81.             Form f2=new Form();
  82.             f2.add(new Label("Hi Admin You Logged in Successfully !"));
  83.             f2.show();
  84.           f2.getToolbar().addCommandToLeftBar("back",null, ev->{hi.show();});
  85.             }
  86.             else
  87.             {
  88.             Dialog.show("Error","login ou pwd invalid","ok",null);
  89.             }
  90.         });
  91.        
  92.         hi.add(new Label("username : admin , password : admin"));
  93.         hi.show();
  94.     }
  95.    
  96.     public void stop() {
  97.         current = getCurrentForm();
  98.         if (current instanceof Dialog) {
  99.             ((Dialog) current).dispose();
  100.             current = getCurrentForm();
  101.         }
  102.     }
  103.    
  104.     public void destroy() {
  105.     }
  106.    
  107. }
  108.  
  109.  
  110. //login.php Link : https://pastebin.com/Zc08ciaj
  111. //https://i.imgur.com/LB3pRGn.png
');