vendredi 24 février 2017

Why do I have the alert: "Undefined index" on PHP? I checked everything [duplicate]

I've been working in this php site. I was developing a form, but i can't send the data. It only appears:

( ! ) Notice: Undefined index: checkbox-2 in C:\wamp\www\Impre3D\es\publishpbd.php on line 19
Call Stack  

( ! ) Notice: Undefined index: checkbox-3 in C:\wamp\www\Impre3D\es\publishpbd.php on line 19
Call Stack  

( ! ) Notice: Undefined index: files1 in C:\wamp\www\Impre3D\es\publishpbd.php on line 28
Call Stack  

( ! ) Notice: Undefined index: files1 in C:\wamp\www\Impre3D\es\publishpbd.php on line 29
Call Stack  

( ! ) Notice: Undefined index: checkbox-1 in C:\wamp\www\Impre3D\es\publishpbd.php on line 31
Call Stack  
0
( ! ) Notice: Undefined index: checkbox-2 in C:\wamp\www\Impre3D\es\publishpbd.php on line 38
Call Stack  
0
( ! ) Notice: Undefined index: checkbox-3 in C:\wamp\www\Impre3D\es\publishpbd.php on line 45
Call Stack  
01608
( ! ) Notice: Undefined index: checkbox-5 in C:\wamp\www\Impre3D\es\publishpbd.php on line 59
Call Stack  
0
( ! ) Notice: Undefined index: checkbox-6 in C:\wamp\www\Impre3D\es\publishpbd.php on line 66
Call Stack  
0
( ! ) Notice: Undefined index: checkbox-7 in C:\wamp\www\Impre3D\es\publishpbd.php on line 71
Call Stack  
0
( ! ) Notice: Undefined index: checkbox-8 in C:\wamp\www\Impre3D\es\publishpbd.php on line 78
Call Stack  
0
( ! ) Notice: Undefined index: checkbox-9 in C:\wamp\www\Impre3D\es\publishpbd.php on line 83
Call Stack  
01805
( ! ) Notice: Undefined index: checkbox-11 in C:\wamp\www\Impre3D\es\publishpbd.php on line 95
Call Stack  
0
( ! ) Notice: Undefined index: category in C:\wamp\www\Impre3D\es\publishpbd.php on line 104
Call Stack  

( ! ) Notice: Undefined index: files1 in C:\wamp\www\Impre3D\es\publishpbd.php on line 107
Call Stack  

( ! ) Notice: Undefined index: files1 in C:\wamp\www\Impre3D\es\publishpbd.php on line 108
Call Stack  

( ! ) Notice: Undefined index: files1 in C:\wamp\www\Impre3D\es\publishpbd.php on line 109
Call Stack  

( ! ) Notice: Undefined index: files in C:\wamp\www\Impre3D\es\publishpbd.php on line 111
Call Stack  

( ! ) Notice: Undefined index: files in C:\wamp\www\Impre3D\es\publishpbd.php on line 112
Call Stack  

( ! ) Notice: Undefined index: files1 in C:\wamp\www\Impre3D\es\publishpbd.php on line 113
Call Stack  

( ! ) Notice: Undefined index: files1 in C:\wamp\www\Impre3D\es\publishpbd.php on line 114

This is my code, I hope you can help me: //HTML

<form method="POST" action="publishpbd.php" name="uploadprinter" id="uploadprinter" enctype="multipart/form-data">
        <label for="strName" class='label-sign' style="font-size:25px;" >Crear centro de impresión 3D</label>
            <div style='margin:5px;color:#f92859;font-size:12px;'>&nbsp;&nbsp;* campo obligatorio</div>
              <label for="strName" class='label-sign'> *Nombre del print hub:</label>
              <input type="text" name="strName" id="strName" class="input-text" autocomplete="off" maxlength="50" required>
        <label for="" class='label-sign'> *Materiales tratados:</label>      
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-1" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-1" name="checkbox-1" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">ABS</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-2" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-2" name="checkbox-2" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">PLA</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-3" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-3" name="checkbox-3" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">Nylon</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-4" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-4" name="checkbox-4" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">HIPS</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-5" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-5" name="checkbox-5" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">PET</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-6" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-6" name="checkbox-6" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">LAYWOOD-D3</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-7" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-7" name="checkbox-7" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">NINJAFLEX</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-8" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-8" name="checkbox-8" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">METAL</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-9" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-9" name="checkbox-9" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">LAYBRICK</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-10" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-10" name="checkbox-10" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">SOFTPLA</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-11" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-11" name="checkbox-11" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">BENDLAY</span><br>
          </label>
        </label>
              <div style="display: none;" id="abs">
        <center><h4>ABS</h4></center>
        <label for="abs" class='label-sign'> Precio por hora del ABS(dólares estadounidenses):</label>
              <input type="number" value="0" name="input-abs" id="input-abs" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        <label for="color-1" class='label-sign'> Colores disponibles:</label>
        <select name="color-1" id="color-1" class="input-text">
          <option value="">Selecciona un color</option>
          <option value="1">Blanco</option>
          <option value="2">Negro</option>
          <option value="3">Rojo</option>
          <option value="4">Amarillo</option>
          <option value="5">Verde</option>
          <option value="6">Azul</option>
          <option value="7">Naranja</option>
          <option value="8">Rosado</option>
          <option value="9">Morado</option>
          <option value="10">Gris</option>
          <option value="11">Celeste</option>
        </select>
        </div>

        <div style="display: none;" id="pla">
        <center><h4>PLA</h4></center>
        <label for="pla" class='label-sign'> Precio por hora del PLA(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-pla" id="input-pla" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        <label for="color-2" class='label-sign'> Colores disponibles:</label>
        <select name="color-2" id="color-2" class="input-text">
          <option value="">Selecciona un color</option>
          <option value="1">Blanco</option>
          <option value="2">Negro</option>
          <option value="3">Rojo</option>
          <option value="4">Amarillo</option>
          <option value="5">Verde</option>
          <option value="6">Azul</option>
          <option value="7">Naranja</option>
          <option value="8">Rosado</option>
          <option value="9">Morado</option>
          <option value="10">Gris</option>
          <option value="11">Celeste</option>
        </select>
        </div>

        <div style="display: none;" id="nylon">
        <center><h4>NYLON</h4></center>
        <label for="nylon" class='label-sign'> Precio por hora del Nylon(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-nylon" id="input-nylon" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        <label for="color-3" class='label-sign'> Colores disponibles:</label>
        <select name="color-3" id="color-3" class="input-text">
          <option value="">Selecciona un color</option>
          <option value="1">Blanco</option>
          <option value="2">Negro</option>
          <option value="3">Rojo</option>
          <option value="4">Amarillo</option>
          <option value="5">Verde</option>
          <option value="6">Azul</option>
          <option value="7">Naranja</option>
          <option value="8">Rosado</option>
          <option value="9">Morado</option>
          <option value="10">Gris</option>
          <option value="11">Celeste</option>
        </select>
        </div>

        <div style="display: none;" id="pet">
        <center><h4>PET</h4></center>
        <label for="pet" class='label-sign'> Precio por hora del PET(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-pet" id="input-pet" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        <label for="color-4" class='label-sign'> Colores disponibles:</label>
        <select name="color-4" id="color-4" class="input-text">
          <option value="">Selecciona un color</option>
          <option value="1">Blanco</option>
          <option value="2">Negro</option>
          <option value="3">Rojo</option>
          <option value="4">Amarillo</option>
          <option value="5">Verde</option>
          <option value="6">Azul</option>
          <option value="7">Naranja</option>
          <option value="8">Rosado</option>
          <option value="9">Morado</option>
          <option value="10">Gris</option>
          <option value="11">Celeste</option>
        </select>
        </div>

        <div style="display: none;" id="hips">
        <center><h4>HIPS</h4></center>
        <label for="hips" class='label-sign'> Precio por hora del HIPS(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-hips" id="input-hips" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        <label for="color-5" class='label-sign'> Colores disponibles:</label>
        <select name="color-5" id="color-5" class="input-text">
          <option value="">Selecciona un color</option>
          <option value="1">Blanco</option>
          <option value="2">Negro</option>
          <option value="3">Rojo</option>
          <option value="4">Amarillo</option>
          <option value="5">Verde</option>
          <option value="6">Azul</option>
          <option value="7">Naranja</option>
          <option value="8">Rosado</option>
          <option value="9">Morado</option>
          <option value="10">Gris</option>
          <option value="11">Celeste</option>
        </select>
        </div>

        <div style="display: none;" id="laywood-d3">
        <center><h4>LAYWOOD-D3</h4></center>
        <label for="laywood-d3" class='label-sign'> Precio por hora del LAYWOOD-D3 (dólares estadounidenses):</label>
        <input type="number" value="0" name="input-laywood-d3" id="input-laywood-d3" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        </div>

        <div style="display: none;" id="ninjaflex">
        <center><h4>NINJAFLEX</h4></center>
        <label for="ninjaflex" class='label-sign'> Precio por hora del NINJAFLEX(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-ninjaflex" id="input-ninjaflex" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        <label for="color-6" class='label-sign'> Colores disponibles:</label>
        <select name="color-6" id="color-6" class="input-text">
          <option value="">Selecciona un color</option>
          <option value="1">Blanco</option>
          <option value="2">Negro</option>
          <option value="3">Rojo</option>
          <option value="4">Amarillo</option>
          <option value="5">Verde</option>
          <option value="6">Azul</option>
          <option value="7">Naranja</option>
          <option value="8">Rosado</option>
          <option value="9">Morado</option>
          <option value="10">Gris</option>
          <option value="11">Celeste</option>
        </select>
        </div>

        <div style="display: none;" id="metal">
        <center><h4>Metal</h4></center>
        <label for="metal" class='label-sign'> Precio por hora del Metal(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-metal" id="input-metal" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        </div>

        <div style="display: none;" id="laybrick">
        <center><h4>Laybrick</h4></center>
        <label for="laybrick" class='label-sign'> Precio por hora del Laybrick(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-laybrick" id="input-laybrick" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        </div>

        <div style="display: none;" id="softpla">
        <center><h4>SoftPla</h4></center>
        <label for="softpla" class='label-sign'> Precio por hora del SoftPla(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-softpla" id="input-softpla" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        <label for="color-7" class='label-sign'> Colores disponibles:</label>
        <select name="color-7" id="color-7" class="input-text">
          <option value="">Selecciona un color</option>
          <option value="1">Blanco</option>
          <option value="2">Negro</option>
          <option value="3">Rojo</option>
          <option value="4">Amarillo</option>
          <option value="5">Verde</option>
          <option value="6">Azul</option>
          <option value="7">Naranja</option>
          <option value="8">Rosado</option>
          <option value="9">Morado</option>
          <option value="10">Gris</option>
          <option value="11">Celeste</option>
        </select>
        </div>

        <div style="display: none;" id="bendlay">
        <center><h4>Bendlay</h4></center>
        <label for="bendlay" class='label-sign'> Precio por hora del Bendlay(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-bendlay" id="input-bendlay" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        </div>

        <label for="strBDesc" class='label-sign'> Descripción básica:<p style='font-weight: lighter;font-size:12px;'>(Hasta 200 caracteres)</p></label>
        <textarea name="strBDesc" id="strBDesc" class="input-text" autocomplete="off" maxlength="200"></textarea>       
        <label for="strADesc" class='label-sign'> Descripción avanzada:<p style='font-weight: lighter;font-size:12px;'>(Hasta 600 caracteres)</p></label>
        <textarea name="strADesc" id="strADesc" class="input-text" autocomplete="off" min="0" maxlength="600"> </textarea>
        <input type="hidden" name="MAX_FILE_SIZE" value="4194304" />            
        <br><label for="country" class='label-sign'> *País:</label><br>
          <select name="country" required autocomplete="off" class="input-text">
              <option value=""></option>
        <option value="00">example</option>
        <option value="00">example</option>
      </select>
      <br><label for="strAdress" class='label-sign'> *Domicilio:</label>
      <input type="text" name="strAdress" id="strAdress" autocomplete="off" class="input-text" required>

              <label for="files1" class='label-sign'> Subir imágen:</label>
              <input type="file" name="files1" id="files1" class="input-text" accept="image/*">
        <a id="btn-reset">
        <output id="list"></output>
        </a>
              <br><br>
              <center>
                <input type="submit" name="submit" id="submit" value="Publicar diseño 3D" class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored">
              </center>
     </form>`
**//PHP publishpbd.php**
<?php require_once('../conection/conection.php');
if(isset($_POST['submit'])){
if(isset($_POST['checkbox-1'])||($_POST['checkbox-2'])||($_POST['checkbox-3'])|| ($_POST['checkbox-4'])||($_POST['checkbox-5'])||($_POST['checkbox-6'])||($_POST['checkbox-7'])||($_POST['checkbox-8'])||($_POST['checkbox-9'])||($_POST['checkbox-10'])||($_POST['checkbox-11'])){
$id=($_SESSION["Id"]);
$correo=($_SESSION["Email"]);
//CAMPOS
$nombre=($_POST['strName']);
$basicdescription=($_POST['strBDesc']);
$advanceddescription=($_POST['strADesc']);
$country=($_POST['country']);
$adress=($_POST['strAdress']);
$file=($_FILES['files1']['tmp_name']);
$filesize=($_FILES['files1']['size']);
//
$abs=($_POST['checkbox-1']);
$absinput=($_POST['input-abs']);
$abscolor=($_POST['color-1']);
print_r($abs);
print_r($absinput);
print_r($abscolor);
//
$pla=($_POST['checkbox-2']);
$plainput=($_POST['input-pla']);
$placolor=($_POST['color-2']);
print_r($pla);
print_r($plainput);
print_r($placolor);
//
$nylon=($_POST['checkbox-3']);
$nyloninput=($_POST['input-nylon']);
$nyloncolor=($_POST['color-3']);
print_r($nylon);
print_r($nyloninput);
print_r($nyloncolor);
//
$hips=($_POST['checkbox-4']);
$hipsinput=($_POST['input-hips']);
$hipscolor=($_POST['color-5']);
print_r($hips);
print_r($hipsinput);
print_r($hipscolor);
//
$pet=($_POST['checkbox-5']);
$petinput=($_POST['input-pet']);
$petcolor=($_POST['color-4']);
print_r($pet);
print_r($petinput);
print_r($petcolor);
//
$laywoodd3=($_POST['checkbox-6']);
$laywoodd3input=($_POST['input-laywood-d3']);
print_r($laywoodd3);
print_r($laywoodd3input);
//
$ninjaflex=($_POST['checkbox-7']);
$ninjaflexinput=($_POST['input-ninjaflex']);
$ninjaflexcolor=($_POST['color-6']);
print_r($ninjaflex);
print_r($ninjaflexinput);
print_r($ninjaflexcolor);
//
$metal=($_POST['checkbox-8']);
$metalinput=($_POST['input-metal']);
print_r($metal);
print_r($metalinput);
//
$laybrick=($_POST['checkbox-9']);
$laybrickinput=($_POST['input-laybrick']);
print_r($laybrick);
print_r($laybrickinput);
//
$softpla=($_POST['checkbox-10']);
$softplainput=($_POST['input-softpla']);
$softplacolor=($_POST['color-7']);
print_r($softpla);
print_r($softplainput);
print_r($softplacolor);
//
$bendlay=($_POST['checkbox-11']);
$bendlayinput=($_POST['input-bendlay']);
print_r($bendlay);
print_r($bendlayinput);
//SESSION
$name=$_SESSION['Name'];
$lastname=$_SESSION['LastName'];
$bdesc=$_POST['strBDesc'];
$adesc=$_POST['strADesc'];
$cat=$_POST['category'];
$nombred=$name." ".$lastname;
$timestamp = date("Y-m-d");
$name1 = $_FILES["files1"]["name"];
$size1 = $_FILES['files1']['size'];
$type1 = $_FILES['files1']['type'];

$tmp_name = $_FILES['files']['tmp_name'];
$error = $_FILES['files']['error'];
$tmp_name1 = $_FILES['files1']['tmp_name'];
$error1 = $_FILES['files1']['error'];
}else{
  ?>
  <script>
    alert("No has seleccionado ningun checkbox");
    window.location="dashboard.php";
  </script>
  <?php 
}
}else{
  ?>
  <script>
    alert("Ha ocurrido un problema, por favor vuelve a intentarlo");
    window.location="dashboard.php";
  </script>
  <?php 
}
?>

Thank you!




Aucun commentaire:

Enregistrer un commentaire