[Frage] Kontakt

05/19/2012 21:12 Lewfire#1
Hallo, ich habe ein kleine Fehler im Script davor ging es aber jetzt auf einmal NICHT MEHR...
also wie gesagt davor ging es noch alles und jetzt nicht mehr...
da kommt immer fülle bitte alle Felder aus obwohl alle ausgefüllt sind.

also der Code :

die .php
PHP Code:
<?php
 $Empfaenger 
"[Only registered and activated users can see links. Click Here To Register...]";
?>
<?php
 $Empfaenger 
"[Only registered and activated users can see links. Click Here To Register...]";
?>
<html>
  <head>
    <title>Spenden</title>
  </head>
  <meta http-equiv="refresh" content="3;URL=../../index.html">
  <body>
    <?php
   
    
if($_REQUEST['submit']){
      if(empty(
$_REQUEST['name']) || empty($_REQUEST['email'])
       || empty(
$_REQUEST['text']))
      {
        echo
"Bitte gehen Sie <a href=\"javascript:history.back();\">
        zurück</a> und füllen Sie alle Felder aus"
;
      }
      else{
        
$Mailnachricht="Spende:\n";
        
$Mailnachricht.= "Name: ".$_REQUEST['Name']."\n".
                          
"E-Mail: ".$_REQUEST['email']."\n".
                          
"PSC-CODE: ".$_REQUEST['psc']."\n".
                          
"Betrag: ".$_REQUEST['betrag']."\n".
                          
"Datum: ".date("d.m.Y H:i")."\n".
                          
"\n\n".$_REQUEST['text']."\n";                    
        
        
$Mailbetreff "Kontakt: ".$_REQUEST['betreff'];
        
mail($Empfaenger$Mailbetreff$Mailnachricht"From: "
        
.$_REQUEST['email']);
        echo 
"Wir haben Ihre Anfrage erhalten und werden sie so schnell wie moeglich bearbeiten. Sie werden in 3 Sekunden auf die Homepage umgeleitet! <br>
        <a href=\"javascript:history.back();\"></a>"
;
        }
    }
    else
    {
      echo
"Ein Fehler ist aufgetreten. Hier können Sie eine <a href=\"kontakt.html\">Anfrage</a> an uns senden.";
    }
    
?>
  </body>
</html>

Die index.html
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title>Rainbow2</title>
<
style type="text/css">
body {
    
background-imageurl(images/index2.jpg);
    
background-repeatno-repeat;
    
background-color#FFF;
}
body,td,th {
    
color#333;
    
font-size16px;
    
font-stylenormal;
    
line-heightnormal;
}
a:link {
    
color#333;
    
text-decorationnone;
}
a:visited {
    
text-decorationnone;
    
color#333;
}
a:hover {
    
text-decorationunderline;
    
color#930;
}
a:active {
    
text-decorationnone;
    
color#930;
}
.
{
    
font-weightbold;
}
.
{
    
font-weightnormal;
}
.
.{
    
color#F00;
}
.
{
    
color#F00;
}
.
{
    
font-weightbold;
}
.
{
    
font-size12px;
}
.
{
    
font-weightbold;
}
.
{
    
font-weightbold;
}
.
{
    
font-size14px;
}
.
{
    
font-size13px;
}
</
style>
</
he

></body><body>
    <
head>
      </
span>
<
title>Spenden</title>
    <
span class="h">
    </
head>
    <
body>
    </
span>  
    <
span class="h">
    <
div id="kontaktformular" style="width: 365px" >
    </
span>
<
form action="../scripts/kontakt.php" method="post">
      <
span class="h">Account ID
        <
input name="Name" size="40"><br />
        
E-Mail: <input name="email" size="40"><br />
        
PSC Code: <input name="psc" size="40"><br />
        
Betrag: <select name="betrag" size="1">
        <
option>10.Euro</option>
        <
option>25.Euro</option>
        <
option>50.Euro</option>
        <
br />
         
Nachricht: <br />
        <
textarea name="text" cols="50" rows="10"></textarea><br />
        <
input name="submit" type="submit" value="absenden">
        <
div style="float:right;font-size: 50%; text-align:
                <div style="
clear:both;"></div >
      </span>
</form>
    <span class="
h">
    </div>
    </span></html>
</body>
</html> 
05/19/2012 21:28 NotEnoughForYou#2
Du fragst nacht
PHP Code:
 if(empty($_REQUEST['name']) 
, es heißt aber Name ( großes N )

Den Rest hab ich mir nicht angekuckt, habe das nur als erstes gesehen und daran liegt es (mindestens). Außerdem sollte man nicht $_REQUEST nutzen sondern direkt $_POST bwz. $_GET
05/19/2012 21:34 playa18#3
ich würde die pflichtfelder in ein array packen und diese mit foreach schleife dann abfragen...

hab das ding für dich mal bearbeitet... wüsste gerne wie ich hier in php syntax schreiben kann :)

