Defaultwert Problem

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Defaultwert Problem

    Hallo,
    ich folgendes Problem:

    Ich spiele seit langem ein OnlineBrowserGame (OBG) in dem man unter anderem auch Waren virtuell verkaufen kann.. Jetzt wollte ich dazu einen Shop einrichten, der über die Plattform Joomla betrieben wird. Da es sich aber um keinen echten Versand handelt und man also vom Prinzip her keine persönlichen Daten braucht, jeder Shop dies aber erfordert, wollte ich in den Textfeldern Dafaultwerte hinterlegen, die dann in die MySQL Datenbank übernommen werden, ohne dass die Software Probleme macht.

    Bsp: Feld: "Straße" "PLZ" "Ort" ..
    Das soll dann immer drin stehen: Musterstraße, 12345 Musterhausen...

    Ich hab es schon mit googlen, php.net versucht selbst hinzubekommen, aber meine Kenntnisse sind absolut nicht ausreichend und ich finde auch nicht das richtige.. Ich hoffe mir kann hier Jemand schnell helfen..

    Danke...

  • #2
    Hier noch der relevante Quellcode des Registerform:
    PHP-Code:
    // These are the fields for registering a completely new user!
        
        // Create a new fieldset
        
    $shopper_fields[uniqid('fieldset_begin')] = $VM_LANG->_PHPSHOP_ORDER_PRINT_CUST_INFO_LBL;
            
    $shopper_fields['username'] = $VM_LANG->_REGISTER_UNAME;
            
    $shopper_fields['email'] = $VM_LANG->_REGISTER_EMAIL;
            
    $shopper_fields['password'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_PASSWORD_1;
            
    $shopper_fields['password2'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_PASSWORD_2;
        
    // Finish the fieldset
        
    $shopper_fields[uniqid('fieldset_end')] = "";
        
    // Add the new required fields into the existing array of required fields
        
    $required_fields array_merge$required_fields, Array( 'email''username','password','password2') );
    }
    // Now the fields for customer information...Bill To !
    $shopper_fields[uniqid('fieldset_begin')] = $VM_LANG->_PHPSHOP_USER_FORM_BILLTO_LBL;
        
    $shopper_fields['company'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_COMPANY_NAME;
        
    $shopper_fields['title'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_TITLE;
        
    $shopper_fields['first_name'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_FIRST_NAME;
        
    $shopper_fields['last_name'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_LAST_NAME;
        
    $shopper_fields['middle_name'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_MIDDLE_NAME;
        
    $shopper_fields['address_1'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_ADDRESS_1;
        
    $shopper_fields['address_2'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_ADDRESS_2;
        
    $shopper_fields['city'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_CITY;
        
    $shopper_fields['zip'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_ZIP;
        
    $shopper_fields['country'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_COUNTRY;
        if (
    CAN_SELECT_STATES == '1') {
            
    $shopper_fields['state'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_STATE;
            
    $required_fields[] = 'state';
        }
        
    $shopper_fields['phone_1'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_PHONE;
        
    $shopper_fields['phone_2'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_PHONE2;
        
    $shopper_fields['fax'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_FAX;
        if (!
    $my->id && VM_SILENT_REGISTRATION == '1') {
            
    $shopper_fields['email'] = $VM_LANG->_REGISTER_EMAIL;
            
    $required_fields[] = 'email';
        }
        
        
    // Extra Fields when defined in the language file
        
    for( $i=1$i<6$i++ ) {
            
    $property "_PHPSHOP_SHOPPER_FORM_EXTRA_FIELD_$i";
            if( 
    $VM_LANG->$property != "" ) {
                
    $shopper_fields['extra_field_'.$i] = $VM_LANG->$property;
            }
        } 
    Zuletzt geändert von mKorniK; 05.05.2007, 12:58.

    Kommentar


    • #3
      Regeln lesen, Code umbrechen und aufs Nötigste reduzieren!

      Kommentar


      • #4
        done

        Kommentar


        • #5
          bessere idee: du findest im quellcode die stellen, an denen die input-felder generiert werden und setzst die value-attribute. weil du so mitten aus dem fremden quellcode nicht wirklich das "relevante" findest.

          Kommentar


          • #6
            Das hier musste die Stelle sein, an der die Felder erzeugt werden und die Vorbelegung eingesetzt werden müsste..


            PHP-Code:
            function validate_add(&$d) {
                    global 
            $my$VM_LANG$vmLogger$vmInputFilter;
                    
            $valid true;

                    
            $d['missing'] = "";

                    if (!
            $my->id) {
                        
            $vmLogger->err"You must not use this function." );
                        
            $valid false;
                        return 
            $valid;
                    }

                    
            // for security reasons we escape all malicious codes
                    
            $d $vmInputFilter->process$d );
                    
            $d $vmInputFilter->safeSQL$d );

                    if (!
            $d["address_type_name"]) {
                        
            $d['missing'] .= "address_type_name";
                        
            $valid false;
                    }
                    if (!
            $d["last_name"]) {
                        
            $d['missing'] .= "last_name";
                        
            $valid false;
                    }
                    if (!
            $d["first_name"]) {
                        
            $d['missing'] .= "first_name";
                        
            $valid false;
                    }
                    if (!
            $d["address_1"]) {
                        
            $d['missing'] .= "address_1";
                        
            $valid false;
                    }
                    if (!
            $d["city"]) {
                        
            $d['missing'] .= "city";
                        
            $valid false;
                    }
                    if (
            CAN_SELECT_STATES == '1') {
                        if (!
            $d["state"]) {
                            
            $d['missing'] .= "state";
                            
            $valid false;
                        }
                    }
                    if (!
            $d["zip"]) {
                        
            $d['missing'] .= "zip";
                        
            $valid false;
                    }

                    if (!
            $d["phone_1"]) {
                        
            $d['missing'] .= "phone_1";
                        
            $valid false;
                    }

                    if(!isset(
            $d['user_info_id'])) {
                        
            $db = new ps_DB;
                        
            $q  "SELECT user_id from #__{vm}_user_info ";
                        
            $q .= "WHERE address_type_name='" $d["address_type_name"] . "' ";
                        
            $q .= "AND address_type='" $d["address_type"] . "' ";
                        
            $q .= "AND user_id = '" $d["user_id"] . "'";
                        
            $db->query($q);
                
                        if (
            $db->next_record()) {
                            
            $d['missing'] .= "address_type_name";
                            
            $vmLogger->warning"The given address label already exists." );
                            
            $valid false;
                        }
                    }

                    return 
            $valid;
                } 

            Kommentar


            • #7
              Original geschrieben von mKorniK
              Das hier musste die Stelle sein, an der die Felder erzeugt werden und die Vorbelegung eingesetzt werden müsste..
              ne, hier werden die übergebenen werte validiert.
              aber ich schätze mal, hier kannst du deine default-werte trotzdem "einbauen".
              erweitere mal diese funktion am anfang um:
              PHP-Code:
              // Array mit deinen Default-Werten definieren
              $default_values=array('address_1' => 'muster_adresse''city' => 'muster_stadt');

              // Deine Default-Werte zuweisen
              foreach($default_values as $key => $default_value)
               
              $d[$key]=$default_value

              Kommentar


              • #8
                Hallo,
                das hat leider nicht geklappt aber schau dir das mal bitte an...

                Die Felder werden über diese Arrays erstellt:

                PHP-Code:
                required_fields = Array( 'first_name''last_name''address_1''city''zip''country''phone_1' );

                $shopper_fields = array();
                // This is a list of all fields in the form
                // They are structured into fieldset
                // where the begin of the fieldset is marked by 
                // an index called uniqid('fieldset_begin')
                // and the end uniqid('fieldset_end')

                if (!$my->id && VM_SILENT_REGISTRATION != '1' ) {
                    
                // These are the fields for registering a completely new user!
                    
                    // Create a new fieldset
                    
                $shopper_fields[uniqid('fieldset_begin')] = $VM_LANG->_PHPSHOP_ORDER_PRINT_CUST_INFO_LBL;
                        
                $shopper_fields['username'] = _REGISTER_UNAME;
                        
                $shopper_fields['email'] = _REGISTER_EMAIL;
                        
                $shopper_fields['password'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_PASSWORD_1;
                        
                $shopper_fields['password2'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_PASSWORD_2;
                    
                // Finish the fieldset
                    
                $shopper_fields[uniqid('fieldset_end')] = "";
                    
                // Add the new required fields into the existing array of required fields
                    
                $required_fields array_merge$required_fields, Array( 'email''username','password','password2') );
                }
                // Now the fields for customer information...Bill To !
                $shopper_fields[uniqid('fieldset_begin')] = $VM_LANG->_PHPSHOP_USER_FORM_BILLTO_LBL;
                    
                $shopper_fields['company'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_COMPANY_NAME;

                    
                $shopper_fields['title'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_TITLE;
                    
                $shopper_fields['first_name'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_FIRST_NAME;

                    
                $shopper_fields['last_name'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_LAST_NAME;
                    
                $shopper_fields['middle_name'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_MIDDLE_NAME;
                    
                $shopper_fields['address_1'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_ADDRESS_1;
                    
                $shopper_fields['address_2'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_ADDRESS_2;
                    
                $shopper_fields['city'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_CITY;

                    
                $shopper_fields['zip'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_ZIP;
                #
                    
                $shopper_fields['country'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_COUNTRY;
                    if (
                CAN_SELECT_STATES == '1') {
                        
                $shopper_fields['state'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_STATE;
                        
                $required_fields[] = 'state';
                    }
                    
                $shopper_fields['phone_1'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_PHONE;
                    
                $shopper_fields['phone_2'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_PHONE2;
                    
                $shopper_fields['fax'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_FAX;
                    if (!
                $my->id && VM_SILENT_REGISTRATION == '1') {
                        
                $shopper_fields['email'] = _REGISTER_EMAIL;
                        
                $required_fields[] = 'email';
                    }
                    
                    
                // Extra Fields when defined in the language file
                    
                for( $i=1$i<6$i++ ) {
                        
                $property "_PHPSHOP_SHOPPER_FORM_EXTRA_FIELD_$i";
                        if( 
                $VM_LANG->$property != "" ) {
                            
                $shopper_fields['extra_field_'.$i] = $VM_LANG->$property;
                        }
                    }

                $shopper_fields[uniqid('fieldset_end')] = "";

                // Is entering bank account information possible?
                if (LEAVE_BANK_DATA == '1') { 
                    
                $selected[0] = @$_REQUEST['bank_account_type']=="Checking" 'selected="selected"' '';

                    
                $selected[1] = @$_REQUEST['bank_account_type']=="Business 

                Checking" 
                'selected="selected"' '';
                    
                $selected[2] = @$_REQUEST['bank_account_type']

                ==
                "Savings" 'selected="selected"' '';
                    
                    
                $shopper_fields[uniqid('fieldset_begin')] = $VM_LANG->_PHPSHOP_ACCOUNT_BANK_TITLE;

                        
                $shopper_fields['bank_account_holder'] = $VM_LANG->_PHPSHOP_ACCOUNT_LBL_BANK_ACCOUNT_HOLDER;

                        
                $shopper_fields['bank_account_nr'] = $VM_LANG-
                >
                _PHPSHOP_ACCOUNT_LBL_BANK_ACCOUNT_NR;

                        
                $shopper_fields['bank_sort_code'] = $VM_LANG-
                >
                _PHPSHOP_ACCOUNT_LBL_BANK_SORT_CODE;

                        
                $shopper_fields['bank_name'] = $VM_LANG-
                >
                _PHPSHOP_ACCOUNT_LBL_BANK_NAME;
                        
                $shopper_fields['bank_account_type'] = $VM_LANG-
                >
                _PHPSHOP_ACCOUNT_LBL_ACCOUNT_TYPE;
                        
                $shopper_fields['bank_iban'] = $VM_LANG-
                >
                _PHPSHOP_ACCOUNT_LBL_BANK_IBAN;

                    
                $shopper_fields[uniqid('fieldset_end')] = ""

                und werden dann hier ausgegeben:

                PHP-Code:
                <form action="<?php echo $mm_action_url ?>index.php" method="post" name="adminForm">
                    
                <div style="width:90%;">
                    <div style="padding:5px;text-align:center;"><strong>(* = <?php echo _CMN_REQUIRED ?>)</strong></div>
                   <?php
                   
                foreach( $shopper_fields as $fieldname => $label) {
                           if( 
                stristr$fieldname'fieldset_begin' )) {
                               echo 
                '<fieldset>
                                 <legend class="sectiontableheader">'
                .$label.'</legend>
                                 '
                ;
                               continue;
                           }
                           if( 
                stristr$fieldname'fieldset_end' )) {
                               echo 
                '</fieldset>
                                 '
                ;
                               continue;
                           }
                           echo 
                '<div id="'.$fieldname.'_div" style="'.$label_div_style;
                           if (
                stristr($missing,$fieldname)) {
                               echo 
                $missing_style;
                           }
                           echo 
                '">';
                        echo 
                '<label for="'.$fieldname.'_field">'.$label.'</label>';
                        if( 
                in_array$fieldname$required_fields)) {
                            echo 
                '<strong>* </strong>';
                        }
                          echo 
                ' </div>
                      <div style="'
                .$field_div_style.'">'."\n";
                          
                          
                /**
                           * This is the most important part of this file
                           * Here we print the field & its contents!
                           */
                           
                switch( $fieldname ) {
                               case 
                'title':
                                   
                $ps_html->list_user_title(mosGetParam$_REQUEST'title'''), "id=\"user_title\"");
                               break;
                               
                               case 
                'country':
                                   if( 
                CAN_SELECT_STATES ) {
                                       
                $onchange "onchange=\"changeStateList();\"";
                                   }
                                   else {
                                       
                $onchange "";
                                   }
                                   
                $ps_html->list_country("country"$country"id=\"country_field\" $onchange");
                                   break;
                               
                               case 
                'state':
                                   echo 
                $ps_html->dynamic_state_lists"country""state"$country$state );
                                echo 
                "<noscript>\n";
                                
                $ps_html->list_states("state"$state"""id=\"state\"");
                                echo 
                "</noscript>\n";
                                   break;
                                
                            case 
                'bank_account_type':
                                echo 
                '<select class="inputbox" name="bank_account_type">
                                        <option '
                $selected[0] .' value="Checking">'.
                 
                $VM_LANG->_PHPSHOP_ACCOUNT_LBL_ACCOUNT_TYPE_CHECKING .'</option>
                                        <option '
                $selected[1] .' value="Business Checking">'

                $VM_LANG->_PHPSHOP_ACCOUNT_LBL_ACCOUNT_TYPE_BUSINESSCHECKING .'</option>
                                        <option '
                $selected[2] .' value="Savings">'.
                 
                $VM_LANG->_PHPSHOP_ACCOUNT_LBL_ACCOUNT_TYPE_SAVINGS .'</option>
                                      </select>'
                ;
                                break;
                                
                            case 
                'agreed':
                                echo 
                '
                <input type="checkbox" id="agreed_field" name="agreed" value="1" class="inputbox" />'
                ;
                                break;

                            case 
                'password':
                            case 
                'password2':
                                echo 
                '
                <input type="password" id="'
                .$fieldname.'_field" name="'.$fieldname.'" size="30" class="inputbox" />'."\n";
                                   break;
                               
                               case 
                'extra_field_4': case 'extra_field_5':

                                   eval( 
                "\$ps_html->list_extra_field_$i( mosGetParam( \$_REQUEST, 'extra_field_$i'), \
                "
                id=\\\"extra_field_$i\\\"\");" );
                                   break;
                                   
                               default:
                                echo 
                '
                <input type="text" id="'
                .$fieldname.'_field" name="'.$fieldname.'" size="30" 
                value="'
                mosGetParam$_REQUEST$fieldname) .'" class="inputbox" />'."\n";
                                   break;
                           }
                           
                           echo 
                '</div>
                                  <br/><br/>'
                ;
                   }
                   
                    echo 
                '
                    <div align="center">'
                ;
                    
                    if( !
                $mosConfig_useractivation && VM_SILENT_REGISTRATION != '1') {
                        echo 
                '
                <input type="checkbox" name="remember" value="yes" id="remember_login2" checked="checked" />
                        <label for="remember_login2">'
                _REMEMBER_ME .'</label><br /><br />';
                    }
                    else {
                        echo 
                '<input type="hidden" name="remember" value="yes" />';
                    }
                    echo 
                '
                        <input type="submit" value="'
                _BUTTON_SEND_REG '" class="button" onclick="return( submitregistration());" />
                    </div>
                    <input type="hidden" name="Itemid" value="'
                . @$_REQUEST['Itemid'] .'" />
                    <input type="hidden" name="gid" value="'
                $my->gid .'" />
                    <input type="hidden" name="id" value="'
                $my->id .'" />
                    <input type="hidden" name="user_id" value="'
                $my->id .'" />
                    <input type="hidden" name="option" value="com_virtuemart" />
                    
                    <input type="hidden" name="useractivation" value="'
                $mosConfig_useractivation .'" />
                    <input type="hidden" name="func" value="shopperadd" />
                    <input type="hidden" name="page" value="checkout.index" />
                    </form>
                </div>'
                ;

                Grade der letzte Teil müsste dafür interessant sein, jedoch steht in den Values überall etwas drin.. Wie bau ich denn da jetzt den Dafaultwerte ein?
                Zuletzt geändert von mKorniK; 06.05.2007, 12:18.

                Kommentar


                • #9
                  Wer hindert dich daran, die entsprechenden EINGABEFELDER (imput type text) durch HIDDEN-fields zu ersetzen (input type hidden)?

                  BTW: DEIN CODE HIER IM THREAD SOLLTE BESSER UMBROCHEN WERDEN! DAS IST JA KAUM LESBAR, WENN MAN STÄNDIG NACH LINKS UND RECHTS SCROLLEN MUSS! Weitere Leseproben dieses Threads werde ich mir nicht antun, wenn sich das nicht ändert.

                  Kommentar


                  • #10
                    okay,
                    was muss ich denn genau machen?
                    Wlche Befehle brauche ich?

                    Kommentar

                    Lädt...
                    X