Foros del Web » Programando para Internet » PHP »

Undefined variable: submit

Estas en el tema de Undefined variable: submit en el foro de PHP en Foros del Web. Hola! cuando ingreso al admin del sitio me tira este error: Notice: Undefined variable: submit in /home/pallotta/public_html/galeria/admin/add_category.php on line 45 La cosa es que la ...
  #1 (permalink)  
Antiguo 22/01/2011, 05:26
 
Fecha de Ingreso: enero-2011
Ubicación: Ing. Maschwitz
Mensajes: 8
Antigüedad: 13 años, 3 meses
Puntos: 0
Pregunta Undefined variable: submit

Hola! cuando ingreso al admin del sitio me tira este error:

Notice: Undefined variable: submit in /home/pallotta/public_html/galeria/admin/add_category.php on line 45

La cosa es que la base no hace nada: no graba los cambios, no borra ni edita.

La línea del código en cuestión es así:

Código PHP:
// if submit has not been clicked
if (!$submit){
echo 
"<FORM ENCTYPE=\"multipart/form-data\" ACTION=\"add_category.php\" METHOD=\"POST\"> 
Desde ya gracias por ayudarme y traten de hacerlo bien fácil porque mis conocimientos son menos que básicos
  #2 (permalink)  
Antiguo 22/01/2011, 07:11
Avatar de Heli0s  
Fecha de Ingreso: abril-2010
Mensajes: 789
Antigüedad: 14 años
Puntos: 40
Respuesta: Undefined variable: submit

Deberias poner todo el código porque lo que has puesto es insuficiente, no sabemos de donde viene la variable submit, ni nada.

Un saludo
  #3 (permalink)  
Antiguo 22/01/2011, 07:18
 
Fecha de Ingreso: enero-2011
Ubicación: Ing. Maschwitz
Mensajes: 8
Antigüedad: 13 años, 3 meses
Puntos: 0
Respuesta: Undefined variable: submit

Es muy largo, lo mando en 2 partes. Acá va la primera.

[HIGHLIGHT="PHP"]
session_start();

// if session is not registered go to login
if (!session_is_registered("admin"))
{
header("Location: login.php");
}

// if seiion is registered
if(session_is_registered("admin")){
include ("config.php");
include( "settings.inc.php");
include_once ("header.inc.php");
echo "<h2>$la_add_cat_title</h2>";

error_reporting(E_ALL);

// if submit has not been clicked
if (!$submit){
echo "<FORM ENCTYPE=\"multipart/form-data\" ACTION=\"add_category.php\" METHOD=\"POST\">
<table align=center width=\"600\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr><td bgcolor=\"$colour_2\">
<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"1\">
<tr bgcolor=\"$colour_3\">
<td width=\"200\" valign=\"top\"><b>$la_cat_name</b></td>
<td width=\"400\" valign=\"top\"><input class=\"textbox\" type=\"textbox\" name=\"cat_name\"></td>
</tr>
<tr bgcolor=\"$colour_3\">
<td width=\"200\" valign=\"top\"><b>$la_cat_name en ingles</b></td>
<td width=\"400\" valign=\"top\"><input class=\"textbox\" type=\"textbox\" name=\"cat_name_en\"></td>
</tr>
<tr bgcolor=\"$colour_3\">
<td width=\"200\" valign=\"top\"><b>Precio</b></td>
<td width=\"400\" valign=\"top\"><input class=\"textbox\" type=\"textbox\" name=\"price\"></td>
</tr>
<tr bgcolor=\"$colour_3\">
<td width=\"200\" valign=\"top\"><b>Descripcion</b></td>
<td width=\"400\" valign=\"top\"><textarea name=\"description\" cols=\"40\" rows=\"8\"></textarea></td>
</tr>
<tr bgcolor=\"$colour_3\">
<td width=\"200\" valign=\"top\"><b>$la_cat_below</b></td>
<td width=\"400\" valign=\"top\">";

// Drop down menu to build full category!
print "<select name=\"cat_father_id\"><option value=\"0\">$la_top_lev</option>";
$select = mysql_query("select * from ".$prefix."store_category");
while ($row = mysql_fetch_array($select))
{
$cat_id_dd = $row["cat_id"];

echo"<option value=\"$cat_id_dd\">";
$cat_full_name = $row["cat_full_name"];
$category = $row["category"];
$catfatherid_1 = $row["cat_father_id"];

$t1 = $category;

if ($catfatherid_1 <> 0)
{
$sql_lowercat = "select * from ".$prefix."store_category where cat_id = $catfatherid_1";
$result1 = mysql_query ($sql_lowercat);
$row1 = mysql_fetch_array($result1);
$catfatherid_2 = $row1["cat_father_id"];
$catname_2 = $row1["category"];
$t2 = $catname_2;
$catid2 = $catid_2;
}

if ($catfatherid_2 <> 0)
{
$sql_lowercat = "select * from ".$prefix."store_category where cat_id = $catfatherid_2";
$result1 = mysql_query ($sql_lowercat);
$row1 = mysql_fetch_array($result1);
$catfatherid_3 = $row1["cat_father_id"];
$catname_3 = $row1["category"];
$t3 = $catname_3;
$catid3 = $catid_3;
}

if ($catfatherid_3 <> 0)
{
$sql_lowercat = "select * from ".$prefix."store_category where cat_id = $catfatherid_3";
$result1 = mysql_query ($sql_lowercat);
$row1 = mysql_fetch_array($result1);
$catfatherid_4 = $row1["cat_father_id"];
$catname_4 = $row1["category"];
$t4 = $catname_4;
$catid4 = $catid_4;
}

if ($catfatherid_4 <> 0)
{
$sql_lowercat = "select * from ".$prefix."store_category where cat_id = $catfatherid_4";
$result1 = mysql_query ($sql_lowercat);
$row1 = mysql_fetch_array($result1);
$catfatherid_5 = $row1["cat_father_id"];
$catname_5 = $row1["category"];
$t5 = $catname_5;
$catid5 = $catid_5;
}

if ($catfatherid_5 <> 0)
{
$sql_lowercat = "select * from ".$prefix."store_category where cat_id = $catfatherid_5";
$result1 = mysql_query ($sql_lowercat);
$row1 = mysql_fetch_array($result1);
$catfatherid_6 = $row1["cat_father_id"];
$catname_6 = $row1["category"];
$t6 = $catname_6;
$catid6 = $catid_6;
}

if ($catfatherid_6 <> 0)
{
$sql_lowercat = "select * from ".$prefix."store_category where cat_id = $catfatherid_6";
$result1 = mysql_query ($sql_lowercat);
$row1 = mysql_fetch_array($result1);
$catfatherid_7 = $row1["cat_father_id"];
$catname_7 = $row1["category"];
$t7 = $catname_7;
$catid7 = $catid_7;
}

if ($catfatherid_7 <> 0)
{
$sql_lowercat = "select * from ".$prefix."store_category where cat_id = $catfatherid_7";
$result1 = mysql_query ($sql_lowercat);
$row1 = mysql_fetch_array($result1);
$catfatherid_8 = $row1["cat_father_id"];
$catname_8 = $row1["category"];
$t8 = $catname_8;
$catid8 = $catid_8;
}

if ($catfatherid_8 <> 0)
{
$sql_lowercat = "select * from ".$prefix."store_category where cat_id = $catfatherid_8";
$result1 = mysql_query ($sql_lowercat);
$row1 = mysql_fetch_array($result1);
$catfatherid_9 = $row1["cat_father_id"];
$catname_9 = $row1["category"];
$t9 = $catname_9;

}
HIGHLIGHT]
  #4 (permalink)  
Antiguo 22/01/2011, 07:19
 
Fecha de Ingreso: enero-2011
Ubicación: Ing. Maschwitz
Mensajes: 8
Antigüedad: 13 años, 3 meses
Puntos: 0
Respuesta: Undefined variable: submit

esto es lo que sigue. Gracias!!

if ($t9)
print "$t9/";
if ($t8)
print "$t8/";
if ($t7)
print "$t7/";
if ($t6)
print "$t6/";
if ($t5)
print "$t5/";
if ($t4)
print "$t4/";
if ($t3)
print "$t3/";
if ($t2)
print "$t2/";
if ($t1)
print "$t1/";

unset($t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$catfath erid_1,$catfatherid_2,$catfatherid_3,$catfatherid_ 4,$catfatherid_5,$catfatherid_6,$catfatherid_7,$ca tfatherid_8,$catfatherid_9,$catname_1,$catname_2,$ catname_3,$catname_4,$catname_5,$catname_6,$catnam e_7,$catname_8,$catname_9);
echo"</option>";}
echo"</select></td>
</tr>
<tr bgcolor=\"$colour_3\">
<td width=\"200\" valign=\"top\"><b>$la_upload_im</b></td>
<td width=\"400\" valign=\"top\"><input name=\"upload_image\" type=\"checkbox\" value=\"yes\">$la_upload_checked</td>
</tr>
<tr bgcolor=\"$colour_3\">
<td width=\"200\" valign=\"top\"><b>$la_image</b></td>
<td width=\"400\" valign=\"top\"><INPUT class=\"file\" NAME=\"userfile\" TYPE=\"file\">$la_cat_types</td>
</tr>
</tr>
<!--<tr bgcolor=\"$colour_3\">
<td width=\"200\" valign=\"top\"><b>$la_per_ship</b></td>
<td width=\"400\" valign=\"top\">
$currency<INPUT class=\"textbox\" TYPE=\"text\" NAME=\"per_ship\"></td>
</tr>
</tr>
<tr bgcolor=\"$colour_3\">
<td width=\"200\" valign=\"top\"><b>$la_per_item</b></td>
<td width=\"400\" valign=\"top\">
$currency<INPUT class=\"textbox\" TYPE=\"text\" NAME=\"item_ship\"></td>
</tr>
</tr>
<tr bgcolor=\"$colour_3\">
<td width=\"200\" valign=\"top\"><b>$la_per_int_item</b></td>
<td width=\"400\" valign=\"top\">
$currency<INPUT class=\"textbox\" TYPE=\"text\" NAME=\"per_int_ship\"></td>
</tr>
</tr>
<tr bgcolor=\"$colour_3\">
<td width=\"200\" valign=\"top\"><b>$la_per_int_item2</b></td>
<td width=\"400\" valign=\"top\">
$currency<INPUT class=\"textbox\" TYPE=\"text\" NAME=\"item_int_ship\"></td>
</tr>-->
<tr bgcolor=\"$colour_3\">
<td width=\"200\" valign=\"top\">&nbsp;</td>
<td width=\"400\" valign=\"top\">
<INPUT class=\"submit\" TYPE=\"submit\" NAME=\"submit\" VALUE=\"$la_add_category\"></td>
</tr>
</table>
</td></tr></table>
</FORM>";
}

// if submit has been clicked
if ($submit){
$userfile_size=$_FILES['userfile']['size'] ;
$userfile_type=$_FILES['userfile']['type'] ;
$userfile_name=$_FILES['userfile']['name'] ;
// $userfile=$_FILES['userfile']['tmp_name'];
$userfile = $HTTP_POST_FILES['userfile']['tmp_name'];

// link back
$goback="<a href=\"javascript:history.back()\">$la_try_again</a>";

// if category was not chosen
if (empty($cat_name))
{
echo "<p align=\"center\">$la_cat_name_empt</p><p>$goback</p>";
exit;
}

// if image was not chosen to be uploaded
if($upload_image!=="yes"){

$userfile_name = "catnophoto.gif";
$userfile_name = addslashes($userfile_name);

$sql_insert = "insert into ".$prefix."store_category (category, category_en, cat_image, price, cat_father_id, per_ship, item_ship, per_int_ship, item_int_ship, description) values ('$cat_name','$cat_name_en','$userfile_name', '$price', '$cat_father_id', '$per_ship', '$item_ship', '$per_int_ship', '$item_int_ship', '$description')";

$result = mysql_query($sql_insert);

// result text
echo "<div align='center'>$la_new_cat $category $la_created!<p><p><img src='../images/$userfile_name'><p><a href=\"add_product.php\">$la_add_prod</a> | <a href=\"add_category.php\">$la_add_cat_title</a></p><p><a href=\"categories.php\">$la_back_cat_admin</a></p></div>";
}

// if upload image was clicked
if($upload_image=="yes"){
// Upload
$path = "$site_dir/images/";
$max_size = 200000;

if (is_uploaded_file($userfile)) {

if ($userfile_size>$max_size) { echo "$la_too_big<br>\n"; exit; }

if (($userfile_type=="image/gif") || ($userfile_type=="image/pjpeg") || ($userfile_type=="image/x-png") || ($userfile_type=="image/png") || ($userfile_type=="image/jpeg")) {

if (file_exists($path . $userfile_name)) { echo "<p align=\"center\">$la_used_already</p><br>\n";$escape=1; }

if($escape!=1){
$res = move_uploaded_file($userfile, $path . $userfile_name);}
if($escape=1){$res="continue";}

// Resultant output
if (!$res) {
echo "<p align=\"center\">$la_upload_failed<br><br><a href=\"javascript:history.back()\">$la_try_again</a></p>\n"; exit; }
} else { echo "<p align=\"center\">$la_wrong_type<br><br><a href=\"javascript:history.back()\">$la_try_again</a></p>\n"; exit; }


$sql_insert = "insert into ".$prefix."store_category (category, category_en, cat_father_id, price, cat_image, per_ship, item_ship, per_int_ship, item_int_ship, description) values ('$cat_name','$cat_name_en', '$cat_father_id', '$price', '$userfile_name', '$per_ship', '$item_ship', '$per_int_ship', '$item_int_ship', '$description')";

$result = mysql_query($sql_insert);

echo "<div align='center'>$la_new_cat $category $la_created!<p><p><img src='../images/$userfile_name'><p><a href=\"add_product.php\">$la_add_prod</a> | <a href=\"add_category.php\">$la_add_cat_title</a></p><p><a href=\"categories.php\">$la_back_cat_admn</a></p></div>";}
}}
include ("footer.inc.php");
} // end if session is registered
?>

Etiquetas: submit, undefined, variables
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:31.