Ver Mensaje Individual
  #12 (permalink)  
Antiguo 02/04/2008, 23:50
razer
 
Fecha de Ingreso: marzo-2008
Mensajes: 237
Antigüedad: 16 años, 2 meses
Puntos: 6
Problema con redirección en PHP

Hola, les cuento:

Tengo un formulario.html que hace un action a un register.php
En ese mismo register necesito hacer una redirección, pero no me anda. Si la redirección la pongo en el formulario.html me anda (lo probé).

Les muestro ambos codigos:


formulario.html
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>roScripts.com - ajax validation form</title>
	<script type="text/javascript" src="js/mootools.js"></script>
	<script type="text/javascript">
		window.addEvent('domready', function(){
	                $('registerForm').addEvent('submit', function(e) {
	                    new Event(e).stop();
	                    var log = $('log_res').empty().addClass('ajax-loading');
	                    this.send({
	                        update: log,
	                        onComplete: function() {
	                            log.removeClass('ajax-loading');
	                        }
	                    });
	                });
	            });
	</script>
	<style type="text/css">

		body {
			font:0.7em Arial, helvetica, sens-serif;
			color:#567475;
		}
		.input {
			border: 1px solid #99b3b4;
			width: 220px;
			background: #e4ebeb;
			font: 11px verdana, sans-serif;
			color:#443;
			padding:3px;
			margin-bottom:4px;
			outline:none;
		}
		.input:focus {
			border:1px solid #567475;
			background: #e4ebeb;
		}
		.submit-btn {
			width: 54px;
			height: 20px;
			background: #743 url(http://www.roscripts.com/images/submit.gif) no-repeat;
			outline: none;
		}
		.submit-btn:hover {
			background: #069 url(http://www.roscripts.com/images/submit.gif) no-repeat 0 -20px;
		}
		div#container {
			border:1px solid #99b3b4;
			padding:15px;
			margin:auto;
			width:400px;
		}
		#log_res {
			height:auto;
			padding:15px;
			margin:100px auto 20px auto;
			width:400px;
		}
		#log_res p {
			margin:0;
			padding:4px 0 4px 0;
		}
		#log_res.ajax-loading
			{background: url(http://www.roscripts.com/images/spinner.gif) no-repeat center;
		}
		.error {
			color:red;
			margin:0;
			padding:0;
		}

	</style>
<!--
                     ____                               __
                    /\  _`\                  __        /\ \__
          _ __   ___\ \,\L\_\    ___   _ __ /\_\  _____\ \ ,_\   ____
         /\`'__\/ __`\/_\__ \   /'___\/\`'__\/\ \/\ '__`\ \ \/  /',__\
         \ \ \//\ \L\ \/\ \L\ \/\ \__/\ \ \/ \ \ \ \ \L\ \ \ \_/\__, `\
          \ \_\ \____/\ `\____\ \____\ \_\  \ \_\ \ ,__/\ \__\/\____/
           \/_/ \/___/  \/_____/\/____/ \/_/   \/_/\ \ \/  \/__/\/___/
                                                    \ \_\
                                                     \/_/
                                                Making your world easy
-->
</head>
<body>
	<div id="log">
		<div id="log_res">
		<!-- SPANNER -->
		</div>
	</div>
	<div id="container">
	<form method="post" id="registerForm" action="register.php">
          <table align="center" cellpadding="2" cellspacing="0">
            <tr>
              <td style="width:120px"><div align="left"><strong><LABEL for="First_name">First name:</LABEL></strong></div></td>
              <td><div align="left" class="string">
                <input name="First_name" type="text" class="input" id="First_name" value="" size="32" /></div>
              </td>
            </tr>
            <tr>
              <td style="width:120px"><div align="left"><strong><LABEL for="Last_name">Last name:</LABEL></strong></div></td>
              <td><div align="left">
                <input name="Last_name" class="input" type="text" id="Last_name" value="" size="32" /></div></td>
            </tr>
            <tr>
              <td style="width:120px"><div align="left"><strong><LABEL for="Username">Username:</LABEL></strong></div></td>
              <td><div align="left">
                <input name="Username" type="text" class="input" id="Username" value="" size="32" /></div>
              </td>
            </tr>
            <tr>
              <td style="width:120px"><div align="left"><strong><LABEL for="Password">Password:</LABEL></strong></div></td>
              <td><div align="left">
              <input name="Password" type="password" class="input" id="Password" value="" size="32" /></div></td>
            </tr>
            <tr>

              <td style="width:120px"><div align="left"><strong><LABEL for="re_Password">Re-type Password:</LABEL></strong></div></td>
              <td><div align="left">
              <input name="re_Password" type="password" class="input" id="re_Password" value="" size="32" /></div></td>
            </tr>
            <tr>

              <td style="width:120px"><div align="left"><strong><LABEL for="Email">Email:</LABEL></strong></div></td>
              <td><div align="left">
              <input name="Email" type="text" class="input" id="Email" value="" size="32" /></div></td>
            </tr>
            <tr>
              <td colspan="2"><div align="right">
                  <input type="image" name="register" class="submit-btn" src="http://www.roscripts.com/images/btn.gif" alt="submit" title="submit" />
              </div></td>
            </tr>
          </table>
        </form>
        </div>
</body>
</html>


y este es el register.php
Código:
<?php

	include('functions.php');

	if ($_POST['First_name']=='' || strlen($_POST['First_name'])<3)
	{
		$errors[] = 'First name is required and must contain 3 characters or more';
	}

	if ($_POST['Last_name']=='' || strlen($_POST['Last_name'])<3)
	{
		$errors[] = 'Last name is required and must contain 3 characters or more';
	}

	if ($_POST['Username']=='' || alpha_numeric($_POST['Username'])==FALSE)
	{
		$errors[] = 'Username is required and must be alpha-numeric';
	}

	if ($_POST['Password']=='' || alpha_numeric($_POST['Password'])==FALSE)
	{
		$errors[] = 'A password is required and must be alpha-numeric';
	}

	if ($_POST['Password']!=$_POST['re_Password'])
	{
		$errors[] = 'The two passwords must match';
	}

	if (valid_email($_POST['Email'])==FALSE)
	{
		$errors[] = 'Please supply a valid email address';
	}

	if(isset($errors))
	{
		echo '<p class="error"><b>The following errors occured</b></p>';
		while (list($key,$value) = each($errors))
		{

			echo '<span class="error">'.$value.'</span><br />';
		}
	}
	else {
		
		//do something here----store to db, send email
		echo '<p><b>Success!</b></p>';
		echo '<span>Your registration was successfully processed. You may login and start using your account. Thank you for registering !</span>'; 
		echo "<meta http-equiv='refresh' content='0;url=desauto.php'>";
	
	}

?>
Como pueden observar en el register.php, la redireccion esta al final. Es esta LINEA:
Código:
echo "<meta http-equiv='refresh' content='0;url=desauto.php'>";
pero NO ME DA BOLA. dice el mensaje de arriba pero no redirecciona y no me dice nada. Alguien tiene idea?
Probe con header(location:link.php); de php y no solo no me da bola, sino que me da el siguiente error: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\ajax_validation\register.php:47) in c:\program files\easyphp1-8\www\ajax_validation\register.php on line 50

Alguien por favor que me diga una forma de redirección y que funcione, es sencillo pero ya no se que hacer

Última edición por razer; 03/04/2008 a las 01:12