PDA

View Full Version : [need help] contact Formular in PHP


snowbear
October 23rd, 2002, 20:56
Hi

I have writen a contact php script but it don't work correct

her is the script



<?php
$rootdir="../";
include("../layout/header.inc");
?>
<link rel="stylesheet" href="../styles/styles.css" type="text/css">


<?php
if($Submit){
if(strlen($name)<3){
$error_msg="Bitte geben Sie Ihren Namen an.<br>";
}
if(!ereg("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,4})$",$email)){
$error_msg.="Bitte geben Sie eine gültige eMail-Adresse an.<br>";
}
if(strlen($anfrage)<3){
$error_msg.="Bitte geben Sie an, welche Anfrage Sie an uns richten möchten.<br>";
}
if($error_msg){
//Eines der Felder wurde nicht korrekt ausgefüllt
echo "Ihre Anfrage konnte aus folgenden Gründen leider nicht bearbeitet werden:<br><br>";
echo $error_msg;
echo "<br>Bitte klicken Sie auf <a href=Java Script:history.back(1)>zurück</a> und füllen Sie alle Felder aus.";
}else{
//Alle Felder ausgefüllt - eMail generieren
$recipient="php@test.de";
$subject="Eine Anfrage aus dem Internet";
$header="From: " . $email . "\n";
$mail_body ="Das Anfrage-Formular wurde am " . date("d.m.Y") . " um " . date("H:i") . "h ausgeführt.\n";
$mail_body.="Folgende Werte wurden eingetragen:\n\n";
$mail_body.="Name: " . $name . "\n";
$mail_body.="eMail: " . $email . "\n\n";
$mail_body.="Anfrage:\n";
$mail_body.=$anfrage . "\n\n ---- Ende der automatisch generierten eMail ----";

mail($recipient,$subject,$mail_body,$header);

//Formular ausgeführt - Meldung ausgeben
echo "Vielen Dank für Ihre Anfrage.";
}
}else{
//Formular noch nicht ausgeführt - Formular anzeigen
?>

<h2>Benutzen Sie das folgende Formular, um Kontakt mit uns aufzunehmen:<br>
</h2>
<form action=<?php echo $PHP_SELF ?> method=POST>
<table width="500" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="183" class="kleiner">Geben Sie hier Ihren Namen an:</td>
<td width="232">
<input type="text" name="name" size="35">
</td>
</tr>
<tr>
<td width="183" class="kleiner">Geben Sie hier Ihre eMail-Adresse an:</td>
<td width="232">
<input type="text" name="email" size="35">
</td>
</tr>
<tr>
<td width="183" class="kleiner">Ihre Anfrage:</td>
<td width="232">
<textarea name="anfrage" cols="30" rows="3"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" name="Submit" value="Abschicken">
</div>
</td>
</tr>
</table>
</form>
<?php
}
?>

<?php
//Zweiter Teil des Standardlayouts
include("../layout/footer.inc");
?>





when I whant test these script than I get a error msg

Notice: Undefined variable: Submit in c:\wampp13a\htdocs\hp\hp_php\kontakt\index.php on line 9

and then I get the Formular

what must I do to define the variable Submit :confused:

is these script correct or are there mistakes???

_E_
October 23rd, 2002, 21:26
I am running out of time, so i cant look at every single line you wrote. but just to make sure, i debugged the whole thing with Microsoft Script Editor and it doesnt seem wrong to me. Anyhow I think you got somewhere wrong in line number 9, but i cannot allocate the error either......:(

snowbear
October 23rd, 2002, 21:30
yes i know that the mistake is in line 9 but how can I define these Variable ???

_E_
October 23rd, 2002, 21:36
I cant say why this is happening isnce everytime i test it, i dont get any error message ( i know, thats really wierd) .

snowbear
October 23rd, 2002, 21:40
i will try to test these Script on an other server. I have testet the script only on my Local WAMP Server

Neojag
October 23rd, 2002, 21:42
hum, tested it on my local server, works ok (stripped the includes tough) :P

snowbear
October 23rd, 2002, 21:55
So I have testet it on Tripod and it works Correct :)

So my server is **** :)

Neojag what server you are using on your PC????

Neojag
October 24th, 2002, 00:12
using OmniHTTPd atm :)

snowbear
October 24th, 2002, 07:32
you are right :)
I have install OmniHTTPd and it works thank you

Nezzar
October 24th, 2002, 12:36
Usually it shouldn't depend on which server you use but rather on the PHP configuration. Have you looked at the error_reporting-function in PHP?

snowbear
October 24th, 2002, 13:05
no i don't
but on omni httpd there are no errors in my script.

thank for your help.

Mohd
October 24th, 2002, 13:35
Originally posted by snowbear
Hi





when I whant test these script than I get a error msg



and then I get the Formular

what must I do to define the variable Submit :confused:

is these script correct or are there mistakes???

I know what is the problem

Because of the latest release of php


please check your php version if it is the latest one you will see this error (Happen to me)

snowbear
October 24th, 2002, 13:51
Yes I know when I' am using Omni httpd with an older version of PHP I got no errors

but in my WAMP is an new version of PHP and there I get these errors

these is the problem with the register_globels isn't it?

Nezzar has shown me to go round these problem

Nezzar
October 24th, 2002, 15:23
BTW, there is another workaround to this:
http://www.php.net/manual/en/function.import-request-variables.php