我有这段代码,我不确定在用户单击“提交”按钮后应使用哪种类型的标题重定向用户。
我尝试了几种解决方案,直到现在都无济于事!
使用此代码,我无法执行任何操作:
function redirect() {
window.location.replace("login.php");
return false;
}
将感谢您的任何建议!这是我在mail.php上拥有的原始代码
<?php
define('admin_email','contact@....'); // Change admin email here for example admin@yoursite.com
define('website_name','site-name'); // Change website name here for example yoursite.com
define('website_url', 'http://'.$_SERVER['HTTP_HOST']);
define('EMAIL_FROM', 'noreply@'.$_SERVER['HTTP_HOST']);
function strict_secure($str){
$str = strip_tags(trim($str));
return $str;
}
function sendEmail($to,$from,$subject,$message,$headname){
$headers="MIME-Version: 1.0" . "\r\n";
$headers.="Content-type: text/html; charset=utf-8" . "\r\n";
$headers.="From: ".$headname.'<'.$from.'>';
return mail ($to,$subject,$message,$headers);
}
if(isset($_POST['action']) && $_POST['action']=='submitform')
{
$N = array();
$N = $_POST['formInput'];
$path = $_SERVER['HTTP_REFERER'];
$admin_message = '<p>Dear Admin, Form submitted on '.website_url.'<br>Detail is as following.</p>';
foreach( $N as $label => $value ){
$admin_message .= '<p>'.ucwords($label).' : '.$value.'</p>';
}
$admin_message .= '<p>Form submitted on URL:<a href="'.$path.'">'.$path.'</a></p>';
$admin_message .= '<br><br>';
$admin_message .= 'Regards,<br />
'.website_name.'<br />
'.website_url.'
';
$user_message = 'Dear '.strict_secure($N['name']).',<br>';
$user_message .= 'Thank you very much for submitting information. We will contact you shortly.';
$user_message .= 'Regards,<br />
'.website_name.'<br />
'.website_url.'
';
$admin_subject = 'Form Received From '.website_name;
$user_subject = 'Thank you - '.website_name;
$sendToAdmin = $sendToUsers = '';
$sendToAdmin = sendEmail(admin_email,EMAIL_FROM,$admin_subject,$admin_message,website_name);
if( isset( $N['email'] ) && ! empty( $N['email'] ) ){
$sendToUsers = sendEmail(strict_secure($N['email']),EMAIL_FROM,$user_subject,$user_message,website_name);
}
if($sendToAdmin || $sendToUsers)
{
$message ='Success::<div class="alert alert-success"><strong><i class="fa fa-info message-icon"></i>Message Sent Successfully.</strong></div>';
}else{
$message ='Error::<div class="alert alert-danger"><strong><i class="fa fa-info message-icon"></i>Something Went Wrong While Sending Message.</strong></div>';
}
echo $message;
}
exit();
?>
答案 0 :(得分:0)