Autor Zpráva
Azhrei
Profil
Dobrý den,
potřeboval bych upravit tento formulář tak, aby se po jeho odeslání nabídl nebo začal stahovat pdf soubor.
<?php

@ini_set('error_reporting',E_ALL);
@ini_set("display_errors","on");
error_reporting(E_ALL);

$code0    = "Tomik";    //antispam
$vysledek = "";
$M        = array();

if (count($_POST) || (isset($HTTP_POST_VARS) && count($HTTP_POST_VARS)))
    {
    $a = 'from';    $M[$a] = isset($_POST[$a]) ? $_POST[$a] : "";
    $a = 'to';    $M[$a] = isset($_POST[$a]) ? $_POST[$a] : "";
    $a = 'jmeno';    $M[$a] = isset($_POST[$a]) ? $_POST[$a] : "";
    $a = 'tel';    $M[$a] = isset($_POST[$a]) ? $_POST[$a] : "";
    $a = 'message';    $M[$a] = isset($_POST[$a]) ? $_POST[$a] : "";
    $a = 'code';    $M[$a] = isset($_POST[$a]) ? $_POST[$a] : "";
    if ($M['code']==$code0)
        {
        unset($M['code']);
        $vysledek = @PPmail($M);
        }
    }

function PPmail($M)
{
// $from = "name <mail>" | "mail"
// $to   = "name <mail>" | "mail"
//$head .= "MIME-Version: 1.0\r\n";            // mime type
$head  = "";
$head .= "Content-Type: text/plain; charset=utf-8\r\n";    // charset
//$head .= "Content-Transfer-Encoding: 8bit\r\n";
//$head .= "X-Sender: ".$M['from']."\r\n";
//$head .= "X-Mailer: PHP test\r\n";        // mailovy klient
//$head .= "X-Priority: 1\r\n";            // urgentni vzkaz!
//$head .= "cc: $to1, $to2, $to3\r\n";        // CC carbon copy - posli X lidem
//$head .= "bcc:$to1, $to2, $to3\r\n";        // BCC blind CC   - CC ale nezobraz jim maily ostatnich
$head .= "From: ".$M['from']."\r\n";
$head .= "Return-Path: ".$M['from']."\r\n";    // navratová cesta pro chyby
$head .= "Reply-To: ".$M['from']."\r\n";

$zprava = "";
$zprava .="Jmeno: ".$M['jmeno']."\r\n";
$zprava .="Telefon: ".$M['tel']."\r\n";
$zprava .="Text: ".$M['message']."\r\n";
$titulek = "Kontaktni formular.";

$err = (mail($M['to'],$titulek,$zprava,$head)) ? "E-mail odesl&aacute;n." : "E-mail nebyl odesl&aacute;n!";
$err.= " ".date("Y-m-d H:i:s",time());
return $err;
}
?>




    <script type="text/javascript">
    function checkForm(xForm)
    {
    var c,i,x,p,reg; i=-1; c=new Array();

    x = "from";
    p = xForm[x].value;
    if (p=="")         {i++;c[i]=x+": 0 chars !";}
    reg = new RegExp("@");
    if (!reg.test(p))    {i++;c[i]=x+": Not @ char !";}
    if (p.length>64)    {i++;c[i]=x+": >64 chars !";};

    x = "to";
    p = xForm[x].value;
    if (p=="")         {i++;c[i]=x+": 0 chars !";}
    reg = new RegExp("@");
    if (!reg.test(p))    {i++;c[i]=x+": Not @ char !";}
    if (p.length>64)    {i++;c[i]=x+": >64 chars !";};
    
    x = "jmeno";
    p = xForm[x].value;
    if (p=="")         {i++;c[i]=x+": 0 chars !";}
    if (p.length>64)    {i++;c[i]=x+": >64 chars !";};

    x = "message";
    p = xForm[x].value;
    if (p=="")         {i++;c[i]=x+": 0 chars !";}

    x = "code";
    p = xForm[x].value;
    if (p!="<?php echo($code0); ?>")    {i++;c[i]=x+": bad code !";}

    if (i>=0) {alert(c.join("\n")); return false;}
    else      {return true;}
    }
</script>


<?php echo $vysledek; ?>

<form name="fmail" action="stranka.php" onsubmit="return checkForm(this)" method="post" enctype="multipart/form-data">
<fieldset>
<legend>Kontaktn&iacute formul&aacute;ř</legend> 
<table align="center">
<tbody valign="top">
<tr><td colspan="2">
<label for="from">Email </label><input type="text" name="from" id="from" value="@" size="20"/>
<input type="hidden" name="to" id="to" value="mail@mail.cz"/>
<label for="jmeno">Jm&eacute;no </label><input type="text" name="jmeno" id="jmeno" size="20"/>
<label for="tel">Telefon </label><input type="text" name="tel" id="tel" value="+420" size="20"/>
</td></tr>
<tr>    <td><label for="message">Text zpr&aacute;vy</label></td>
    <td><textarea name="message" id="message" rows="5" cols="60"></textarea></td></tr>
    <tr>
    <td><input type="hidden" name="code" value="Tomik"/> </td></tr>
<tr>    
    <td>
    <input type="submit" value="Odeslat"/>
    </td></tr>
</tbody>
</table>
</fieldset>
</form>

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: