Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //VIEW (WHERE I PUT PAYPAL BUTTON)
- <?php include "functions/view_functions.php";?>
- <!DOCTYPE html>
- <html>
- <head>
- <link href="https://fonts.googleapis.com/css?family=Sintony" rel="stylesheet">
- <link rel='stylesheet' href='css/style.css'/>
- <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
- <meta name="My New Car" content="Best Site or App to Buy a Car in Vancouver">
- <meta http-equiv="content-type" content="text/html;charset=UTF-8">
- <meta name=viewport content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
- <title>View my car - detail</title>
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
- <!--Including PayPal API-->
- <script src="https://www.paypalobjects.com/api/checkout.js"></script>
- </head>
- <body>
- <article class="view-bg view-bg-location flex flex-middle flex-center" role="banner">
- <section class="main" id="home">
- <nav role="navigation">
- <ul class="list">
- <li><a href="index.php" class="active">Home</a></li>
- <li><a href="index.php#search">Search</a></li>
- <li><a href="index.php#available">Available Cars</a></li>
- <li><a href="admin/">Admin Sign In</a></li>
- <li><a href="subscriber/">Suscriber Sign In</a></li>
- <li><a href="index.php#contact">Contact</a></li>
- </ul>
- </nav>
- </section>
- </article>
- <section>
- <div class="container" align= "center" id="search">
- <h2 class= "textSearch">View my car detail:</h2>
- <!--
- marianacaldassouza-facilitator@hotmail.com
- AQUXEBTvax8Qpu-CULisSvgtgsrKEsuTMdqWDd_lXR9Jd4GMzUlqhzVua2eZ-BheBfnON7A-Lm0IWyAH
- Production:EOu3H8f4enqyxYbHOs2FVSFKQmzzUoM0hzx-bKECxC4lTxMoUp3DEMaBg1HBg3VUj5uJaXA0zVt_Ml5u
- -->
- <div id="paypal-button-container"></div>
- <?php
- ShowSpecificCar();
- ?>
- </div>
- <div class="footer" id="contact">
- <p class="bottom"><a href="index.php"><- Return to main page</a></p>
- </div>
- </section>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
- <script>
- $("document").ready(function() {
- $(function() {
- $(window).scroll(function () {
- if ($(this).scrollTop() > 50) {
- $("nav").addClass('changeColor')
- $('.list').addClass('center')
- }
- if ($(this).scrollTop() < 50) {
- $('nav').removeClass('changeColor')
- $('.list').removeClass('center')
- }
- });
- });
- });
- </script>
- </body>
- </html>
- //VIEW FUNCTIONS (WHERE I HAVE THE PAYPAL CODE. NOTE YOU NEED TO CREATE A PAYPAL ACCOUNT AND AN APP:
- https://developer.paypal.com/developer/applications/create
- <?php include "connection_db.php";
- function ShowSpecificCar(){
- //We put variables from other places, like $connection, inside a function by using global
- global $connection;
- //This id comes from a link in the function ShowAllCars in index_functions
- $id = $_GET['id'];
- $query = "SELECT * FROM cars WHERE vin=".$id;
- //We use the mysqli built functions to stablish a connection (db.php) and perform the queries in our database.
- $result = mysqli_query($connection, $query);
- if(!$result){
- die("Query failed." . mysqli_error());
- }
- $rowcount=mysqli_num_rows($result);
- if ($rowcount==0){
- echo "<hr/><h2>No car was found!</h2>";
- }else{
- echo '<table class="table">';
- echo "<tr>";
- while($row = mysqli_fetch_assoc($result)){
- ?>
- <script>
- paypal.Button.render({
- env: 'sandbox', // sandbox | production
- // PayPal Client IDs - replace with your own
- // Create a PayPal app: https://developer.paypal.com/developer/applications/create
- client: {
- sandbox: 'AZDxjDScFpQtjWTOUtWKbyN_bDt4OgqaF4eYXlewfBP4-8aqX3PiV8e1GWU6liB2CUXlkA59kJXE7M6R',
- production: 'EOu3H8f4enqyxYbHOs2FVSFKQmzzUoM0hzx-bKECxC4lTxMoUp3DEMaBg1HBg3VUj5uJaXA0zVt_Ml5u'
- },
- // Show the buyer a 'Pay Now' button in the checkout flow
- commit: true,
- // payment() is called when the button is clicked
- payment: function(data, actions) {
- // Make a call to the REST api to create the payment
- return actions.payment.create({
- payment: {
- transactions: [
- {
- amount: { total: '<?php echo number_format($row['price'], 2, '.','');?>', currency: 'USD' }
- }
- ]
- }
- });
- },
- // onAuthorize() is called when the buyer approves the payment
- onAuthorize: function(data, actions) {
- // Make a call to the REST api to execute the payment
- return actions.payment.execute().then(function() {
- window.alert('Payment Complete!');
- });
- }
- }, '#paypal-button-container');
- </script>
- <?php
- echo "<td>";
- echo "<table>";
- echo "<tr>";
- echo "<td>";
- echo '<img width="350" height="200" src="data:image/jpg;base64,'.base64_encode( $row['picture1'] ).'"/>';
- echo '<img width="350" height="200" src="data:image/jpg;base64,'.base64_encode( $row['picture2'] ).'"/>';
- echo '<img width="350" height="200" src="data:image/jpg;base64,'.base64_encode( $row['picture3'] ).'"/>';
- echo "</td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Make: ";
- echo $row['make'];
- echo "</td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Model: ";
- echo $row['model'];
- echo "</td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Year: ";
- echo $row['year'];
- echo "</td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Color: ";
- echo $row['color'];
- echo "</td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Mileage: ";
- echo $row['mileage'];
- echo "</td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Accidents: ";
- echo $row['accidents'];
- echo "</td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Total Damage: ";
- echo "$". number_format($row['totalDamage'], 2, '.','');
- echo "</td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Price: ";
- echo "$". number_format($row['price'], 2, '.','');
- echo "</td>";
- echo "</tr>";
- echo "<tr>";
- echo "<td>Special features: <br/>";
- $specialFeatures = $row['specialFeatures'];
- if(strpos($specialFeatures, 'A' ) !== false ) echo 'AWD<br/>';
- if(strpos($specialFeatures, '4' ) !== false ) echo '4WD<br/>';
- if(strpos($specialFeatures, 'P' ) !== false ) echo 'Power steering<br/>';
- if(strpos($specialFeatures, 'N' ) !== false ) echo 'Navigation<br/>';
- if(strpos($specialFeatures, 'S' ) !== false ) echo 'ABS break<br/>';
- if(strpos($specialFeatures, 'R' ) !== false ) echo 'Panoramic sunroof<br/>';
- if(strpos($specialFeatures, 'T' ) !== false ) echo 'Automatic Transmission<br/>';
- if(strpos($specialFeatures, 'W' ) !== false ) echo 'Winch<br/>';
- echo "</td>";
- echo "</tr>";
- echo "</table>";
- echo "</td>";
- }
- echo "</tr>";
- echo "</table>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement