Re: error php-mysql formulario registro. Perdon
Publicado por rodrhy (2 intervenciones) el 30/01/2012 14:26:19
Hola a todos:
Mi problema es el siguiente: quiero hacer un registro de usuario sencillo en php, pero a la hora de leer las respuestas enviadas por el formulario algo va mal ya que me dice siempre que rellene todos los campos, por más y más vueltas que le he dado no he conseguido solucionarlo, así que no me queda más que pedir ayuda, gracias. El código es el siguiente:
Mi problema es el siguiente: quiero hacer un registro de usuario sencillo en php, pero a la hora de leer las respuestas enviadas por el formulario algo va mal ya que me dice siempre que rellene todos los campos, por más y más vueltas que le he dado no he conseguido solucionarlo, así que no me queda más que pedir ayuda, gracias. El código es el siguiente:
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
[...]
function formRegistro() {
?>
<div class="registro">
<table>
<tr>
<th colspan="2"><h2>Registro de usuario</h2></th>
</tr>
<form action="index.php" method="post">
<tr>
<th>Usuario:</th>
<th><input type="text" name="usuario" size="25" maxlength="30" /></th>
</tr>
<tr>
<th>Contraseña:</th>
<th><input type="password" name="password" size="25" maxlength="30" /></th>
</tr>
<tr>
<th>Confirma:</th>
<th><input type="password" name="password2" size="25" maxlength="30" /></th>
</tr>
<tr>
<th>Email:</th>
<th><input type="text" name="email" size="25" maxlength="40" /></th>
</tr>
<tr>
<th>Código Postal</th>
<th align="right"><input type="text" name="cp" size="5" maxlength="5" /></th>
</tr>
<tr>
<th>Nacimiento (aaaa-mm-dd):</th>
<th align="right"><input type="text" name="nacimiento" size="10" maxlength="10" /></th>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" value="Registrar" /></td>
</tr>
</form>
</table>
</div>
<?php
}
if (isset($_POST["usuario"]))
{
$usuario = $_POST["usuario"];
$password = $_POST["password"];
$password2 = $_POST["password2"];
$email = $_POST["email"];
$cp = $_POST["cp"];
$nacimiento = $_POST["nacimiento"];
if($username==NULL|$password==NULL|$password2==NULL|$email==NULL|$nacimiento==NULL|$cp==NULL)
{
echo "<div class='error'>Almenos un campo está vacio.</div>";
formRegistro();
}
[...]
Valora esta pregunta


0