Thread Verfasser: Catzenjaeger
Thread ID: 910
Thread Info
Es gibt 3 Beiträge zu diesem Thema, und es wurde 1681 Mal angesehen.
 Thema drucken
Daten in DB schreiben ...
Catzenjaeger
Ich verzweifle gleich
gasnz easy baue ich ein Sctipt auf wo von eimem Form Daten in die DB gespeichert werden soll.

Bei meinem Code wird aber n ur die ID vergeben und die CAT gespeichert .. der Title wird nicht gespeichert und ich weiss nicht warum.
Die Datenbank hat etwa 30 spalten ich will z,um Test aber nur der ersten mal füllen

was mache ich falsch?

Code
<?php

/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2011 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: submit.php
| Author: Nick Jones (Digitanium)
| Co-author: Khalid545
|
| URL: http://khalidb.co.cc/
| E-Mail: khalidd545@gmail.com 
| URL: http://khalidb.co.cc/
|
| Modification: Catzenjaeger
| URL: www.aliencollectors.com
| E-Mail: admin@aliencollectors.com
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "../../maincore.php";
require_once THEMES."templates/header.php";
require_once INCLUDES."bbcode_include.php";

// SYSTEMDATEI
include "infusion_db.php";
// POPUPS BEI FEHLER ODER NICHT AUFGEFÜLLTEN FELDERN
include "includes/popups.php";
// CSS FÜR DIE POPUPS / CSS FÜR DIE HINWEISE
include "includes/css.php";
// AUSGELAGERTE FUNKTIONEN
//include "classes/functions_submit.php";
// SETTINGS SUBMIT
include "includes/settings_submit.php";

if (!iMEMBER) { redirect("figure.php"); }

