Bueno en un modulo, de la web donde estoy implementando esto hay 3 botones de submit, tienen el mismo nombre name=accion y segun sea, Grabar, Cancelar o Borrar es lo que ejecuto el sistema, estoy intentando implementarlo, pero no funciona checo y no le esta llegando el valor de accion, pero si le llega al de comprobar por lo tanto no hace nada.
usuario valido foros
http://www.tellosite.com/forosdelweb/prueba.php Código PHP:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Problemas con formulario</title>
<script type="text/javascript">
function comprobar(){
var ops = "status=yes,width=400,height=260,top=" + (screen.height / 2 - 130) + ",left=" + (screen.width / 2 - 200);
window.open("", "comprobar", ops);
document.forms["datos"].submit();
}
</script>
</head>
<body>
<form id="datos" method="POST" name="datos" action="comprobar.php" target="comprobar">
<input type="text" id="nombre" name="nombre" size="20"> foros
<div id=boton>
<input id="grabar" name="accion" onclick="comprobar()" type="submit" value="Grabar">
<input id="borrar" name="accion" type="submit" value="Borrar">
<input id="cancelar" name="accion" type="submit" value="Cancelar">
<input type="reset" value="Reset">
</div>
</form>
</body>
</html>
http://www.tellosite.com/forosdelweb/comprobar.php tiene codigo php, lo unico que hace es comprobar el usuario si el usuario esta bien
<body onload="ok()"> si esta mal <body onload="error()"> tambien imprime todas lo que le llego del form
Código PHP:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<script type="text/javascript">
function error(){
//window.self.close();
opener.alert("Nombre de usuario no existe");
opener.document.forms["datos"].nombre.focus();
opener.document.forms["datos"].nombre.select();
return false;
}
function ok(){
//window.self.close();
opener.document.forms["datos"].action="procesa.php";
opener.document.forms["datos"].target="_self";
opener.document.forms["datos"].submit();
return true;
}
</script>
<?php
$usuario = $_POST['nombre'];
if ($usuario == foros){
echo '<body onload="ok()">';
}else{
echo '<body onload="error()">';
}
print_r($_POST);
?>
</head>
</body>
</html>
http://www.tellosite.com/forosdelweb/procesa.php
Solo imprime lo que le llega del formulario si comparamos lo que le llega a comprobar.php y procesa.php falta accion= en procesa.php
Asi que como hacerle para que un submit tenga un action otro submit y otro action, y otro target, y para que accion no pierda su valor de ventana en ventana.