
Error al conectar php con phpmyadmin
Publicado por Andres (7 intervenciones) el 03/03/2013 22:40:00
Buenas tardes, les comento que tengo un problema que no logro solucionar al intentar conectar mi script en php con la base de datos de wampserver, intento agregarle datos desde mi html y me lanza un error que dice "SCREAM: Error supression ingnored for: Notice: Undefined index: name in D:\wamp\www\tuimpor\conexionbd.php on line 21" y eso mismo con 3 mas de mis variables y todo eso dentro de unos cuadros rojos, aqui dejo mi codigo php y mi formulario:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<form name="sign" method="post" action="conexionbd.php">
<a style="margin-right:80px">Nombre:</a>
<input type="text" id="name" name="name" size="30" >
<p>
<a style="margin-right:80px">Apellido:</a>
<input type="text" id="lname" name="lname" size="30">
<p>
<a style="margin-right:87px">Correo:</a>
<input type="text" id="mail" name="mail" size="30" >
<p>
<a style="margin-right:39px">Repetir Correo:</a>
<input type="text" id="rmail" name="rmail" size="30" >
<p>
<a style="margin-right:62px">Contraseña:</a>
<input type="password" id="pass" name="pass" size="30" >
<p>
<a style="margin-right:14px">Repetir Contraseña:</a>
<input type="password" id="rpass" name="rpass" size="30" >
<p>
<a style="text-align:left">
<p style="word-spacing:15px">
<input type="submit" value="Enviar">
<button type="button" onClick="reiniciar()" >Reiniciar</button>
</p>
</a>
</form>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="bd1"; // Database name
$tbl_name="usuarios"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$name=$_POST['name'];
$lastname=$_POST['lname'];
$email=$_POST['mail'];
$password=$_POST['pass'];
// Insert data into mysql
$sql="INSERT INTO $tbl_name(Nombre, Apellido, Correo, Contraseña)VALUES('$name', '$lastname', '$email', '$password')";
$result=mysql_query($sql);
if($result){
echo "Successful";
echo "<br>";
echo "<a href='tuimport.html'>Back to main page</a>";
}
else {
echo "ERROR";
}
?>
Valora esta pregunta


0