$result = dbquery("SELECT * FROM ".DB_FIGURE_CATS);
if (dbrows($result) && $asettings['figure_submit'] == "1") {
   if (isset($_GET['status']) && !isset($message)) {
      if ($_GET['status'] == "sn") {
         $message = $locale['figure_524'];
      } elseif ($_GET['status'] == "se") {
      // The following error occured 113 //
         $message = $locale['figure_113']."<br />\n<span class='small'>";
      
      // Figure title cannot be left empty 117 //   
         if ($_GET['error'] == 0) { $message .= $locale['figure_117']."</span>"; }      
      // Invalid filename //
         elseif ($_GET['error'] == 1) { $message .= $locale['figure_114']."</span>"; }
      // File must be less than %s //
         elseif ($_GET['error'] == 2) { $message .= sprintf($locale['figure_115'], parsebytesize($asettings['figure_max_b']))."</span>"; }         
      // File must be one of the following file types: %s  116 //
         elseif ($_GET['error'] == 3) { $message .= sprintf($locale['figure_116'], str_replace(',', ' ', $asettings['figure_types']))."</span>"; }      
      // File or url cannot be left empty. 118 //
         elseif ($_GET['error'] == 4) { $message .= $locale['figure_118']."</span>"; }         
      // Invalid image filename.   170 //
         elseif ($_GET['error'] == 5) { $message .=  $locale['figure_170']."</span>";}         
      // Image must be less than %s 171 //
         elseif ($_GET['error'] == 6) { $message .=  sprintf($locale['figure_171'], parsebytesize($asettings['figure_photo_max_b']))."</span>";}      
      // Image must be a GIF, JPEG or PNG file 172 //      
         elseif ($_GET['error'] == 7) { $message .=  $locale['figure_172']."</span>";}            
      // Image must be no bigger than %uw x %uh pixels. 173 //   
         elseif ($_GET['error'] == 8) { $message .=  sprintf($locale['figure_173'], $asettings['figure_photo_max_w'], $asettings['figure_photo_max_h'])."</span>";}         
               
      } elseif ($_GET['status'] == "del") {
         // Figure deleted 112 //
         $message = $locale['figure_112'];
      }
      if ($message) { echo "<div id='close-message'><div class='admin-message'>".$message."</div></div>\n"; }
   }

   $submit_info = array();

   if (isset($_POST['submit_figure'])) {
      $valid_ext = explode(",", $asettings['figure_types']);
      $error = 0;
      
//////////////////////////////////////////////////////////////////////////////////////////////////      
//////////////////////////////ÜBERPRÜFUNGEN//////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////   

      // ÜBERPRÜFUNG OB CATOGORY ANGEGEBEN
      if (isset($_POST['figure_cat']) && $_POST['figure_cat'] == "1") {   
         redirect(FUSION_SELF."#popup_cat");
         } else {
         $submit_info['figure_cat'] = intval($_POST['figure_cat']);
         }
         
      // ÜBERPRÜFUNG OB TITLE ANGEGEBEN
        if (isset($_POST['figure_title']) && $_POST['figure_title'] == "") {   
         redirect(FUSION_SELF."#popup_title");
         } else {
         $submit_info['figure_title'] = stripinput($_POST['figure_title']);   
         }
   
      if ($error == 0) {
      
         $result = dbquery("INSERT INTO ".DB_FIGURE."
            (
               figure_cat,
               figure_title
         
            )
         VALUES
            (
               '$figure_cat',
               '$figure_title'
            )");

               
                  redirect(FUSION_SELF."?status=sn");
               } else {
                  redirect(FUSION_SELF."?status=se&error=$error");
               }
            } else {
               add_to_title($locale['global_200'].$locale['figure_521']);
               opentable($locale['figure_521']);
      
      /////////////  DROPDOWN ZUSTEUERUNG///////////////////   
      //CAT
      $editlistcat = "";
      $resultcat = dbquery("SELECT * FROM ".DB_FIGURE_CATS." WHERE figure_cat_parent='0' ORDER BY figure_cat_name");
      if (dbrows($resultcat) != 0) {
         while ($datacat = dbarray($resultcat)) {
            $editlistcat .= menu_subcats($datacat['figure_cat_id'], $datacat['figure_cat_name'],1);
         }
      }
      
      //////////////TABELLEN ANFANG DES SUBMIT FORMULARS ///   
      
      echo "<form id='inputform' method='post' action='".FUSION_SELF."' enctype='multipart/form-data' onsubmit='return validatePost(this);'>\n";
      echo "".$locale['figure_459']."";
      echo "<table cellpadding='0' cellspacing='0' width='600' class='center'>\n<tr>\n";
      
      //CATEGORY
      echo "<td width='150' class='tbl'>".$locale['figure_123']."*:</td>\n";
      echo "<td class='tbl'><select style='width:380px;' name='figure_cat' class='textbox'>\n".$editlistcat."</select> <a class='info' href='javascript:void(0)'><span>".$locale['figure_1800']."</span><img src='".INFUSIONS."figurelib/images/helper.png' height='20' border='0' alt='' style='vertical-align:middle;' /></a></td>\n";
      echo "</tr>\n<tr>\n";
      
      //TITLE 411
      echo "<td width='150' class='tbl'>".$locale['figure_411']."*:</td>\n";
      echo "<td class='tbl'><input type='text' name='figure_title' value='' class='textbox' style='width:380px;' /></td>\n";
      echo "</tr>\n<tr>\n";
   
      echo "<td align='center' colspan='2' class='tbl'>";
      echo "<input type='submit' name='submit_figure' value='".$locale['figure_527']."' class='button' /></td>\n";
      
      echo "</tr>\n</table>\n</form>\n";
      closetable();
   }

} else {
   opentable($locale['figure_102']);
   echo "<div style='text-align:center'>".$locale['figure_525']."</div>\n";

   closetable();
}


function menu_subcats($id, $name, $level) {
   global $figure_cat;
   $list = "<option value='".$id."'>".str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;",$level-1)." ".$name."</option>\n";
   $sresult[$id] = dbquery("SELECT figure_cat_id, figure_cat_name FROM ".DB_FIGURE_CATS." WHERE figure_cat_parent='".$id."' ORDER BY figure_cat_name");
   if (dbrows($sresult[$id]) != 0) {
      while ($sdata[$id] = dbarray($sresult[$id])) {
         $list .= menu_subcats($sdata[$id]['figure_cat_id'], $sdata[$id]['figure_cat_name'], $level+1);
      }
   }
   return $list;
}

require_once THEMES."templates/footer.php";
?>
 
Wemi
Lass dir doch mal die Variablen vorher ausgeben?

Was hast du denn da für Werte?
'$figure_cat',
'$figure_title'
"Es geht hier um die Frage, ob die Menschheit ohne Religion besser dastünde. Und ich sagte: ja" Ben Moore
 
Catzenjaeger
habe ich doch :) -->
Array ( [submit_figure] => Submit [figure_cat] => 3 [figure_title] => wrewrwr ) Array ( )

