Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
| Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 7th, 2007, 09:13 AM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How redirect to a new page after submit form...

Hello

I have the following code. I want to load a new page after send the form but does not work. Anybody knows why?? Thanks a lot!!:)

<?
if (!$HTTP_POST_VARS){
?>
            <form action="contacto.php" method="post">
            <label for="user">Nombre y Apellidos</label>
            <input class="campo" type="text" name="nombre" value="" /><br />
            <label for="emailaddress">Direccion de email</label>
            <input class="campo" type="text" name="email" value="" /><br />
            <label for="comments">Comentarios</label>
            <textarea cols="1" rows="1" name="comentario"></textarea><br />
            <input class="button" type="submit" name="submitbutton" value="Enviar" />
            </form>

<?
}else{

$cuerpo = "Formulario enviado\n";
$cuerpo .= "Nombre: " . $HTTP_POST_VARS["nombre"] . "\n";
$cuerpo .= "Email: " . $HTTP_POST_VARS["email"] . "\n";
$cuerpo .= "Comentarios: " . $HTTP_POST_VARS["comentario"] . "\n";

//send the mail...
mail("xxx@xxx.com","Formulario recibido",$cuerpo);
header('location:newpage.php');
    }
    ?>

  #2 (permalink)  
Old February 8th, 2007, 11:22 AM
Authorized User
 
Join Date: Nov 2006
Location: , , United Kingdom.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mark jonas
Default

give this a try mate it is what i have been using and if you have a problem still let us no what the error is or what it shows on the screen.


$link = "newpage.php";
header('location:'. $link);


mark


also look here
http://p2p.wrox.com/topic.asp?TOPIC_ID=11882
  #3 (permalink)  
Old February 9th, 2007, 05:28 PM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Mark thanks for your help but it still does not work. The form send the content properly but after that does not redirect to the new page.
Any PHP workaround?

Thanks

  #4 (permalink)  
Old February 12th, 2007, 06:17 AM
Authorized User
 
Join Date: Nov 2006
Location: , , United Kingdom.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mark jonas
Default

morning

ok i just been having a play with your code and it was working for me are you shore your calling to the right page as i managed to get it to go to every page.

other then that it may be how the server has been set up.But dont hold me to that as i still have a very basic understanding on things in that area.

hope you get it sorted if i think of anything else i will let you no mate

mark

p.s also check that you dont have any out put visal out put before the header as that will not make it work but possable still send the email
  #5 (permalink)  
Old February 12th, 2007, 06:49 AM
Authorized User
 
Join Date: Feb 2007
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi


i think header('location:newpage.php');

in that line location should be Location i.e. first letter Capital and aslo some URL to redirect like http://www.example.com/newpage.php

so header('Location: http://www.example.com/newpage.php');


Well i hope it works. Please let me know if it is working or not.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form post page redirect problem - S.O.S. jroxit ASP.NET 1.0 and 1.1 Professional 4 May 21st, 2008 11:06 AM
submit form and jump on previous page sanjeev jha Classic ASP Basics 0 November 3rd, 2007 06:18 AM
Redirect to new page without closing current page peter2004 ASP.NET 2.0 Basics 5 June 5th, 2006 08:49 PM
Form Validation and Redirect Page jourys ASP.NET 1.0 and 1.1 Basics 1 February 24th, 2006 12:20 PM
How can we submit a form without a submit butto phpsharma BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 4 October 20th, 2003 08:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.