Hi there, I just made this script and i'm a totally php newbie Somehow he doesn't send the e-mail with all the fild in fields. I was wondering if someone could help me finding the fault? And what i have to change to make it work? Thanks for the effort. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled</title> </head> <body> <form method="post" action="contact.php"> <table> <tr> <td>Naam:</td> <td><input name="naam" /></td> </tr> <tr> <td>Voorletters</td> <td><input name="voorletters" /></td> </tr> <tr> <td>Geslacht:</td> <td>Man<input type="radio" name="geslacht" value="man" checked />Vrouw<input type="radio" name="geslacht" value="vrouw" /></td> </tr> <tr> <td>Geboortedatum:</td> <td><input name="geboortedatum" /></td> </tr> <tr> <td>Adres:</td> <td><input name="adres" /></td> </tr> <tr> <td>Postcode:</td> <td><input name="postcode" /></td> </tr> <tr> <td>Plaats:</td> <td><input name="plaats" /></td> </tr> <tr> <td>Telefoon:</td> <td><input name="telefoon" /></td> </tr> <tr> <td>Telefoon zakelijk:</td> <td><input name="telefoonzakelijk" /></td> </tr> <tr> <td>E-mail:</td> <td><input name="mail" /></td> </tr> <tr> <td>Werkgever:</td> <td><input name="werkgever" /></td> </tr> <tr> <td>Lid COR/OR/OC:</td> <td>Ja<input type="radio" value="ja" name="lidcor" checked/>Nee<input type="radio" value="nee" name="lidcor"/></td> </tr> <tr> <td>Machtiging aut. inc.:</td> <td>Ja<input type="radio" value="ja" name="machtiging" checked/>Nee<input type="radio" value="nee" name="machtiging"/> Kwartaal<input type="radio" value="kwartaal" name="machtiging"/> Halfjaar<input type="radio" value="nee" name="machtiging"/> Jaar<input type="radio" value="nee" name="machtiging"/></td> </tr> <tr> <td>Gepensoineerd/VUT:</td> <td>Ja<input type="radio" value="ja" name="gepensioneerd" checked/>Nee<input type="radio" value="nee" name="gepensioneerd"/></td> </tr> <tr> <td>Wat wilt u?:</td> <td>Aanmelden<input type="radio" value="aanmelden" name="watwiltu" checked/>Informatie<input type="radio" value="informatie" name="watwiltu"/>Mijn persoons gegevens wijzigen<input type="radio" value="gegevenswijzigen" name="watwiltu"/>Opzeggen<input type="radio" value="opzeggen" name="watwiltu"/></td> </tr> <tr> <td>Branche:</td> <td>Banken<input type="radio" value="banken" name="branche" checked/> Verzekeringen<input type="radio" value="verzekeringen" name="bracnhe"/> Overige<input type="radio" value="verzekeringen" name="bracnhe"/> <tr> <td></td> <td><input type="submit" value="Verzenden" /></td> </tr> </table> </form> </body> </html> HTML: <?php if($_SERVER['REQUEST_METHOD']=='post'){ $bericht="Naam:\t".$_POST['naam']. "\nVoorletters:\t".$_POST['voorletters']. "\nGeslacht:\t".$_POST['geslacht']. "\nGeboortedatum:\t".$_POST['geboortedatum']. "\nAdres:\t".$_POST['adres']. "\nPostcode:\t".$_POST['postcode']. "\nPlaats:\t".$_POST['plaats']. "\nTelefoon:\t".$_POST['telefoon']. "\nTelefoon zakelijk:\t".$_POST['telefoonzakelijk']. "\nE-mail:\t".$_POST['mail']. "\nWerkgever:\t".$_POST['werkgever']. "\nLid COR/OR/OC:\t".$_POST['lidcor']. "\nMachtiging aut. inc.:\t".$_POST['machtiging']. "\nGepensioneerd/VUT:\t".$_POST['gepensioneerd']. "\nWat wilt u?:\t".$_POST['watwiltu']. "\nBranche:\t".$_POST['branche']. mail('lisettebast@hotmail.com', 'Contact formulier', $bericht, 'From: '.$_POST['naam'].'<'.$_POST['mail'].'>'); } ?> PHP:
So i've put this in every line: <input name="werkgever" type="text"/> HTML: But it still doesn't work.. Maybe it's the contact.php file which isn't right?
Instead of emailing the output to yourself just echo it to the page to help you debug it. Whats the output?
Maybe a stupid question but how do i echo it? I have to change the mail thing to echo and then contact.php?
//mail('lisettebast@hotmail.com', 'Contact formulier', $bericht, 'From: '.$_POST['naam'].'<'.$_POST['mail'].'>'); //this comments out the mail function echo"$bericht"; //this echos the results PHP:
After changing the code in this: <?php if($_SERVER['REQUEST_METHOD']=='post'){ $bericht="Naam:\t".$_POST['naam']. "\nVoorletters:\t".$_POST['voorletters']. "\nGeslacht:\t".$_POST['geslacht']. "\nGeboortedatum:\t".$_POST['geboortedatum']. "\nAdres:\t".$_POST['adres']. "\nPostcode:\t".$_POST['postcode']. "\nPlaats:\t".$_POST['plaats']. "\nTelefoon:\t".$_POST['telefoon']. "\nTelefoon zakelijk:\t".$_POST['telefoonzakelijk']. "\nE-mail:\t".$_POST['mail']. "\nWerkgever:\t".$_POST['werkgever']. "\nLid COR/OR/OC:\t".$_POST['lidcor']. "\nMachtiging aut. inc.:\t".$_POST['machtiging']. "\nGepensioneerd/VUT:\t".$_POST['gepensioneerd']. "\nWat wilt u?:\t".$_POST['watwiltu']. "\nBranche:\t".$_POST['branche']. //mail('lisettebast@hotmail.com', 'Contact formulier', $bericht, 'From: '.$_POST['naam'].'<'.$_POST['mail'].'>');//this comments out the mail function echo"$bericht";//this echos the results } ?> PHP: The output says: Parse error: parse error, unexpected '}' in /home/virtual/site85/fst/var/www/html/contact/contact.php on line 21
You have to close the bericht string properly on the last line: "\nBranche:\t".$_POST['branche']. PHP: to: "\nBranche:\t".$_POST['branche']; PHP: Note the . to ; change. All string end with ; That will get rid of the Parse error. Then echo $bericht like mad4 said to see if it's working. En als het niet werkt, helpen we wel weer
Putted some enters in it.. Now it says: Parse error: parse error, unexpected T_ECHO in /home/virtual/site85/fst/var/www/html/contact/contact.php on line 23
<?php if($_SERVER['REQUEST_METHOD']=='post'){ $bericht="Naam:\t".$_POST['naam']. "\nVoorletters:\t".$_POST['voorletters']. "\nGeslacht:\t".$_POST['geslacht']. "\nGeboortedatum:\t".$_POST['geboortedatum']. "\nAdres:\t".$_POST['adres']. "\nPostcode:\t".$_POST['postcode']. "\nPlaats:\t".$_POST['plaats']. "\nTelefoon:\t".$_POST['telefoon']. "\nTelefoon zakelijk:\t".$_POST['telefoonzakelijk']. "\nE-mail:\t".$_POST['mail']. "\nWerkgever:\t".$_POST['werkgever']. "\nLid COR/OR/OC:\t".$_POST['lidcor']. "\nMachtiging aut. inc.:\t".$_POST['machtiging']. "\nGepensioneerd/VUT:\t".$_POST['gepensioneerd']. "\nWat wilt u?:\t".$_POST['watwiltu']. "\nBranche:\t".$_POST['branche']; // <-- Note the ; instead of the . (. indicates more is soming, ; says string comes to an end) mail('lisettebast@hotmail.com', 'Contact formulier', $bericht, 'From: '.$_POST['naam'].'<'.$_POST['mail'].'>'); } ?> PHP: After adding the type="text" to the form, the above form handler should do the job.
He nog een nederlander I changed the close tag.. But now i just get a white screen.. <?php if($_SERVER['REQUEST_METHOD']=='post'){ $bericht="Naam:\t".$_POST['naam']. "\nVoorletters:\t".$_POST['voorletters']. "\nGeslacht:\t".$_POST['geslacht']. "\nGeboortedatum:\t".$_POST['geboortedatum']. "\nAdres:\t".$_POST['adres']. "\nPostcode:\t".$_POST['postcode']. "\nPlaats:\t".$_POST['plaats']. "\nTelefoon:\t".$_POST['telefoon']. "\nTelefoon zakelijk:\t".$_POST['telefoonzakelijk']. "\nE-mail:\t".$_POST['mail']. "\nWerkgever:\t".$_POST['werkgever']. "\nLid COR/OR/OC:\t".$_POST['lidcor']. "\nMachtiging aut. inc.:\t".$_POST['machtiging']. "\nGepensioneerd/VUT:\t".$_POST['gepensioneerd']. "\nWat wilt u?:\t".$_POST['watwiltu']. "\nBranche:\t".$_POST['branche']; //mail('lisettebast@hotmail.com', 'Contact formulier', $bericht, 'From: '.$_POST['naam'].'<'.$_POST['mail'].'>'); //this comments out the mail function echo"$bericht";//this echos the results } ?> PHP: So that means, that when i change it in email it will work? So i've changed it.. but now i dont get an email..
Try this: <?php if($_SERVER['REQUEST_METHOD']=='post'){ $bericht="Naam:\t".$_POST['naam']. "\nVoorletters:\t".$_POST['voorletters']. "\nGeslacht:\t".$_POST['geslacht']. "\nGeboortedatum:\t".$_POST['geboortedatum']. "\nAdres:\t".$_POST['adres']. "\nPostcode:\t".$_POST['postcode']. "\nPlaats:\t".$_POST['plaats']. "\nTelefoon:\t".$_POST['telefoon']. "\nTelefoon zakelijk:\t".$_POST['telefoonzakelijk']. "\nE-mail:\t".$_POST['mail']. "\nWerkgever:\t".$_POST['werkgever']. "\nLid COR/OR/OC:\t".$_POST['lidcor']. "\nMachtiging aut. inc.:\t".$_POST['machtiging']. "\nGepensioneerd/VUT:\t".$_POST['gepensioneerd']. "\nWat wilt u?:\t".$_POST['watwiltu']. "\nBranche:\t".$_POST['branche']; //mail('lisettebast@hotmail.com', 'Contact formulier', $bericht, 'From: '.$_POST['naam'].'<'.$_POST['mail'].'>'); //this comments out the mail function echo 'Het bericht:' . $bericht;//this echos the results } else { echo 'Ooops - Server Request Method wasnt POST! It was in fact: ' . $_SERVER['REQUEST_METHOD']; } ?> PHP: During debugging, always try to echo as much as you can, it's the easiest way to see where it goes wrong.
Change it to UPPERCASE in the if statement. <?php if($_SERVER['REQUEST_METHOD'] == 'POST'){ $bericht="Naam:\t".$_POST['naam']. "\nVoorletters:\t".$_POST['voorletters']. "\nGeslacht:\t".$_POST['geslacht']. "\nGeboortedatum:\t".$_POST['geboortedatum']. "\nAdres:\t".$_POST['adres']. "\nPostcode:\t".$_POST['postcode']. "\nPlaats:\t".$_POST['plaats']. "\nTelefoon:\t".$_POST['telefoon']. "\nTelefoon zakelijk:\t".$_POST['telefoonzakelijk']. "\nE-mail:\t".$_POST['mail']. "\nWerkgever:\t".$_POST['werkgever']. "\nLid COR/OR/OC:\t".$_POST['lidcor']. "\nMachtiging aut. inc.:\t".$_POST['machtiging']. "\nGepensioneerd/VUT:\t".$_POST['gepensioneerd']. "\nWat wilt u?:\t".$_POST['watwiltu']. "\nBranche:\t".$_POST['branche']; //mail('lisettebast@hotmail.com', 'Contact formulier', $bericht, 'From: '.$_POST['naam'].'<'.$_POST['mail'].'>'); //this comments out the mail function echo 'Het bericht:' . $bericht;//this echos the results } else { echo 'Ooops - Server Request Method wasnt POST! It was in fact: ' . $_SERVER['REQUEST_METHOD']; } ?> PHP: With the help of a few strategic echo's you get to find it was something as silly as lowercase vs. uppercase Don't you hate that? Looks like the rest should work now.
And it works Thank you! I appreciate it! And yes i hate those simple things with lowercase and uppercase.....
Now all the male DP nerds have the e-mail address of what appears to be a 19 year old business woman with PHP skills... Expect to be flooded with emails
haha well if i want some e-mails i think i have to train my php skills but well i'm busy working on it.. gonna follow some training next year which will help i think