由于管理员将帖子作为维基页面移动,因为问题永远不会得到解决,因为有一个简单的拼写错误被认为是PHP文件中的问题,但这不是造成问题的原因。“ / p>
请帮助我能够重定向到感谢页面。 我在Javascript和PHP文件中尝试了很多重定向,但似乎无法弄明白。
当我点击提交按钮时,电子邮件详细信息会完美发送,但页面不会重定向。
提前致谢
亚当
/* ==================================
Hero Form Validation
=====================================*/
$('#hero-submit').click(function(e){
// Stop form submission & check the validation
e.preventDefault();
// Variable declaration
var error = false;
var fname = $('#hero-fname').val();
var email = $('#hero-email').val();
var username = $('#hero-username').val();
// Form field validation
if(fname.length == 0){
var error = true;
$('#hero-fname').parent('div').addClass('field-error');
}else{
$('#hero-fname').parent('div').removeClass('field-error');
}
if(email.length == 0 || email.indexOf('@') == '-1'){
var error = true;
$('#hero-email').parent('div').addClass('field-error');
}else{
$('#hero-email').parent('div').removeClass('field-error');
}
if(username.length == 0){
var error = true;
$('#hero-username').parent('div').addClass('field-error');
}else{
$('#hero-username').parent('div').removeClass('field-error');
}
if(error == true){
$('#hero-error-notification').addClass('show-up');
}else{
$('#hero-error-notification').removeClass('show-up');
}
if(error == false){
$.post("hero-form.php", $("#register-form").serialize(),function(result){
if(result == 'sent'){
window.location.replace("http://SOMESITE.COM/ppi/page2.html");
$('#hero-success-notification').addClass('show-up');
$('#hero-submit').addClass('disabled');
}
});
}
});
// Function to close the Notification
$('a.notification-close').click(function(){
$(this).parent('div').fadeOut(200);
});
<?php
$subject = 'Register New Account on Urip Landing Page'; // Subject of your email
$to = 'TO-EMAIL@DOMAIN.COM'; //Recipient's or Your E-mail
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= "From: " . $_REQUEST['email'] . "\r\n"; // Sender's E-mail
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message = 'ACCOUNT DETAILS: ' . "<br>";
$message .= 'Username: ' . $_REQUEST['username'] . "<br>";
$message .= 'First Name: ' . $_REQUEST['fname'] . "<br>";
$message .= 'Last Name: ' . $_REQUEST['lname'] . "<br>";
$message .= 'Email Address: ' . $_REQUEST['email'] . "<br>";
$message .= 'Phone Number: ' . $_REQUEST['phone'];
////// Redirect user after submitting form
$redirect_thankyou = 'http://SOMESITE.COM/ppi/page2.html';
$redirect_error = 'http://SOMESITE.COM/ppi/page3.html';
if (mail($to, $subject, $message, $headers)) {
header("Location: $redirect_thankyou");
exit();
}
else
{
header("Location: $redirect_error");
exit();
}
?>
<!--DOCTYPE html -->
<html><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<!-- CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Droid+Serif:400,400italic|Montserrat:700,400|Varela+Round">
<!-- Font Icon -->
<link rel="stylesheet" href="fonts/icomoon/icomoon.css">
<!-- Swipebox -->
<link rel="stylesheet" href="css/swipebox.css">
<!-- Animate CSS -->
<link rel="stylesheet" href="css/animate.min.css">
<!-- Slick CSS -->
<link rel="stylesheet" href="js/slick/slick.css">
<link rel="stylesheet" href="js/slick/slick-theme.css">
<!-- Custom CSS -->
<link rel="stylesheet" href="css/style-v2.css">
<link rel="stylesheet" href="css/style-responsive-v2.css">
<link rel="stylesheet" href="css/expandableGallery.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="js/modernizr.js"></script> <!-- Modernizr -->
</head>
<body>
<div id="page" class="page main">
<!--
==========================
== BEGIN HEADER CONTENT ==
==========================
-->
<header id="main-header" class="the-header the-origin-header">
<div class="container">
<div class="row">
<div class="col-lg-12">
<a href="#0" class="logo"><img src="images/logo.png" alt="Urip Logo" style="outline: none; cursor: inherit;"></a> <!-- Your Logo -->
<a href="#0" id="nav-menu-trigger" class="menu-toggle pull-right all-caps">Menu<span class="icon-menu5"></span></a> <!-- Menu Toggle -->
</div> <!--/ .col-lg-12 -->
</div> <!--/ .row -->
</div> <!--/ .container -->
</header>
<!--
=========================
==/ END HEADER CONTENT ==
=========================
-->
<!--
============================
== BEGIN NAV MENU CONTENT ==
============================
-->
<nav id="nav-wrapper">
<a class="nav-close" href="#0" style="outline: none; cursor: inherit;"><span class="icon-cross2"></span></a>
<ul id="main-nav" class="main-nav all-caps">
<li class="current"><a href="#hero" style="outline: none; cursor: inherit;">Home</a></li>
<li><a href="#what-we-do" style="outline: none; cursor: inherit;">What We Do</a></li>
<li><a href="#our-features" style="outline: none; cursor: inherit;">Our Features</a></li>
<li><a href="#pricing" style="outline: none; cursor: inherit;">Pricing</a></li>
<li><a href="#our-team" style="outline: none; cursor: inherit;">The Team</a></li>
<li><a href="#customer-story" style="outline: none; cursor: inherit;">Customers</a></li>
<li class="dropdown">
<a class="external" href="#0" style="outline: none; cursor: inherit;">
Dropdown
</a>
<ul class="dropdown-menu">
<li><a href="#0" style="outline: none; cursor: inherit;">Some Submenu</a></li>
<li><a href="#0" style="outline: none; cursor: inherit;">And More</a></li>
</ul>
</li>
</ul> <!--/ .main-nav -->
<ul class="secondary-nav">
<li><a href="#0" style="outline: none; cursor: inherit;">About This Template</a></li>
<li><a href="#0" style="outline: none; cursor: inherit;">Privacy Policy</a></li>
<li><a href="#0" style="outline: none; cursor: inherit;">Terms of Service</a></li>
<li><a href="#0" style="outline: none; cursor: inherit;">Legal</a></li>
<li><a href="#0" style="outline: none; cursor: inherit;">Careers</a></li>
<li><a class="contact-trigger" style="outline: none; cursor: inherit;">Contact Us</a></li>
</ul> <!--/ .secondary-nav -->
</nav>
<!--
===========================
==/ END NAV MENU CONTENT ==
===========================
-->
<!--
========================
== BEGIN MAIN CONTENT ==
========================
-->
<!--
========================
== BEGIN HERO SECTION ==
========================
-->
<section id="hero" class="hero-form-layout breaking" data-stellar-background-ratio="0.5" data-stellar-vertical-offset="50" style="background-position: 50% 0px;">
<div class="hero-split-right"></div>
<div class="container">
<div class="vertical-center-wrapper">
<div class="vertical-center-table">
<div class="vertical-center-content">
<!-- BEGIN Hero Content -->
<div class="hero-content row">
<div class="col-lg-6 col-md-6 col-sm-6 margin-top-40">
<div class="editContent" style="outline: none; cursor: inherit;">
<p class="lead zero-bottom text-shadow-xsmall">Meet Urip Landing Page Template</p>
</div>
<div class="editContent" style="outline: none; cursor: inherit;">
<h2 class="text-shadow-medium">All in One Landing Page that Converts</h2>
</div>
<div class="row">
<div class="col-lg-10">
<div class="videoWrapper embed-responsive embed-responsive-16by9">
<iframe src="https://player.vimeo.com/video/93094247?color=19a9e5&title=0&byline=0&portrait=0" width="470" height="265" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>
</div> <!--/ .embed-responsive -->
</div>
</div> <!--/ .row -->
</div> <!--/ .col-lg-6 -->
<div class="hero-form-wrapper col-lg-5 col-lg-offset-1 col-md-6 col-md-offset-0 col-sm-6 col-sm-offset-0 col-xs-10 col-xs-offset-1 centered">
<div class="editContent">
<h4 class="all-caps margin-bot-15">Create Account for Free</h4>
</div>
<div class="editContent">
<p class="zero-bottom">
Create account in 30 seconds. No credit card required.<br>
Already have an account? <a href="#0" class="more" style="outline: none; cursor: inherit;">Log in here.</a>
</p>
</div>
<form class="register-form margin-top-32 margin-bot-5" id="register-form" method="post">
<div class="row">
<div class="col-lg-6 col-md-6">
<div class="required-field">
<input name="fname" id="hero-fname" class="hero-input" type="text" placeholder="First Name">
</div> <!--/ .required-field -->
</div>
<div class="col-lg-6 col-md-6">
<input name="lname" id="hero-lname" class="hero-input" type="text" placeholder="Last Name">
</div>
<div class="col-lg-12 col-md-12">
<div class="required-field">
<input name="username" id="hero-username" class="hero-input" type="text" placeholder="Choose Username">
</div> <!--/ .required-field -->
</div>
<div class="col-lg-12 col-md-12">
<div class="required-field">
<input name="email" id="hero-email" class="hero-input" type="text" placeholder="Email Address">
</div> <!--/ .required-field -->
</div>
<div class="col-lg-8 col-md-8">
<input name="phone" id="hero-phone" class="hero-input" type="text" placeholder="Phone Number">
</div>
<div class="col-lg-4 col-md-4">
<button id="hero-submit" type="submit" class="submit-btn">Create</button>
</div>
</div>
</form> <!--/ .register-form -->
<div class="editContent" style="outline: none; cursor: inherit;">
<p class="zero-bottom">By creating account, you agree to the <a href="#0" class="more" style="outline: none; cursor: inherit;">Terms of Service</a></p>
</div>
</div> <!--/ .hero-form-wrapper -->
</div> <!--/ .row -->
<!-- END Hero Content -->
</div> <!--/ .vertical-center-content -->
</div> <!--/ .vertical-center-table -->
</div> <!-- / .vertical-center-wrapper -->
</div> <!--/ .container -->
</section>
<!--
=======================
==/ END HERO SECTION ==
=======================
--></div><!-- /#page -->
<!-- Load JS here for greater good =============================-->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<!-- SmoothScroll -->
<script src="js/minified/SmoothScroll.min.js"></script>
<!-- Classie -->
<script src="js/minified/classie.min.js"></script>
<!-- One Page Nav -->
<script src="js/minified/jquery.nav.min.js"></script>
<!-- AjaxChimp -->
<script src="js/minified/jquery.ajaxchimp.min.js"></script>
<!-- Swipebox -->
<script src="js/minified/jquery.swipebox.min.js"></script>
<!-- Expandable Gallery on 2 Block Column -->
<script src="js/minified/expandableGallery.min.js"></script>
<!-- Counter Up -->
<script src="http://cdnjs.cloudflare.com/ajax/libs/waypoints/2.0.3/waypoints.min.js"></script>
<script src="js/minified/jquery.counterup.min.js"></script>
<!-- Isotope JS -->
<script src="https://npmcdn.com/isotope-layout@3.0/dist/isotope.pkgd.min.js"></script>
<script src="js/urip-isotope-setting.js"></script>
<!-- Stellar JS -->
<script src="js/jquery.stellar.js"></script>
<!-- Custom JS -->
<script src="js/urip-v2.js"></script>
<!-- Expandable Navigation Menu -->
<script src="js/minified/expandableNav.min.js"></script>
</body></html>
答案 0 :(得分:0)
试试这个:
<?php
header('Location: redirectpage.php');
header('Location: redirectpage.php');exit();
echo "<script>location.href='redirectpage.php';</script>";
?>
您尝试修改标题时可能已经设置了标题。