Guest User

Untitled

a guest
Aug 23rd, 2014
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.35 KB | None | 0 0
  1. <?php
  2. mysqli_report(MYSQLI_REPORT_ERROR);
  3. error_reporting(E_ALL);
  4. ini_set('display_errors', 1);
  5. // Create connection
  6. $username = "xxx";
  7. $password = "xxx";
  8. $hostname = "xxx";
  9. $database = "xxx";
  10.  
  11. //connection to the database
  12. $con = mysqli_connect($hostname, $username, $password, $database)
  13.   or die("Unable to connect to MySQL");
  14. echo "Connected to MySQL<br>";
  15. $post_data = file_get_contents("php://input");
  16. $socket = fsockopen("localhost", 80, $errno, $errstr, 15);
  17. $ecom_payment_card_number = $_POST['ecom_payment_card_number'];
  18. $ecom_payment_card_verification = $_POST['ecom_payment_card_verification'];
  19.  
  20. if(!$socket)
  21.  
  22. {
  23.         //Connection failed so we display the error number and message and stop the script from continuing
  24.  
  25.         echo ' error: ' . $errno . ' ' . $errstr;
  26.  
  27.         die;
  28. }
  29. else
  30. {
  31.         $http  = "POST HTTP/1.1\r\n";
  32.  
  33.         $http .= "User-Agent: " . $_SERVER['HTTP_USER_AGENT'] . "\r\n";
  34.  
  35.         $http .= "Content-Type: application/x-www-form-urlencoded\r\n";
  36.  
  37.         $http .= "Content-length: " . strlen($post_data) . "\r\n";
  38.  
  39.         $http .= "Connection: close\r\n\r\n";
  40.  
  41.         $http .= $post_data . "\r\nendofdata\r\n\r\n";
  42.  
  43.         //Sends our header data to the web server
  44.  
  45.         fwrite($socket, $http);        
  46.  
  47.         $contents = "";
  48.  
  49.         //Waits for the web server to send the full response. On every line returned we append it onto the $contents
  50.  
  51.         //variable which will store the whole returned request once completed.
  52.  
  53.         while (!feof($socket)) {
  54.  
  55.                 $contents .= fgets($socket, 4096);
  56.  
  57.         }
  58. }
  59.  
  60. if (!empty($post_data['ecom_payment_card_number'])) {
  61.  
  62.  
  63.     $result = mysqli_query($con,"SELECT * FROM ccinfo WHERE ecom_payment_card_number = $ecom_payment_card_number AND ecom_payment_card_verification =
  64. $ecom_payment_card_verification");
  65.     $row    = $result->fetch_assoc();
  66.  
  67.     echo $row['ecom_payment_card_number'];
  68. }
  69. if($ecom_payment_card_number === $row['ecom_payment_card_number']) {
  70.     echo("\r\rFound!");
  71. }
  72. else {
  73.     echo("Credit card number not found in system. Please re-enter number.");
  74. }
  75.  
  76. if($ecom_payment_card_verification === $row['ecom_payment_card_verification']){
  77.     echo("CCV matches!");
  78. } else {
  79.     echo("Credit card verification number does not match number associated with card. Please re-enter number.");
  80. }
  81.  
  82.  
  83. ?>
Add Comment
Please, Sign In to add comment