All pastes #733733 Raw Edit

Categorias

public php v1 · immutable
·published 2007-10-12 01:27 UTC
rendered paste body
<?session_start();if(!isset($SESSION)){header("location:index.php");} else {include('../connect.php'); ?>		<form action="admin.php?site=categorias&accion=agregar" method="POST">		<table><tr><center><h2><strong>Categorias</strong></h2></center>		<tr>			<td width="200"><strong>Nombre:</strong></td>			<td><input type="text" name="categoria" size="30" maxlength="50"></td>		</tr>		<tr>			<td width="200"><strong>Tags (Separados por ","):</strong></td>			<td><input type="text" name="cat_tags" size="30" maxlength="100"></td>		</tr>		</table>		<center><input type="submit" name="Crear" value="Ingresar Datos"></center>		</form>		 <?  switch ($accion) {case "ver":	$result=mysql_query("SELECT * FROM Categorias ORDER BY categoria ASC") or die (mysql_error());	echo '<table>';	echo '<tr>';	echo '<td>Categorias</td>';	echo '<td>Tags</td>';	echo '</tr>';	while($row=mysql_fetch_array($result))		{			echo '<tr>';			echo '<td>'.$row['categoria'].'</td>';			echo '<td>'.$row['tags'].'</td>';			$id = $row["id"];			echo '<td><a href="admin.php?site=categorias&accion=edit&id='.$id.'">Editar</a></td>';			echo '<td><a href="admin.php?site=categorias&accion=del&id='.$id.'">Eliminar</a></td>';			echo '</td>';		}	echo '</table>';		mysql_close();break;case "edit":	if ($id == NULL){	 	echo 'No se ha seleccionado una Categoria';	 } else {		echo 'Editar';  	}break;case "del":	if ($id == NULL){	 	echo 'No se ha seleccionado una Categoria';	 } else {		mysql_query('DELETE FROM Categorias WHERE id='.$id) or die (mysql_error());				if(mysql_affected_rows($connect)){					echo "Dato eliminado correctamente";				} else {					echo "Error eliminando dato";				}					}break;case "agregar":		$result=mysql_query("SELECT * FROM Categorias WHERE categoria = '$categoria'") or die (mysql_error());		if(mysql_num_rows($result)){			echo "El Dato ingresado ya existe en la BD";		} else {			mysql_free_result($result);				mysql_query("INSERT INTO Categorias (categoria,tags) VALUES ('$categoria','$cat_tags')");				if(mysql_affected_rows($connect)){					echo "Datos introducidos correctamente";				} else {					echo "Error introduciendo Datos";				}					}}}	?>