1
PHP / [AYUDA] Base de Datos
« en: 19 de Diciembre de 2011, 15:51:44 pm »
Bueno yo estoy haciendo una web fan con surpu y tengo un sistema de alertas que he echo hace tiempo entonces quería saber si alguien me puede ayudar con la base de datos :S aquí el código del panel de alertas.
Ayúdenme :L
Código: [Seleccionar]
<?
session_start();
include("conectar.php");
$n=$_SESSION[nick];
$q=mysql_query("SELECT * FROM usuarios WHERE nick='$n'");
$ar=mysql_fetch_array($q);
if($ar[rango] == "Administrador" or $ar[rango] == "Coordinador" or $ar[rango] == "Hobba-Gold" or $ar[rango] == "Hobba-Silver" or $ar[rango] == "Hobba-Bronce" or $ar[rango] == "Moderador") {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<style type="text/css">
<!--
body,td,th {
font-family: Tahoma, Geneva, sans-serif;
font-size: 8pt;
}
-->
</style></head>
<body>
<?
if(isset($_POST['OK'])) {
if($_POST['IP'] == NULL or $_POST['Nombre'] == NULL or $_POST['Razon'] == NULL) {
print('No puedes dejar campos en blanco');
}else{
include("conectar.php");
if(mysql_query("INSERT INTO `alertas` (`nick`,`texto`,`leido`,`autor`,`ip`) VALUES ('$_POST[Nombre]','$_POST[Razon]','No','$_SESSION[nick]','$_POST[IP]')")){
echo "El usuario ha sido alertado.";
} else {
echo mysql_error();
}
}
}
?>
Mi ip :
<?
if (isset( $_SERVER [ 'HTTP_X_FORWARDED_FOR' ])) {
$ip = $_SERVER [ 'HTTP_X_FORWARDED_FOR' ];
}
elseif (isset( $_SERVER [ 'HTTP_VIA' ])) {
$ip = $_SERVER [ 'HTTP_VIA' ];
}
elseif (isset( $_SERVER [ 'REMOTE_ADDR' ])) {
$ip = $_SERVER [ 'REMOTE_ADDR' ];
}
else {
$ip = "Anonima" ;
}
print $ip;
?>
<form method="POST" action="<?=$PHP_SELF;?>">
<p>
<b><font size="1" face="Tahoma">IP a alertar:</font></b><br>
<input name="IP" type="text" style="font-size: 8pt; font-family: Verdana; font-weight: bold" value="<?=$_GET['ip']?>" size="20">
</p>
<p>
<b><font size="1" face="Tahoma">Nombre de Usuario:<br></font></b>
<input name="Nombre" type="text" style="font-size: 8pt; font-family: Verdana; font-weight: bold" value="<?=$_GET['nick']?>" size="20"><br><br>
<b><font face="Tahoma" size="1">Alerta:<br>
<label>
<textarea name="Razon" cols="30" rows="5" id="Razon"></textarea>
</label>
<br />
</font></b><br><input type="submit" value="Enviar" name="OK">
</p>
</form>
<center>
<strong>Alertas: </strong><br />
<br />
<table bgcolor="#E1EDF2" width="440" border="0" cellspacing="" cellpadding="">
<tr>
<td width="100"><strong>Nick</strong></td>
<td width="140"><strong>IP</strong></td>
<td width="100"><strong>Alerta</strong></td>
<td width="100"><strong>Alertado por</strong></td>
<td><strong>Leida</strong></td>
</tr>
</table>
<?
include("conectar.php");
$a = mysql_query("SELECT * FROM alertas ORDER by id DESC LIMIT 0,10");
$rows = mysql_num_rows($a);
if($rows == 0) {
print('No hay alertas');
}else{
print('<table bgcolor="#F7F7F7" cellpadding="2" width="440" border="0" cellspacing="0" cellpadding="0">');
while($datos = mysql_fetch_array($a)) {
print('<tr>
<td width="100"><strong>'.$datos['nick'].'</strong></td>
<td width="140"><strong>'.$datos['ip'].'</strong></td>
<td width="100"><strong>'.$datos['texto'].'</strong></td>
<td width="100"><strong>'.$datos['autor'].'</strong></td>
<td><strong>'.$datos['leido'].'</strong></td>
</tr>');
}
print('</table>');
}
?>
</center>
</body>
</html>
<? }else{ print('No tienes acceso'); } ?>Ayúdenme :L

