Estimados amigos.
Mi problema es el siguiente:
Tengo una web con PHP y base de datos MySQL.
Dentro de ella hay 3 documentos entre los que está el problema.
areaprivada.php
Donde se introduce usuario y contraseña y se accede a consultas.php
En consultas.php se ven una avanzadilla de los datos de cada cliente.
Si pinchamos en un cliente en concreto, accedemos a la página
datos_cliente.php
En datos_cliente.php tenemos todos los datos de ese cliente en concreto.
El documento que se genera es del tipo:
www.............../datos_cliente.php?Id=62
Si alguien teclea esa dirección en google, accede directamente a esos datos.
No quiero que eso ocurra.
¿Cómo lo puedo solucionar?
Soy bastante novato en esto así que si me lo podéis explicar muy claro o aún mejor si me dais un código que deba introducir, os lo agradecería.
Envío los códigos de las dos páginas:
consultas.php
<?php require_once('Connections/conexionconsultas.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];
?>
<?php require_once('Connections/conexionconsultas.php'); ?>
<?php
$maxRows_con = 25;
$pageNum_con = 0;
if (isset($_GET['pageNum_con'])) {
$pageNum_con = $_GET['pageNum_con'];
}
$startRow_con = $pageNum_con * $maxRows_con;
mysql_select_db($database_conexionconsultas, $conexionconsultas);
$query_con = "SELECT * FROM `general` ORDER BY Id DESC";
$query_limit_con = sprintf("%s LIMIT %d, %d", $query_con, $startRow_con, $maxRows_con);
$con = mysql_query($query_limit_con, $conexionconsultas) or die(mysql_error());
$row_con = mysql_fetch_assoc($con);
if (isset($_GET['totalRows_con'])) {
$totalRows_con = $_GET['totalRows_con'];
} else {
$all_con = mysql_query($query_con);
$totalRows_con = mysql_num_rows($all_con);
}
$totalPages_con = ceil($totalRows_con/$maxRows_con)-1;
$queryString_con = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_con") == false &&
stristr($param, "totalRows_con") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_con = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_con = sprintf("&totalRows_con=%d%s", $totalRows_con, $queryString_con);
?><!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=iso-8859-1" />
<title>Reformar piso, reformas vivienda, reforma hogar, reformas cocina</title>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<META NAME="Description" CONTENT="Presupuestos gratuitos para sus obras y reformas realizados por empresas de su ciudad. Reformas de viviendas, reformas de cocinas, reformas de baños... Todo en reformas.">
<META NAME="Keywords" CONTENT="reformas,presupuestos,reforma,presupuesto ,obras,obra,construcciones,construccion,obras y reformas,obras reformas,presupuesto de reforma,presupuesto reforma,precio reforma,presupuestos gratis,reformas madrid,reformas valencia,reformas galicia,reformas barcelona,reformas mejor precio,presupuestos reforma">
<META NAME="Generator" CONTENT="macromedia dreamweaver 8">
<META NAME="Language" CONTENT="Spanish">
<META NAME="Revisit" CONTENT="1 day">
<style type="text/css">
<!--
.Estilo12 {color: #990000;
font-weight: bold;
}
-->
</style>
<script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<body>
<p> </p>
<table width="760" align="center">
<?php do { ?>
<?php
$unafecha = explode ("-",$row_con['Fecha']);
?>
<tr bgcolor="#FFCC99">
<td width="85"><?php echo $unafecha[2]."-".$unafecha[1]."-".$unafecha[0]; ?></td>
<td width="412"><div align="center"><?php echo $row_con['reforma']; ?></div></td>
<td width="146"><?php echo $row_con['Localidad']; ?></td>
<td><?php echo $row_con['Provincia']; ?></td>
</tr>
<tr bgcolor="#FFFFCC">
<td width="85" valign="middle">reformas <?php echo $row_con['Provincia']; ?></td>
<td colspan="2"><?php echo $row_con['Descripción']; ?></td>
<td width="97"><div align="center"><a href="datos_cliente.php?Id=<?php echo $row_con['Id']; ?>" target="_blank">VER</a></div></td>
</tr>
<?php } while ($row_con = mysql_fetch_assoc($con)); ?>
</table>
<br />
<table width="760" align="center">
<tr>
<td width="114"><div align="center">
<?php if ($pageNum_con > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_con=%d%s", $currentPage, max(0, $pageNum_con - 1), $queryString_con); ?>" target="_blank">Anterior</a>
<?php } // Show if not first page ?>
</div></td>
<td width="511"> </td>
<td width="119"><div align="center">
<?php if ($pageNum_con < $totalPages_con) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_con=%d%s", $currentPage, min($totalPages_con, $pageNum_con + 1), $queryString_con); ?>" target="_blank">Siguiente</a>
<?php } // Show if not last page ?>
</div></td>
</tr>
</table>
<p> </p>
</body>
</html>
<?php
mysql_free_result($con);
?>
datos-cliente.php
<?php require_once('Connections/conexionconsultas.php'); ?>
<?php
$colname_cliente = "-1";
if (isset($_GET['Id'])) {
$colname_cliente = (get_magic_quotes_gpc()) ? $_GET['Id'] : addslashes($_GET['Id']);
}
mysql_select_db($database_conexionconsultas, $conexionconsultas);
$query_cliente = sprintf("SELECT * FROM `general` WHERE Id = %s", $colname_cliente);
$cliente = mysql_query($query_cliente, $conexionconsultas) or die(mysql_error());
$row_cliente = mysql_fetch_assoc($cliente);
$totalRows_cliente = mysql_num_rows($cliente);
?><!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=iso-8859-1" />
<title>Reformar piso, reforma hogar, reformas vivienda, reformas</title>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<META NAME="Description" CONTENT="Presupuestos gratuitos para sus obras y reformas realizados por empresas de su ciudad. Reformas de viviendas, reformas de cocinas, reformas de baños... Todo en reformas.">
<META NAME="Keywords" CONTENT="reformas,presupuestos,reforma,presupuesto ,obras,obra,construcciones,construccion,obras y reformas,obras reformas,presupuesto de reforma,presupuesto reforma,precio reforma,presupuestos gratis,reformas madrid,reformas valencia,reformas galicia,reformas barcelona,reformas mejor precio,presupuestos reforma">
<META NAME="Generator" CONTENT="macromedia dreamweaver 8">
<META NAME="Language" CONTENT="Spanish">
<META NAME="Revisit" CONTENT="1 day">
<style type="text/css">
<!--
.Estilo12 {color: #990000;
font-weight: bold;
}
-->
</style>
<script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<body>
<p> </p>
<table width="500" align="center" bgcolor="#FFCC99">
<tr>
<td width="9"> </td>
<td width="97"><?php
$unafecha = explode ("-",$row_cliente['Fecha']);
?>
<?php echo $unafecha[2]."-".$unafecha[1]."-".$unafecha[0]; ?>
<td width="378"><div align="center"><?php echo $row_cliente['reforma']; ?></div></td>
</tr>
</table>
<br />
<table width="500" align="center" bgcolor="#FFFFCC">
<tr>
<td width="113">Nombre:</td>
<td width="375"><?php echo $row_cliente['Nombre_ y _Apellidos']; ?></td>
</tr>
<tr>
<td>Dirección:</td>
<td><?php echo $row_cliente['Dirección']; ?></td>
</tr>
<tr>
<td>Teléfono:</td>
<td><?php echo $row_cliente['Teléfono']; ?></td>
</tr>
<tr>
<td>Email:</td>
<td><?php echo $row_cliente['Email']; ?></td>
</tr>
<tr>
<td>Localidad:</td>
<td><?php echo $row_cliente['Localidad']; ?></td>
</tr>
<tr>
<td>Provincia:</td>
<td><?php echo $row_cliente['Provincia']; ?></td>
</tr>
<tr>
<td>Código Postal: </td>
<td><?php echo $row_cliente['Código_ postal']; ?></td>
</tr>
<tr>
<td>Inicio de la obra: </td>
<td><?php echo $row_cliente['Plazo_ de_ inicio']; ?></td>
</tr>
</table>
<table width="500" align="center">
<tr>
<td width="767"><div align="center" class="Estilo12">Trabajos a realizar </div></td>
</tr>
</table>
<table width="500" align="center" bgcolor="#FFCC99">
<tr>
<td><?php echo $row_cliente['Descripción']; ?></td>
</tr>
</table>
<p> </p>
</body>
</html>
<?php
mysql_free_result($cliente);
?>