Figure Cat wird als = eingetragen und der Name gar nicht

hier mal das script

Code
<?php

   error_reporting(E_ALL);
   // Formularinhalte prüfen
   print_r ($_POST);
   // GET-Parameter prüfen
   print_r ($_GET);
   // Sessions prüfen
   print_r ($_SESSION);
   
require_once "../../maincore.php";
require_once THEMES."templates/header.php";
require_once INCLUDES."bbcode_include.php";

// SYSTEMDATEI
include "infusion_db.php";
// POPUPS BEI FEHLER ODER NICHT AUFGEFÜLLTEN FELDERN
include "includes/popups.php";
// CSS FÜR DIE POPUPS / CSS FÜR DIE HINWEISE
include "includes/css.php";
// AUSGELAGERTE FUNKTIONEN
include "classes/functions_submit.php";
// SETTINGS SUBMIT
include "includes/settings_submit.php";


      // ÜBERPRÜFUNG OB CATOGORY ANGEGEBEN
      if (isset($_POST['figure_cat']) && $_POST['figure_cat'] == "1") {   
         redirect(FUSION_SELF."#popup_cat");
         } else {
         $submit_info['figure_cat'] = intval($_POST['figure_cat']);
         }
         
      // ÜBERPRÜFUNG OB TITLE ANGEGEBEN
        if (isset($_POST['figure_title']) && $_POST['figure_title'] == "") {   
         redirect(FUSION_SELF."#popup_title");
         } else {
         $submit_info['figure_title'] = stripinput($_POST['figure_title']);   
         }
         
      $submit_info['figure_freigabe'] = stripinput($_POST['figure_freigabe']);
      $submit_info['figure_submitter'] = stripinput($_POST['figure_submitter']);
      $submit_info['figure_weight'] = stripinput($_POST['figure_weight']);
      $submit_info['figure_retailprice'] = stripinput($_POST['figure_retailprice']);
      $submit_info['figure_usedprice'] = stripinput($_POST['figure_usedprice']);
      $submit_info['figure_editionsize'] = stripinput($_POST['figure_editionsize']);
      $submit_info['figure_artists'] = stripinput($_POST['figure_artists']);
      $submit_info['figure_country'] = stripinput($_POST['figure_country']);
      $submit_info['figure_series'] = stripinput($_POST['figure_series']);
      $submit_info['figure_variant'] = stripinput($_POST['figure_variant']);
      $submit_info['figure_pubdate'] = stripinput($_POST['figure_pubdate']);
      $submit_info['figure_accessories'] = trim(stripinput($_POST['figure_accessories']));
      $submit_info['figure_description'] = trim(stripinput($_POST['figure_description']));

      if ($error == 0) {
         //$result = dbquery("INSERT INTO ".DB_FIGURE_SUBMISSIONS." (submit_user, submit_datestamp, submit_criteria) VALUES('".$userdata['user_id']."', '".time()."', '".addslashes(serialize($submit_info))."')");
         
         $result = dbquery("INSERT INTO ".DB_FIGURE." (figure_freigabe, figure_submitter, figure_cat, figure_title, figure_variant, figure_manufacturer, figure_artists, figure_country, figure_brand, figure_series, figure_scale,figure_weight, figure_height, figure_width, figure_depth, figure_material, figure_poa, figure_packaging, figure_pubdate, figure_retailprice, figure_usedprice, figure_limitation,figure_editionsize, figure_image_1, figure_image_1_thumb, figure_image_2, figure_image_2_thumb, figure_image_3, figure_image_3_thumb, figure_image_4, figure_image_4_thumb,figure_image_5, figure_image_5_thumb, figure_image_6, figure_image_6_thumb, figure_image_7, figure_image_7_thumb, figure_image_8, figure_image_8_thumb, figure_image_9,figure_image_9_thumb, figure_image_10, figure_image_10_thumb, figure_url, figure_accessories, figure_description, figure_datestamp)VALUES ('0', '".$userdata['user_id']."', '$figure_cat', '$figure_title', '$figure_variant', '$figure_manufacturer', '$figure_artists', '$figure_country', '$figure_brand', '$figure_series', '$figure_scale', '$figure_weight', '$figure_height', '$figure_width', '$figure_depth', '$figure_material', '$figure_poa', '$figure_packaging', '$figure_pubdate', '$figure_retailprice', '$figure_usedprice', '$figure_limitation', '$figure_editionsize', '$figure_image_1', '$figure_image_1_thumb', '$figure_image_2', '$figure_image_2_thumb', '$figure_image_3', '$figure_image_3_thumb', '$figure_image_4', '$figure_image_4_thumb', '$figure_image_5', '$figure_image_5_thumb', '$figure_image_6', '$figure_image_6_thumb', '$figure_image_7', '$figure_image_7_thumb', '$figure_image_8', '$figure_image_8_thumb', '$figure_image_9', '$figure_image_9_thumb', '$figure_image_10', '$figure_image_10_thumb', '$figure_url', '$figure_accessories', '$figure_description', '".time()."')");
         
         //$result = dbquery("INSERT INTO ".DB_FIGURE." (figure_freigabe)VALUES ('$figure_freigabe')");
         
         

      }
      opentable($locale['figure_521']);
      

      echo "<form id='inputform' method='post' action='".FUSION_SELF."' enctype='multipart/form-data' onsubmit='return validatePost(this);'>\n";
      echo "".$locale['figure_459']."";
      echo "<table cellpadding='0' cellspacing='0' width='600' class='center'>\n<tr>\n";

      //HIDDEN FREIGABE BEI USEREINSENDUNG IMMER = 0
      //wird direkt als 0 in DB eingetragen
      
      //HIDDEN SUBMITTER BEI USEREINSENDUNG IMMER = $userdata['user_id']
      //wird direkt in DB geschreiben
      
      //CATEGORY
      $editlistcat = "";
      $resultcat = dbquery("SELECT * FROM ".DB_FIGURE_CATS." WHERE figure_cat_parent='0' ORDER BY figure_cat_name");
      if (dbrows($resultcat) != 0) {
         while ($datacat = dbarray($resultcat)) {
            $editlistcat .= menu_subcats($datacat['figure_cat_id'], $datacat['figure_cat_name'],1);
         }
      }
      
      //CATEGORY
      echo "<td width='80' class='tbl'>".$locale['figure_123'].":</td>\n";
      echo "<td class='tbl'><select name='figure_cat' class='textbox'>\n".$editlistcat."</select></td>\n";
      echo "</tr>\n<tr>\n";
      
      
      //TITLE 411
      echo "<td width='150' class='tbl'>".$locale['figure_411']."*:</td>\n";
      echo "<td class='tbl'><input type='text' name='figure_title' value='' class='textbox' style='width:380px;' /></td>\n";
      echo "</tr>\n<tr>\n";
      

      echo "<input type='submit' name='submit_figure' value='".$locale['figure_527']."' class='button' /></td>\n";
            ///HIER MESSAGE TO USER OR ADMIN MÖGLICH
      echo "</tr>\n</table>\n</form>\n";
      closetable();



require_once THEMES."templates/footer.php";
?>

SO DAS PROJEKT HABE ICH MAL AUF GITHUB GESTELLT
https://github.com/Catzenjaeger/Figur...ree/master


Übnrigens werden alle SUBMITS doppelt in der DB gespeichert -- warum auch immer
Bearbeitet von Catzenjaeger am 28.05.2016 um 13:01
 
Springe ins Forum: