IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

EDI, CMS, Outils, Scripts et API PHP Discussion :

[osCommerce] Insérer le contenu d'un champ


Sujet :

EDI, CMS, Outils, Scripts et API PHP

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    78
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 78
    Points : 46
    Points
    46
    Par défaut [osCommerce] Insérer le contenu d'un champ
    Bonsoir tous le monde

    Voilla trois jours que j'essaye de récupéré le contenue d'un champ pour l'inséré dans ma base de donnée order.

    donc voila mes champ dans le fichier cc
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
     
      $confirmation = array('id' => $this->code,
                             'module' => $this->title,
                             'fields' => array(array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_OWNER,
                                                     'field' => tep_draw_input_field('$cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'])),
                                              array('title' => MODULE_PAYMENT_CC_TEXT_MENS,
                                                    'field' =>  tep_draw_pull_down_menu('$cc_mens',$montants_array, $mens_selected)), 
                                               array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_NUMBER,
                                                     'field' => tep_draw_input_field('$cc_number')),
                                               array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_EXPIRES,
                                                     'field' => tep_draw_pull_down_menu('$cc_expires_month', $expires_month) . ' ' . tep_draw_pull_down_menu('cc_expires_year', $expires_year))));
     
     
          return $confirmation;
        }
    Ces champs plus loin dans le même fichier enregister en global
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
     function process_button() {
     
          global $HTTP_POST_VARS;
     
     
          include(DIR_WS_CLASSES . 'cc_validation.php');
     
          $cc_validation = new cc_validation();
          $result = $cc_validation->validate($HTTP_POST_VARS['cc_number'], $HTTP_POST_VARS['cc_mens'], $HTTP_POST_VARS['cc_expires_month'], $HTTP_POST_VARS['cc_expires_year']);
     
     
          $this->cc_card_type = $cc_validation->cc_type;
          $this->cc_card_number = $cc_validation->cc_number;
     
          $process_button_string = tep_draw_hidden_field('cc_owner', $HTTP_POST_VARS['cc_owner']) .
                                   tep_draw_hidden_field('cc_mens', $HTTP_POST_VARS['cc_mens']) .
                                   tep_draw_hidden_field('cc_expires', $HTTP_POST_VARS['cc_expires_month'] . $HTTP_POST_VARS['cc_expires_year']) .
                                   tep_draw_hidden_field('cc_type', $HTTP_POST_VARS['cc_mens']) .
                                   tep_draw_hidden_field('cc_number', $this->cc_card_number);
     
          return $process_button_string;
        }
     
        function before_process() {
          global $HTTP_POST_VARS, $order;
     
     
     
          if ( (defined('MODULE_PAYMENT_CC_EMAIL')) && (tep_validate_email(MODULE_PAYMENT_CC_EMAIL)) ) {
            $len = strlen($HTTP_POST_VARS['cc_number']);
     
            $this->cc_middle = substr($HTTP_POST_VARS['cc_number'], 17, ($len-8));
            $order->info['cc_number'] = substr($HTTP_POST_VARS['cc_number'], 0, 17) . str_repeat('X', (strlen($HTTP_POST_VARS['cc_number']) - 17)) . substr($HTTP_POST_VARS['cc_number'], -17);
          }
        }
    puis on inclus et enregistre les donner grâce a la classe order_carte

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    function after_process() {
          global $insert_id;
           require(DIR_WS_CLASSES . 'order_carte.php');
     
           $sql_data_array = array('cc_type' => $order_carte->carte['cc_type'], 
                              'cc_owner' => $order_carte->carte['cc_owner'], 
                              'cc_number' => $order_carte->carte['cc_number'], 
                              'cc_expires' => $order_carte->carte['cc_expires']);
      tep_db_perform(TABLE_ORDERS, $sql_data_array);
    voici order_carte
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    <?php
    /*
      $Id: order_carte.php,v 1.1.1.1 2009/04/16 19:03:49 wilt Exp $
    
      osCommerce, Open Source E-Commerce Solutions
      http://www.oscommerce.com
    
      Copyright (c) 2003 osCommerce
    
      Released under the GNU General Public License
      
      Badibad
    */
     
    tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$orders_id . "'"); 
    tep_db_query('INSERT INTO `orders`(cc_type, cc_owner, cc_number, cc_expires) VALUES ("cc_type", "cc_owner", "cc_number", "cc_expires")'); 
     
     
    class order_carte 
    {
        var $carte;
     
        function order_carte($oID) {
          $this->carte = array();
          $this->query($oID);
        }
         function query($oID) {
     
        $order_invoice_query  = tep_db_query("select cc_type, cc_owner, cc_number, cc_expires from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
          $order_carte = tep_db_fetch_array($order_invoice_query);
     
        $this->carte = array('cc_type' => $order_carte['cc_type'],
                              'cc_owner' => $order_carte['cc_owner'],
                              'cc_number' => $order_carte['cc_number'],
                              'cc_expires' => $order_carte['cc_expires']);
     }
    }
     
    ?>
    mais malheureusement ca ne marche pas et je ne comprend pas pourquoi.

    Merci d'avance

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Il faudrait que tu nous cibles un peu le problème plutot que nous donner plein de bouts de code.

    En regardant juste comme ca :

    - $HTTP_POST_VARS n'est plus utilisé depuis PHP4.1 je crois, il est remplacé par $_POST et est toujours global.

    - Qu'est censé faire cette ligne ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    tep_db_query('INSERT INTO `orders`(cc_type, cc_owner, cc_number, cc_expires) VALUES ("cc_type", "cc_owner", "cc_number", "cc_expires")');
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    78
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 78
    Points : 46
    Points
    46
    Par défaut
    Merci de ta réponse

    En faite je cherche à recupéré le contenue des champ pour l'inseré dans ma bd

    Ca c'est les champs que les clients remplisse
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    $confirmation = array('id' => $this->code,
                             'module' => $this->title,
                             'fields' => array(array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_OWNER,
                                                     'field' => tep_draw_input_field('$cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'])),
                                              array('title' => MODULE_PAYMENT_CC_TEXT_MENS,
                                                    'field' =>  tep_draw_pull_down_menu('$cc_mens',$montants_array, $mens_selected)), 
                                               array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_NUMBER,
                                                     'field' => tep_draw_input_field('$cc_number')),
                                               array('title' => MODULE_PAYMENT_CC_TEXT_CREDIT_CARD_EXPIRES,
                                                     'field' => tep_draw_pull_down_menu('$cc_expires_month', $expires_month) . '&nbsp;' . tep_draw_pull_down_menu('cc_expires_year', $expires_year))));
    et ca c'est pour inséré le contenu des champ dans la BD (enfin ca devrai)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    tep_db_query('INSERT INTO `orders`(cc_type, cc_owner, cc_number, cc_expires) VALUES ("cc_type", "cc_owner", "cc_number", "cc_expires")');
    je suis désolé si je ne suis pas clair mais si je met tous on code ca risque d'être trop long.

  4. #4
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Que fais la fonction tep_db_query ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Septembre 2009
    Messages
    78
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2009
    Messages : 78
    Points : 46
    Points
    46
    Par défaut désolé
    HA Dédolé c'est une fonction de oscommerce

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
     function tep_db_query($query, $link = 'db_link') {
        global $$link;
     
        if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {
          error_log('QUERY ' . $query . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
        }
     
        $result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error());
     
        if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {
           $result_error = mysql_error();
           error_log('RESULT ' . $result . ' ' . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
        }
     
        return $result;
      }
    merci

Discussions similaires

  1. Réponses: 1
    Dernier message: 07/09/2011, 10h33
  2. Réponses: 5
    Dernier message: 02/05/2009, 20h42
  3. Réponses: 4
    Dernier message: 23/01/2009, 18h57
  4. Insérer le contenu d'un champ texte dans un JavaScript
    Par yoyot dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 17/02/2005, 14h12
  5. Recuperer le contenu d'un champs texte
    Par bouboussjunior dans le forum ASP
    Réponses: 4
    Dernier message: 29/09/2004, 14h16

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo