2012-08-17 31 views
5

¿Puede alguien decirme por qué diantres no se está sometiendo a sí mismo?Formulario HTML Someterse a sí mismo

que tienen la siguiente configuración:

<?php 
    print_r($_POST); 
?> 

<form name="bizLoginForm" method="post" action"" > 
    <table id="loginTable"> 
     <tr><td>Username:</td><td><input type="text" id="loginUsername" /></td></tr> 
     <tr><td>Password:</td><td><input type="password" id="loginPassword" /></td></tr> 
    </table> 
    <input type="Submit" value="Login" /> 
</form> 

y cada vez que haga clic en el botón de enviar veo nada dentro de la matriz POST. ¿Qué cosa tan simple he pasado por alto?

Gracias!

Respuesta

8

Aparte del hecho de los iguales se encuentra en su atributo action en su elemento de formulario.

Sus entradas necesitan atributos nombre:

<tr> 
    <td>Username:</td> 
    <td><input id="loginUsername" name="loginUsername" type="text" /></td> 
</tr> 
+0

Esa es la respuesta correcta. –

+0

¡ah, ja! ¡¡Gracias!! – ackerchez

8
<form name="bizLoginForm" method="post" action"" > 

debería ser

<form name="bizLoginForm" method="post" action="" > 

Missing signo =.

También se está perdiendo el atributo nombre dentro de las etiquetas de entrada, por lo que cambiar

<input type="text" id="loginUsername" /> 

y

<input type="password" id="loginPassword" /> 

a

<input type="text" id="loginUsername" name="loginUsername" /> 

y

<input type="password" id="loginPassword" name="loginPassword" /> 
+0

ARUGH !!! DOH !!! – ackerchez

+0

:-) html necesita un compilador tal vez? – sjobe

+0

um, eso no lo hizo ... – ackerchez

4
  • Debe añadir es igual a señal entre acción y ""
  • también especifican nombre atributo para cada campo de entrada.

<?php 
    print_r($_POST); 
?> 

<form name="bizLoginForm" method="post" action="" > 
    <table id="loginTable"> 
     <tr><td>Username:</td><td><input type="text" name="login" id="loginUsername" /></td></tr> 
     <tr><td>Password:</td><td><input type="password" name="password" id="loginPassword" /></td></tr> 
    </table> 
    <input type="Submit" value="Login" /></form> 
0

probar esto

<?php 
if(isset($_GET["submitted"])){ 
    print_r($_POST["values"]); 
} else { 
?> 
<form name="bizLoginForm" method="post" action="?submitted" > 
    <table id="loginTable"> 
     <tr><td>Username:</td><td><input type="text" name="values[]" id="loginUsername" /></td></tr> 
     <tr><td>Password:</td><td><input type="password" name="values[]" id="loginPassword" /></td></tr> 
    </table> 
    <input type="Submit" value="Login" /> 
</form> 
<?php 
} 
?> 
2

Prueba este

<?php 
    if(isset($_POST['submit_button'])) 
     print_r($_POST); 
?> 

<form name="bizLoginForm" method="post" action"<?php echo $_SERVER['PHP_SELF']?>" > 
    <table id="loginTable"> 
    <tr><td>Username:</td><td><input type="text" id="loginUsername" /></td></tr> 
    <tr><td>Password:</td><td><input type="password" id="loginPassword" /></td></tr> 
    </table> 
    <input type="Submit" name="submit_button" value="Login" /> 
</form> 

Guardar el archivo con extensión .php

Cuestiones relacionadas