Luis Martin
1
Lambda
Verificado
Verificación en dos pasos activada
Verificado por Whatsapp
¡Ha verificado su Paypal!
Verificado por Binance
Suscripción a IA
Hola, tengo dias en este proyecto pero no he conseguido solucion, intento crear una base de datos para mi negocio desde un servidor local con wampserver, y lo que he intentado es crear una pagina php, donde muestre los clientes registrados y en otra, mediante un formulario, poder ingresar nuevos clientes, pero no me funciona, a continuacion muestro los codigos utilizados:
Pagina para conectar con phpmyadmin: base.php
Pagina de formulario para ingresar nuevos registros a la base de datos: nuevo.php
Pagina para procesar el formulario: add_reg.php
y por ultimo, la pagina donde muestro todos los registros en la base de datos:
Problemas:
1.Al ir a nuevo.php y rellenar el formulario, doy enviar y me envia a add_reg.php, donde salen los siguientes mensajes:
Por lo cual no se envian los nuevos registros.
Cabe destacar: que esta es la base de datos en phpmyadmin:


Ademas procedo a subir todos los archivos, incluyendo la base de datos:
Enlace Dropbox
Si alguien me ayuda lo agradeceria muchisimo :encouragement:
Pagina para conectar con phpmyadmin: base.php
Insertar CODE, HTML o PHP:
<?php
$host = "localhost";
$user = "root";
$pw= "";
$bd = "centro_optico_mm";
$link = mysql_connect($host,$user,$pw);
mysql_select_db($bd,$link);
?>
Pagina de formulario para ingresar nuevos registros a la base de datos: nuevo.php
Insertar CODE, HTML o PHP:
<html>
<body>
<form method="post" action="add_reg.php">
Nombre: <input type="text" name="Nombre"><p>
Apellido: <input type="text" name="Apellido"><p>
Telefono <input type="text" name="Telefono"><p>
<br>
<a>Correccion:</a>
<br>
O.D: <input type="text" name="O.D"> Cil: <input type="text" name="CilDerecho"> Eje: <input type="text" name="EjeDerecho"> Add: <input type="text" name="AddDerecho"><p>
O.I: <input type="text" name="O.I"> Cil: <input type="text" name="CilIzquierdo"> Eje: <input type="text" name="EjeIzquierdo"> Add: <input type="text" name="AddIzquierdo"><p><p>
Tipo: <input type="text" name="Tipo"><p>
<input type="submit" name="enviar" value="enviar">
</form>
</body>
</html>
Pagina para procesar el formulario: add_reg.php
Insertar CODE, HTML o PHP:
<?php
include("base.php");
if(1==1)
{
$con = mysql_connect($host,$user,$pw)
or die("problemas al conectar al servidor");
mysql_select_db($bd,$con)
or die("problemas al conectar a la base de datos");
mysql_query("INSERT INTO cliente (Nombre,Apellido,Telefono,OD,CilDerecho,EjeDerecho,AddDerecho,OI,CilIzquierdo,EjeIzquierdo,AddIzquierdo,Tipo)
values ('$_POST[Nombre]','$_POST[Apellido]','$_POST[Telefono]','$_POST[OD]','$_POST[CilDerecho]','$_POST[EjeDerecho]','$_POST[AddDerecho]','$_POST[OI]','$_POST[CilIzquierdo]','$_POST[EjeIzquierdo]','$_POST[AddIzquierdo]','$_POST[Tipo]'",$con);
}
else {
echo "Ocurrió un error";
}
?>
y por ultimo, la pagina donde muestro todos los registros en la base de datos:
Insertar CODE, HTML o PHP:
<html>
<head><title>Listado completo de Registros</title>
<link rel="stylesheet" type="text/css" href="tabla.css"/>
</head>
<body>
<div class="datagrid">
<?php
$sql = "SELECT * FROM cliente ORDER BY Nombre";
include ("base.php");
$result = mysql_query($sql) or die (mysql_error());
if ($row = mysql_fetch_array($result))
{
echo "<table border = '1' width='50%'>";
mysql_field_seek($result,0); //
while ($field = mysql_fetch_field($result)){
}
echo "<thead> \n";
echo '<tr>';
echo '<th width="5%">'."ID".'</th>';
echo '<th width="15%">'."Nombre".'</th>';
echo '<th width="15%">'."Apellido".'</th>';
echo '<th width="15%">'."Telefono".'</th>';
echo '<th width="15%">'."OD".'</th>';
echo '<th width="15%">'."CilDerecho".'</th>';
echo '<th width="15%">'."EjeDerecho".'</th>';
echo '<th width="15%">'."AddDerecho".'</th>';
echo '<th width="15%">'."OI".'</th>';
echo '<th width="15%">'."CilIzquierdo".'</th>';
echo '<th width="15%">'."EjeIzquierdo".'</th>';
echo '<th width="15%">'."AddIzquierdo".'</th>';
echo '<th width="15%">'."Tipo".'</th>';
echo '<th width="15%">'."Modificar".'</th>';
echo '<th width="15%">'."Borrar".'</th>';
echo '</tr>';
echo '</tr>';
echo "</thead> \n";
do {
echo '<tr>';
echo "<td width='5%'>".$row["Nombre"]."</td> \n";
echo "<td>".$row["Nombre"]."</td> \n";
echo "<td>".$row["Apellido"]."</td> \n";
echo "<td>".$row["Telefono"]."</td> \n";
echo "<td>".$row["OD"]."</td> \n";
echo "<td>".$row["CilDerecho"]."</td> \n";
echo "<td>".$row["EjeDerecho"]."</td> \n";
echo "<td>".$row["AddDerecho"]."</td> \n";
echo "<td>".$row["OI"]."</td> \n";
echo "<td>".$row["CilIzquierdo"]."</td> \n";
echo "<td>".$row["EjeIzquierdo"]."</td> \n";
echo "<td>".$row["AddIzquierdo"]."</td> \n";
echo "<td>".$row["Tipo"]."</td> \n";
echo "</tr>";
}
while ($row = mysql_fetch_array($result));
echo "</table>";
echo '<p><a href="index.html">Volver</a></p>';
} else
{
echo "<p>No se ha encontrado ningún registro</p>";
echo '<p><a href="index.html">Volver</a></p>';
}
?>
</div>
</body>
</html>
Problemas:
1.Al ir a nuevo.php y rellenar el formulario, doy enviar y me envia a add_reg.php, donde salen los siguientes mensajes:
( ! ) Notice: Undefined index: OD in C:\wamp\www\Centro Optico MM\add_reg.php on line 14
Call Stack
# Time Memory Function Location
1 0.0265 147224 {main}( ) ..\add_reg.php:0
( ! ) Notice: Undefined index: OI in C:\wamp\www\Centro Optico MM\add_reg.php on line 14
Call Stack
# Time Memory Function Location
1 0.0265 147224 {main}( ) ..\add_reg.php:0
Por lo cual no se envian los nuevos registros.
Cabe destacar: que esta es la base de datos en phpmyadmin:


Ademas procedo a subir todos los archivos, incluyendo la base de datos:
Enlace Dropbox
Si alguien me ayuda lo agradeceria muchisimo :encouragement: