0

I would like to add $_POST['memo'] which is an array from $ids to my database. It is a script to send payment to paypal.

pre_checkout.php

<table class="table">
                                <thead>
                                    <tr>

 <th>Titre</th>
 <th>Coût</th>
 <th>Quantité choisie</th>
   </tr>
                                </thead>
                                <tbody class="table">
 <?php   $total_price = 0;                                 

 $retour = mysql_query('SELECT * FROM billets_vendus WHERE eventid="'.$_GET['id'].'" ORDER BY id DESC');
 while ($donnees = mysql_fetch_array($retour)) // On fait une boucle pour lister les news.
{
?>
 <tr>
    <?php
    // lancement de la requete
$sql = 'SELECT * FROM event_tickets WHERE id =   "'.$donnees['id_ticket'].'"';

 // on lance la requête (mysql_query) et on impose un message d'erreur si la requête ne se passe pas bien (or die)
 $req = mysql_query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());

 // on recupere le resultat sous forme d'un tableau
 $data = mysql_fetch_array($req);

  $ids[] = $data['id'];
  ?>
  <td><?php echo stripslashes($data['titre']); ?></td>
  <td>$ <?php echo stripslashes($donnees['amount']); ?></td>
  <td> <?php echo stripslashes($donnees['qty']); ?></td>

  </tr>
 <?php

  $total_price += $donnees['amount'] * $donnees['qty'];

  } // Fin de la boucle qui liste les news.
  ?>
  </table>

   <h1>Total : $ <?php echo $total_price;?></h1>


         <form method="post" action="buy/Buy.php" class="commentsForm">
                      <div class="input-group">


                    <input type="hidden" name="amount" id="inp_tw23" value="<?php echo $total_price;?>" class="form-control" >

                    <input type="hidden" name="itemname" id="inp_tw20"  value="<?php echo $ids;?>" class="form-control" >

                    <input type="hidden" name="business" value="<?php echo $_POST['business'];?>">

                    <input type="hidden" name="business2" value="paiement@gaspesia.co">


                    <input type="hidden" name="ticketid" value="<?php echo $id_ticket;?>">

                     <span class="input-group-btn"><input type="submit" value="Procéder au paiement" class="btn btn-green"></span>
                </div>
            </form>

And the code for add to database (IPN PAYPAL):

  $ids=$_POST['memo'];


 foreach($ids as $id => $where){
mysql_query("UPDATE billets_vendus SET status_payment='1' WHERE id_ticket = '$where'") or die(mysql_error());
   }

Thank you! It would be very appreciated to help me.

Alex Bond
  • 19
  • 5
  • 1
    If you can, you should [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) [statements](http://php.net/manual/en/pdo.prepared-statements.php) instead, and consider using PDO, [it's really not hard](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Jun 17 '15 at 15:35
  • In your form, I see no reference to `name="memo"` nor `id="memo"`. Where is `$_POST['memo']` defined? – Twisty Jun 17 '15 at 19:05
  • memo = itemname. Paypal create the value from itemname – Alex Bond Jun 17 '15 at 20:19

0 Answers0