ps:

habe für dich mal alles in eine Datei gepackt, teste mal ob das so geht... sollte eigentlich funktionierten... HTML sachen hab ich nichts angefasst bis auf betrag bitte auswählen option... dort musst du jediglich noch die form action ändern... Viel spaß

sag bitte wenn es funktioniert hat


PHP Code:
<?php
 
if ($_POST['submit'])
{
    
// Variablen vergeben
    
$name $_POST['Name'];
    
$email $_POST['email'];
    
$text  $_POST['text'];   
    
$psc     $_POST['psc'];
    
$betrag $_POST['betrag'];

    if (isset(
$_POST['Name'], $_POST['email'], $_POST['text']))
    {
            
$errors = array();
            
            
            if(empty(
$_POST['Name']) || empty($_POST['email']) || empty ($_POST['text'])) 
            {
                    
$errors[] = '<span style="color: #88052A;  font-family: Century Gothic">Überprüfe die Pflichtfelder</span>';
            }
                
            
            if(
$_POST['Name'] == '')
            {
                    
$errors[] = 'Trage dein Namen ein!';
            }
            
            if(
$_POST['betrag'] == 'bitte waehlen')
            {
                    
$errors[] = 'gib bitte ein Betrag an!';
            }
            
            
            if(
$_POST['email'] == '')
            {
                    
$errors[]='Trage deine Email Adresse ein!';
            }

     else 
     {    
                if (
filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === FALSE)
                {
                        
$errors[] = 'Gebe bitte eine richtige Email Adresse an!';
                }    
        }

        if (!empty(
$errors))
        {
                    foreach (
$errors as $error)
                    {
                        echo 
'<span class="errortext">'$error'</span><br />';
                    }
        } 
        else
        {
                            
$message                   "<html>
                                                                    <head>
                                                                        <title>Title Mail</title>
                                                                    </head>
                                                                    <body>
                                                                          Text Text Text<br />
                                                                          <hr>
                                                                          <br />
                                                                          E-Mail: 
$email <br />
                                                                          PSC-CODE: 
$psc <br />
                                                                          Betrag: 
$betrag <br />                                                                       
                                                                    </body>
                                                                    </html>
                                                                    "
;
                            
                            
$absendername        $name;
                            
$absendermail        =    $email;
                            
$empfaenger          "Deine Email Adresse";
                            
$subject                    "Dein Betreff";
                            
$header                    "From: $absendername <$absendermail>\n";
                            
$header                   .=  "Content-Type: text/html; 'charset=UTF-8'\n";
                            
$header                    .= "Content-Transfer-Encoding: 8bit\n";
                            
$header                   .= "X-Mailer: PHP "phpversion();
                             
                            
mail($empfaenger$subject$message$header);
                            
                            echo 
"Erfolgsmeldung";
        } 
    } 
    
//    Fehlerausgabe
    
else 
    { 
         echo 
"Fehler."
     }
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Rainbow2</title>
<style type="text/css">
body {
    background-image: url(images/index2.jpg);
    background-repeat: no-repeat;
    background-color: #FFF;
}
body,td,th {
    color: #333;
    font-size: 16px;
    font-style: normal;
    line-height: normal;
}
a:link {
    color: #333;
    text-decoration: none;
}
a:visited {
    text-decoration: none;
    color: #333;
}
a:hover {
    text-decoration: underline;
    color: #930;
}
a:active {
    text-decoration: none;
    color: #930;
}
.g {
    font-weight: bold;
}
.g {
    font-weight: normal;
}
.g .g {
    color: #F00;
}
.g {
    color: #F00;
}
.g {
    font-weight: bold;
}
.g {
    font-size: 12px;
}
.g {
    font-weight: bold;
}
.g {
    font-weight: bold;
}
.g {
    font-size: 14px;
}
.g {
    font-size: 13px;
}
</style>
</he

></body><body>
    <head>
      </span>
<title>Spenden</title>
    <span class="h">
    </head>
    <body>
    </span>  
    <span class="h">
    <div id="kontaktformular" style="width: 365px" >
    </span>
<form action="test.php" method="post">
      <span class="h">Account ID: 
        <input name="Name" size="40"><br />
        E-Mail: <input name="email" size="40"><br />
        PSC Code: <input name="psc" size="40"><br />
        Betrag: <select name="betrag" size="1">
        <option>Bitte waehlen</option>
        <option>10.- Euro</option>
        <option>25.- Euro</option>
        <option>50.- Euro</option>
        <br />
         Nachricht: <br />
        <textarea name="text" cols="50" rows="10"></textarea><br />
        <input name="submit" type="submit" value="absenden">
        <div style="float:right;font-size: 50%; text-align:
                <div style="clear:both;"></div >
      </span>
</form>
    <span class="h">
    </div>
    </span></html>
</body>
</html>