Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900