Seite 1 von 1

Finde den Fehler nicht :( PHP-Code

Verfasst: 28.09.2003 21:53
von Gast
Hi. ich finde leider den fehler in diesem PHP-Code nicht :-(( soll angeblich in zeile 67 oder so liegen, also genauergesagt da wo $toAddress="... steht. Aber was soll da falsch sein?? :-(

Code: Alles auswählen

<html> 
<head> 
</head> 
<body> 

<?php 
/* grabs the POST variables and puts them into variables that we can use */ 

$vorname = $_POST['vorname']; 
$nachname = $_POST['nachname']; 
$email = $_POST['email']; 
$strasse = $_POST['strasse']; 
$plz = $_POST['plz']; 
$wohnort = $_POST['wohnort']; 
$tel = $_POST['tel']; 
$fax = $_POST['fax']; 
$homepage = $_POST['homepage']; 

//---------VALIDATION--------> 
    if($vorname){//----> CHECK input 
        } 
        else{ 
            $error.="Please, go back and fill out your first name\n";//----> ERROR if no input 
            } 

    if($nachname){//----> CHECK input 
        } 
        else{ 
            $error.="Please, go back and fill out your last name\n";//----> ERROR if no input 
            } 

    if($email){//----> CHECK input 
        } 
        else{ 
            $error.="Please, go back and fill out your e-mail address\n";//----> ERROR if no input 
            } 

    if($tel){//----> CHECK input 
        } 
        else{ 
            $error.="Please, go back and fill out your phone number\n";//----> ERROR if no input 
            } 

    if($strasse){//----> CHECK input 
        } 
        else{ 
            $error.="Please, go back and fill out your mailing address\n";//----> ERROR if no input 
            } 

    if($wohnort){//----> CHECK input 
        } 
        else{ 
            $error.="Please, go back and fill out your city name\n";//----> ERROR if no input 
            } 

    if($plz){//----> CHECK input 
        } 
        else{ 
            $error.="Please, go back and fill out your zip code\n";//----> ERROR if no input 
            } 
//-------->ERROR FREE?? 
    if($error == "") { 
        echo "Thank you for inquiring about us! A receipt of your submission will be e-mailed to you almost immediately."; 
		}
//---------------------------------- 
$mailContent = "--------CONTACT--------\n" 
            ."First Name: ".$vorname."\n" 
            ."Last Name: ".$nachname."\n" 
            ."E-mail: ".$email."\n" 
            ."Website: ".$homepage."\n\n--------PHONE--------\n" 
            ."Phone: ".$tel."\n" 
            ."Fax: ".$fax."\n" 
			."Street Address: ".$strasse."\n" 
            ."City: ".$wohnort."\n" 
            ."Zip Code: ".$plz."\n\n--------INFO--------\n" 
//---------------------------------- 
$toAddress = "meine@mail.com";
$subject = "Betreff fuer Homepagebesitzer"; 
$recipientSubject = "Betreff fuer Absender";
$receiptMessage = "Thank you ".$vorname." for inquiring about MyWebSite.com's Products!\n\n\nHere is what you submitted to us:\n\n" 
            ."--------CONTACT--------\n" 
            ."First Name: ".$vorname."\n" 
            ."Last Name: ".$nachname."\n" 
            ."E-mail: ".$email."\n" 
            ."Website: ".$homepage."\n\n--------PHONE--------\n" 
            ."Phone: ".$tel."\n" 
            ."Fax: ".$fax."\n" 
            ."Street Address: ".$strasse."\n" 
            ."City: ".$wohnort."\n" 
            ."Zip Code: ".$plz."\n\n--------INFO--------\n" 
//---------------------------------- 
mail($email, $subject, $receiptMessage,"From:$toAddress"); 
//---------------------------------- 
mail($toAddress,$recipientSubject,$mailContent,"From:$email"); 
//--->echo $mailContent; 

////////////////////////////////////////  CONNECT TO MYSQL DB  //////////////////// 
// OPEN CONNECTION ---> 
$connection = mysql_connect("mysql","YXYX", "YXYXYX") or die("Unable to connect!"); /* change this! */ 

mysql_select_db("XYZ") or die("Unable to select database!"); /* change this! */ 

//  EXECUTE QUERY ---> 
$query="INSERT INTO kontaktformular ( 
            vorname,
            nachname, 
            email, 
            strasse, 
            plz,
            wohnort, 
            tel, 
            fax, 
            homepage)
		VALUES( 
            '".$vorname."', 
            '".$nachname."', 
            '".$email."', 
            '".$strasse."', 
            '".$plz."', 
            '".$wohnort."', 
            '".$tel."', 
            '".$fax."', 
            '".$homepage."')"; 
//////-----> 
$result = mysql_query($query) or die("Error in query:".mysql_error()); 
//if ($result) 
    //echo mysql_affected_rows()." row inserted into the database effectively."; 

//  CLOSE CONNECTION ---> 
mysql_close($connection); 

/////////////////////////////////////////////////////////////////////////////////// 
        } 
    else{ 
            print "Sorry, but the form cannot be sent until the fields indicated are filled out completely - \n"; 
            print "$error\n"; 
            print "\n"; 
            print "\n"; 
            print "Please use your \"Back\" button to return to the form to correct the omissions.  Thank you.\n"; 
        } 

?> 
</body> 
</html> 

Verfasst: 28.09.2003 22:52
von Mungo

Code: Alles auswählen

."Zip Code: ".$plz."\n\n--------INFO--------\n"
da gehört ein ";" hinter. (In Zeile 75 und 90)

außerdem passt der teil hier nicht ganz. das "if" ist auskommentiert, aber das else ist noch vorhanden.

Code: Alles auswählen

//if ($result) 
    //echo mysql_affected_rows()." row inserted into the database effectively.";

//  CLOSE CONNECTION --->
mysql_close($connection);

///////////////////////////////////////////////////////////////////////////////////
      }
    else{
            print "Sorry, but the form cannot be sent until the fields indicated are filled out completely - \n";
            print "$error\n";
            print "\n";
            print "\n";
            print "Please use your \"Back\" button to return to the form to correct the omissions.  Thank you.\n";
        }

Verfasst: 28.09.2003 23:08
von Gast
das mit dem ; ist richtig.

aber wenn du genau hinsiehst, ist über dem else noch eine }. das hat mit dem block der auskommentiert ist nix zu tun. weiter oben beginnt die abfrage, ob der fehler leer ist also = "" wenn das der fall ist, soll die mail verschickt werden und der datenbankeintrag getätigt werden. mittlerweile bin ich soweit, daß ich sehe, daß mit post keine daten ankommen, mit get schon. aber trotz der daten mit get geht er in die fehlermeldung rein und sagt, er hat keine angaben....warum??? komisch.

Verfasst: 28.09.2003 23:28
von Gast
hat sich erledigt.... case sensitivity is wohl nicht zu unterschätzen in den form-feldern.

Verfasst: 29.09.2003 11:12
von Mungo
ich hab zwar keine offene if-anweisung gefunden, aber wenn es jetzt funktioniert, ist ja gut.