重写.htaccess后POST不工作 [英] POST not working after rewrite .htaccess

查看:79
本文介绍了重写.htaccess后POST不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在向.htaccess添加重写后,我的表单无效。我发现很多主题都有类似的问题,但都没有解决我的问题。如果你能看看,我将不胜感激。它是:



 RewriteEngine On 
RewriteBase /
RewriteCond%{THE_REQUEST} ^ [AZ] { 3,} \ s([^。] +)\.php [NC]
RewriteRule ^%1 [R = 301,L]
RewriteCond%{REQUEST_FILENAME}!-d
RewriteCond%{REQUEST_FILENAME} .php -f
RewriteRule ^(。*?)/?$ $ 1.php [NC,L]







这是我的邮政编码:)



<?php 
函数send_email($ to_email,$ from_email,$ from_name,$ subject,$ msg,
$ showinfo){
//拆分为电子邮件数组,如果给定
if(is_array) ($ to_email)){
$ to_email_string = implode(',',$ to_email);
}
else {
$ to_email_string = $ to_email;
}

//构建内容

$ message ='< html>< body>';
$ message。='< table rules =allstyle =border-color:#666;
cellpadding =10>';
$ message。=< tr style ='background:#eee;'>< td> Imie i nazwisko:
< / td>< td> ; 。 strip_tags($ from_name)。 < / TD>< / TR> 中;
$ message。=< tr>< td> 电子邮件:< / td>< td> 。 strip_tags(
$ from_email)。 < / TD>< / TR> 中;
$ message。=< tr>< td> Temat:< / td>< td> 。 strip_tags(
$ subject)。 < / TD>< / TR> 中;
$ message。=< tr>< td> Wiadomość:< / td>< td> 。 nl2br(
strip_tags($ msg))。 < / TD>< / TR> 中;
$ message。=< / table>;
$ message。=< / body>< / html>;



//汇编标题
$ headers ='MIME-Version:1.0'。 \r\\\
;
$ headers。='Content-type:text / html; charset = iso-8859-1'。 \r\\\
;
$ headers。=From:$ from_name< $ from_email> 。 \r\\\
;

//通过PHP的mail()函数发送
if($ showinfo)
{
mail($ to_email_string,$ subject,$ message,$ headers)或死(json_encode(
array('error'=> true,'msg'=>'Felnärduskickar meddelanden。')));
echo json_encode(array('error'=> false,'msg'=>Ditt meddelande har
skickats。));
} else {
mail($ to_email_string,$ subject,$ message,$ headers);
}



}


if(isset($ _POST ['name'])&& isset($ _POST ['email'])&& isset(
$ _POST ['subject'])&& isset($ _POST ['message'])&& $ _POST ['其他'] =='')
{

send_email(myemail,$ _POST ['email'],$ _POST ['name'],
$ _POST [ 'subject',$ _POST ['message'],true);
send_email($ _POST ['email'],'myemail',LHI,'复制:'。
$ _POST ['subject'],$ _POST ['message'],false);
}

if(isset($ _POST ['info'])&& $ _POST ['info'] =='notajax')
{
header(HTTP / 1.1 301永久移动);
header(Location:http:// localhost / dash /);
}





提前感谢您的帮助。

解决方案

< blockquote>


1.php [NC,L]







,这是我的邮政编码:)



<?php 
function send_email(


to_email,

My forms not working after adding rewrite to .htaccess. I found many topics with similar problem but neither have solution to my issue. I would be grateful if you could take a look. There it is:

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [NC,L]




and here is my post code:)

<?php
function send_email ($to_email, $from_email, $from_name, $subject, $msg,
$showinfo) {
//split up to email array, if given
if (is_array($to_email)) {
    $to_email_string = implode(', ', $to_email);
}
else {
    $to_email_string = $to_email;
}

// build content

$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;"  
cellpadding="10">';
$message .= "<tr style='background: #eee;'><td>Imie i nazwisko:  
 </td><td>" . strip_tags( $from_name ) . "</td></tr>";
$message .= "<tr><td>E-mail: </td><td>" . strip_tags( 
$from_email ) . "</td></tr>";
$message .= "<tr><td>Temat: </td><td>" . strip_tags( 
$subject ) . "</td></tr>";
$message .= "<tr><td>Wiadomość: </td><td>" . nl2br( 
strip_tags( $msg ) ) . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";



//Assemble headers
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: $from_name <$from_email>" . "\r\n";

//send via PHP's mail() function
if( $showinfo )
{
    mail($to_email_string, $subject, $message, $headers) or die(json_encode(
array( 'error' => true, 'msg' => 'Fel när du skickar meddelanden.')));
    echo json_encode( array( 'error' => false, 'msg' => "Ditt meddelande har
skickats."));
} else {
    mail($to_email_string, $subject, $message, $headers);
}



}


if( isset( $_POST['name']) && isset( $_POST['email']) && isset(   
$_POST['subject']) && isset( $_POST['message']) && $_POST['other'] == '')
{

send_email( "myemail", $_POST['email'], $_POST['name'], 
$_POST['subject'], $_POST['message'], true );
send_email( $_POST['email'], 'myemail', "LHI", 'Copy: ' .
   $_POST['subject'], $_POST['message'], false );
}

if( isset( $_POST['info']) && $_POST['info'] == 'notajax' )
{
header("HTTP/1.1 301 Moved Permanently"); 
header("Location: http://localhost/dash/"); 
}



Thanks in advance for any help.

解决方案


1.php [NC,L]




and here is my post code:)

<?php
function send_email (


to_email,


这篇关于重写.htaccess后POST不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