Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.91 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
  4. ini_set('display_errors' , 1);
  5. include (  "account.php"     ) ;
  6. $db = mysqli_connect($hostname, $user, $pass, $project);
  7. if (mysqli_connect_errno())
  8.   {
  9.       echo "Failed to connect to MySQL: " . mysqli_connect_error();
  10.       exit();
  11.   }
  12. mysqli_select_db($db, $project);
  13. print "Successfully connected to MySQL.<br><br><br>";
  14.  
  15.  
  16. function auth ($user, $pass ) {
  17.         global $db;
  18.         $s = " select * from A where user = '$user' and pass = '$pass' ";
  19.        
  20.         $t = mysqli_query($db, $s);
  21.         $num =  mysqli_num_rows($t);
  22.         if ($num > 0) {
  23.                 echo"<br><br>Credentials are verified<br><br>";
  24.                 return true;
  25.         } else {
  26.                 return false ;
  27.         }
  28. }
  29.  
  30.  
  31. function getdata ($name, &$result) {
  32.     global $bad;
  33.     global $db;
  34.    
  35.     if(!isset($_GET [$name])){
  36.                 $bad = true;
  37.                 echo "Bad credentials";
  38.                 return;
  39.    
  40.     }
  41.     $temp = $_GET [ $name ] ;
  42.             //$temp   = mysqli_real_escape_string ( $db,  $temp );
  43.             $result = $temp;
  44. }
  45.  
  46.  
  47.  
  48. $bad  = false ;
  49. getdata ( "user" , $user );
  50. getdata ( "pass" , $pass );
  51. print "Hello <br>";
  52. print "User is: $user <br>";
  53. print "Pass is: $pass <br>";
  54. if ( $bad ) { exit ("Incorrect Input"); }
  55.  
  56. if (!auth(  $user,  $pass   )){exit("Bad Credentials"); }
  57.  
  58. echo 'Good Bye!' ;
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. $s = "select * from A";
  66.  
  67. print "SQL query is: $s <br> ";
  68.  
  69.  
  70.  
  71. $t = mysqli_query ($db, $s);
  72.  
  73. print "<br> Number rows is: " . mysqli_num_rows($t);
  74.  
  75.  
  76.  
  77. while ( $r = mysqli_fetch_array($t, MYSQL_ASSOC) ) {
  78.  
  79. $user = $r  ["user"];
  80.  
  81. $mail = $r ["mail"];
  82.  
  83. $current = $r ["cur_balance"];
  84.  
  85. print "<br>User is $user || $mail || Current Balance: $current";   
  86.  
  87. }
  88.  
  89. function mailer ( $user , $out ) {
  90.  
  91.     $to = "cjm86@mailinator.com" ;
  92.     $subject = "hello 10 4 2017";
  93.     $message = $out;
  94.    
  95.     $to = "cjm86@mailinator.com" ;
  96.     $subject = "hello 10 4 2017";
  97.     $message = $out;
  98.    
  99.     if (isset($_GET ["emailresults"]) &&
  100.          $_GET["emailresults"] == true)
  101.     {
  102.          echo "Mail was requested" ;
  103.     }
  104.     else
  105.     {
  106.         echo "Mail was NOT requested" ;
  107.     }
  108.    
  109.    
  110.     mail( $to , $subject, $message );
  111. }
  112.  
  113. function show ( $user , &$out ) {
  114.     global $db;
  115.    
  116.     $s  =   "select * from A " ;
  117.     $out = "<br>SQL statement is: $s<br>";
  118.     ($t = mysqli_query( $db, $s) ) or die( mysqli_error($db) );
  119.     while ( $r = mysqli_fetch_array($t,MYSQLI_ASSOC) ) {
  120.         $user           =$r[ "user"];
  121.         $cur_balance    =$r[ "cur_balance" ];
  122.         $out .="User is $user<br>";
  123.         $out .="cur_balance is $cur_balance<br><br>";
  124.     };
  125.     echo $out;
  126. }
  127. include (  "account.php"     ) ;
  128. $db = mysqli_connect($hostname,$user, $pass ,$project);
  129. if (mysqli_connect_errno())
  130.   {
  131.       echo "Failed to connect to MySQL: " . mysqli_connect_error();
  132.       exit();
  133.   }
  134. print "<br>Successfully connected to MySQL.<br>";
  135. mysqli_select_db( $db, $project );
  136.  
  137.  
  138.  
  139. $user = $_GET [ "user" ] ;   print "<br>user is: $user";
  140.  
  141. show ( $user , $out) ;
  142. mailer ( $user , $out );
  143.  
  144.  
  145.  
  146. print "<br> <br>Bye <br>";
  147.  
  148. print "Interaction completed."
  149.  
  150. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement