vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   PHP Redirect (https://vborg.vbsupport.ru/showthread.php?t=206347)

Winterworks 02-23-2009 02:35 PM

PHP Redirect
 
I have a PHP contact code on my site... Right now, after you submit a contact form, it comes up with...

Code:

Data has been submitted to $to!
Because of the codes...

Code:

echo "Data has been submitted to $to!";
mail($to, $subject, $body);

In the .php file. Now, instead of it showing that, how can I make it redirect to another page instead?

CoolHandLuc 02-23-2009 02:48 PM

PHP Code:

<?php
header
("Location: http://www.example.com/"); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */
exit;
?>


Winterworks 02-23-2009 03:02 PM

that's not my whole code.

Code:

<?php
if(isset($_POST['submit'])) {

$to = "mikemersereau@hotmail.com";
$subject = "Client Testimonial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
 
$body = "From: $name_field\n Email: $email_field\n Testimonial:\n $message";
 
echo "Data has been submitted to $to!";
mail($to, $subject, $body);

} else {

echo "error";

}
?>

I just need to know what to put where it says the "echo "Data has been...""

ragtek 02-23-2009 03:05 PM

1.
PHP Code:

$body "From: $name_field\n Email: $email_field\n Testimonial:\n $message";
 
mail($to$subject$body);
header("Location: http://www.example.com/"); /* Redirect browser */ 
exit();


the redirect have to be after the mail function!

Winterworks 02-23-2009 03:06 PM

ah, thank you very much!

TigerC10 02-23-2009 03:51 PM

I recommend something a little more standard...

PHP Code:

$vbulletin->url 'index.php' $vbulletin->session->vars['sessionurl_q'];
eval( 
print_standard_redirect("Data has been submitted to ".$to."!"falsetrue) ); 

That way, it keeps the look of your style, and doesn't deal with the complications that come with the above samples.

Winterworks 02-23-2009 03:55 PM

sorry, you probably do not know this, but it is not for vbulletin, just for a general webpage.

TigerC10 02-23-2009 04:02 PM

Oh, I see. Then don't use the exit() function (it does some wonky things between different versions of PHP).

PHP Code:

ob_start();

//your code
echo "Data has been submitted to $to!";
mail($to$subject$body);

header("Location: http://www.google.com");
ob_end_flush(); 

This is much better.


All times are GMT. The time now is 03:09 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01080 seconds
  • Memory Usage 1,731KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete