Avatar billede jajoh Seniormester
04. februar 2017 - 12:46 Der er 2 kommentarer og
2 løsninger

Hjælp til ÆØÅ i denne php fil

Hejsa
Håber der er en der gider hjælpe :-)
Hvor og hvad skal der indsættes så den kan skrive æøå, når man modtager mailen.

<?php
/************************************************************************
* This file is part of Windows Image Gallery.                *
*                                    *
* Windows Image Gallery is free software:                *
* you can redistribute it and/or modify                *
* it under the terms of the GNU General Public License as published by    *
* the Free Software Foundation, either version 3 of the License, or    *
* (at your option) any later version.                    *
*                                    *
* Windows Image Gallery is distributed in the hope that it will be    *
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty    *
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
* GNU General Public License for more details.                *
*                                    *
* You should have received a copy of the GNU General Public License    *
* along with Windows Image Gallery.                    *
* If not, see <http://www.gnu.org/licenses>.                *
************************************************************************/
?>
<script>
function goBack()
  {
    window.history.back()
  }
</script>
</head>

<body>

<?php
if (isset($_REQUEST['email'])) {
    require('config.php');
    //send email
    $email = $_REQUEST['email'] ;
    $subject = $_REQUEST['subject'] ;
    $message = $_REQUEST['message'] ;

    echo "<table class='table' width='50%'>
        <tr class='table_header'>
            <td></td>
        </tr>
        <tr class='row1'>
            <td>";
                if ($email == "") {
                    echo "ERROR: you have to fill in a E-mail adress<br>";
                    echo "<input type='button' value='Back' onclick='goBack()' />";
                    exit;
                }
                if ($subject == "") {
                    echo "ERROR: you have to fill in a subject<br>";
                    echo "<input type='button' value='Back' onclick='goBack()' />";
                    exit;
                }
                if ($message == "") {
                    echo "ERROR: you have to fill in a message<br>";
                    echo "<input type='button' value='Back' onclick='goBack()' />";
                    exit;
                }

            mail($my_email, $subject, "This is a message from the contact form at: " . $sitename . " --- " .
            $message, "From:" . $email);
            echo "Your message has been send.<br>We will reply as soon as possible.
            </td>
        </tr>
    </table>";

} else {






    echo "<form method='post' onClick='ajaxwin.load('ajax', 'contact_form.php', 'New Ajax Page')' action='contact_form.php'>
        <table class='table' width='40%'>
            <tr class='table_header'>
                <td colspan='2'></td>
            </tr>
            <tr class='row1'>
                <td>Email:</td>
                <td>
                    <input name='email' type='text' />
                </td>
            </tr>
            <tr class='row1'>
                <td>Subject:</td>
                <td>
                    <input name='subject' type='text' />
                </td>
            </tr>
            <tr class='row1'>
                <td valign='top'>Message:</td>
                <td>
                    <textarea name='message' rows='8' cols='40'></textarea>
                </td>
            </tr>
            <tr class='row1'>
                <td>&nbsp;</td>
                <td>
                    <input type='submit' value='Send Message' />
                </td>
            </tr>
        </table>
    </form>";
}
?>

</body>
</html>
Avatar billede olsensweb.dk Ekspert
04. februar 2017 - 13:33 #1
regl nr 1
anvend sammen charset alle steder (feks utf8).
dvs
1) filen er incodet som utf8
2) filen er gemt som utf8
3) filens meta er sat til utf8 ( <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> )
4) includeret php filer er i utf8 format
5) databasen leveret data i utf8 format

>mail($my_email, $subject, "This is a message from the contact form at: " . $sitename . " --- " .$message, "From:" . $email);
som arne_v skrev i et af dine tidligere spm http://www.computerworld.dk/eksperten/spm/1015281?k=8247216
citat
Der er ingen MIME header, ingen encoding eller charset mail headers.
/citat
kig på mail documentationen http://php.net/manual/en/function.mail.php

kig evt på functionen mail_utf8
http://php.net/manual/en/function.mail.php#108669
eller ole_bole's vertion (bruger jeg selv)
http://www.computerworld.dk/eksperten/spm/1012847?k=8233259 se filen mail.php

denne linje
mail($my_email, $subject, "This is a message from the contact form at: " . $sitename . " --- " .$message, "From:" . $email);

bare er
$message = "This is a message from the contact form at: " . $sitename . " --- " .$message;
mail_utf8($my_email, $subject, $message, $email);
Avatar billede jajoh Seniormester
04. februar 2017 - 14:01 #2
Ja det er sikker rigtigt.
Men når dette indsættes virker det ikke.
Derfor jeg bad om en der kunne indsætte det, da jeg trodet jeg lavet det forkert.
Avatar billede olsensweb.dk Ekspert
04. februar 2017 - 14:55 #3
ca sådan


mail.php
<?php
// http://www.computerworld.dk/eksperten/spm/961816?k=7937170
function escapeAddr($addr) {
    $check = preg_match('/(.*)<(.*)>/', $addr, $a);
    if ($check) $addr = '=?UTF-8?B?'.base64_encode($a[1]).'?= <'.$a[2].'>';
    return $addr;
}
// http://www.computerworld.dk/eksperten/spm/961816?k=7937170
function mail_utf8($to, $subject='Intet emne', $message='', $from='', $cc='', $bcc='', $type='plain') {
    $from = escapeAddr($from);
    $header = 'From: '.$from.PHP_EOL
            . 'Return-Path: '.$from.PHP_EOL
            . 'Reply-To: '.$from.PHP_EOL
            . 'MIME-Version: 1.0'.PHP_EOL
            . 'Content-type: text/'.$type.'; charset=UTF-8'.PHP_EOL
            . 'X-Mailer: PHP/'.phpversion().PHP_EOL
            . 'Content-Transfer-Encoding: 8bit'.PHP_EOL;
    if ($cc!='') $header .= 'Cc: '.escapeAddr($cc).PHP_EOL;
    if ($bcc!='') $header .= 'Bcc: '.escapeAddr($bcc).PHP_EOL;
    $header .= PHP_EOL;
    return mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header);
}
?>




<?php
/************************************************************************
* This file is part of Windows Image Gallery.                *
*                                    *
* Windows Image Gallery is free software:                *
* you can redistribute it and/or modify                *
* it under the terms of the GNU General Public License as published by    *
* the Free Software Foundation, either version 3 of the License, or    *
* (at your option) any later version.                    *
*                                    *
* Windows Image Gallery is distributed in the hope that it will be    *
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty    *
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
* GNU General Public License for more details.                *
*                                    *
* You should have received a copy of the GNU General Public License    *
* along with Windows Image Gallery.                    *
* If not, see <http://www.gnu.org/licenses>.                *
************************************************************************/
require_once("mail.php");
?>
<!DOCTYPE html>
<HTML lang="da">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>demo</title>

<style type="text/css">
</style>
<script type="text/javascript">
function goBack()
  {
    window.history.back()
  }
</script>
</head>
<body>
<?php
if (isset($_REQUEST['email'])) {
    require('config.php');
    //send email
    $email = $_REQUEST['email'] ;
    $subject = $_REQUEST['subject'] ;
    $message = $_REQUEST['message'] ;

    echo "<table class='table' width='50%'>
        <tr class='table_header'>
            <td></td>
        </tr>
        <tr class='row1'>
            <td>";
                if ($email == "") {
                    echo "ERROR: you have to fill in a E-mail adress<br>";
                    echo "<input type='button' value='Back' onclick='goBack()' />";
                    exit;
                }
                if ($subject == "") {
                    echo "ERROR: you have to fill in a subject<br>";
                    echo "<input type='button' value='Back' onclick='goBack()' />";
                    exit;
                }
                if ($message == "") {
                    echo "ERROR: you have to fill in a message<br>";
                    echo "<input type='button' value='Back' onclick='goBack()' />";
                    exit;
                }

            // mail($my_email, $subject, "This is a message from the contact form at: " . $sitename . " --- " . $message, "From:" . $email);
            $message = "This is a message from the contact form at: " . $sitename . " --- " .$message;
            mail_utf8($my_email, $subject, $message, $email);

            echo "Your message has been send.<br>We will reply as soon as possible.
            </td>
        </tr>
    </table>";
} else {
    echo "<form method='post' onClick='ajaxwin.load('ajax', 'contact_form.php', 'New Ajax Page')' action='contact_form.php'>
        <table class='table' width='40%'>
            <tr class='table_header'>
                <td colspan='2'></td>
            </tr>
            <tr class='row1'>
                <td>Email:</td>
                <td>
                    <input name='email' type='text' />
                </td>
            </tr>
            <tr class='row1'>
                <td>Subject:</td>
                <td>
                    <input name='subject' type='text' />
                </td>
            </tr>
            <tr class='row1'>
                <td valign='top'>Message:</td>
                <td>
                    <textarea name='message' rows='8' cols='40'></textarea>
                </td>
            </tr>
            <tr class='row1'>
                <td>&nbsp;</td>
                <td>
                    <input type='submit' value='Send Message' />
                </td>
            </tr>
        </table>
    </form>";
}
?>
</body>
</html>
Avatar billede jajoh Seniormester
04. februar 2017 - 16:49 #4
Super mange tak.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester