Jump to content

kimikai

Members
  • Posts

    18
  • Joined

  • Last visited

kimikai's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Where do I have to put that, because I tried to set it around this part: $attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name']))); $filename = $_FILES['file']['name']; But that didn't work... might be that I didn't include enough?
  2. Oh dam haha completely missed that It works now, And I know its not the right way to do it... buut... since you are responding to this topic anyways I might aswell ask another question. Thats the last problem I would like to get out of it. Its a form that can send an attachment. But I've found that it will always send an empty attachment with the mail, whether you actually send an attachment or not. Im fairly new to PHP so I guess theres a way to fix that aswell. But I kinda dont know how...
  3. thats what i thought too... basically the page is set up like this: - PHP forum check + mail send - <head> tags where it sets the charset - <body> tags with the forum in it i also tried to set in the forum action : accept-characters utf-8... but that didnt work either
  4. i have this in my <head> tags <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> but the <head> tags are set below the PHP part of where it deals with checking the form and sending the message... could that be the problem?
  5. I have a question, I have a fully working PHP mail form, but I can't seem to find one problem. I thought it had something to do with the data cleansing like trim, htmlspecialcharacters and stripslashes, but unfortunately that wasn't. My form has to be able to process characters like é è á ó etc. Just that now when you fill those characters in it shows some weird code in the mail. (é becomes é in the mail) and this is highly inconvenient. Could any1 tell me how I can fix this? this is the PHP code for my form: <?php if(isset($_POST['submit'])) { function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $error = ""; //Keep Values $Papillon_checked = (isset($_POST['ras']) && $_POST['ras'] == 'Papillon') ? 'checked' : ''; $Phalene_checked = (isset($_POST['ras']) && $_POST['ras'] == 'Phalene') ? 'checked' : ''; $Babyklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Babyklasse') ? 'checked' : ''; $Puppyklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Puppyklasse') ? 'checked' : ''; $Jeugdklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Jeugdklasse') ? 'checked' : ''; $Tussenklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Tussenklasse') ? 'checked' : ''; $Openklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Openklasse') ? 'checked' : ''; $Kampioensklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Kampioensklasse') ? 'checked' : ''; $Fokkersklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Fokkersklasse') ? 'checked' : ''; $Veteranenklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Veteranenklasse') ? 'checked' : ''; //Validate form fields if (!empty($_POST['ras'])) { $ras = $_POST['ras']; } else { $error .= "- Klik het ras van uw hond aan. <br />";} if (!empty($_POST['kleur'])) { $kleur = test_input($_POST['kleur']); } else { $error .= "- Vul de kleur van uw hond in. <br />";} if (!empty($_POST['geslacht'])) { $geslacht = test_input($_POST['geslacht']); } else { $error .= "- Vul het geslacht van uw hond in. <br />";} if (!empty($_POST['naamhond'])) { $naamhond = test_input($_POST['naamhond']); } else { $error .= "- Vul de naam van uw hond in. <br />";} if (!empty($_POST['stamboom'])) { $stamboom = test_input($_POST['stamboom']); } else { $error .= "- Vul het stamboomnummer van uw hond in. <br />";} if (!empty($_POST['geboorte'])) { $geboorte = test_input($_POST['geboorte']); } else { $error .= "- Vul de geboortedatum van uw hond in. <br />";} if (!empty($_POST['klasse'])) { $klasse = $_POST['klasse']; } else { $error .= "- Klik de gewenste klasse aan. <br />"; } if (!empty($_POST['fokker'])) { $fokker = test_input($_POST['fokker']); } else { $error .= "- Vul de naam van de fokker in. <br />";} if (!empty($_POST['vader'])) { $vader = test_input($_POST['vader']); } else { $error .= "- Vul de naam van de vaderhond in. <br />";} if (!empty($_POST['moeder'])) { $moeder = test_input($_POST['moeder']); } else { $error .= "- Vul de naam van de moederhond in. <br />";} if (!empty($_POST['initialen'])) { $initialen = test_input($_POST['initialen']); } else { $error .= "- Vul uw initialen in. <br />";} if (!empty($_POST['eigachternaam'])) { $eigachternaam = test_input($_POST['eigachternaam']); } else { $error .= "- Vul uw achternaam in. <br />";} if (!empty($_POST['minitialen'])) { $minitialen = test_input($_POST['minitialen']);} if (!empty($_POST['meigachternaam'])) { $meigachternaam = test_input($_POST['meigachternaam']);} if (!empty($_POST['straat'])) { $straat = test_input($_POST['straat']); } else { $error .= "- Vul uw straatnaam in. <br />";} if (!empty($_POST['huisnr'])) { $huisnr = test_input($_POST['huisnr']); } else { $error .= "- Vul uw huisnummer in. <br />";} if (!empty($_POST['postcode'])) { $postcode = test_input($_POST['postcode']); } else { $error .= "- Vul uw postcode in. <br />";} if (!empty($_POST['plaats'])) { $plaats = test_input($_POST['plaats']); } else { $error .= "- Vul uw woonplaats in. <br />";} if (!empty($_POST['land'])) { $land = test_input($_POST['land']);} if (!empty($_POST['email'])) { $email = $_POST['email']; if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email)){ $error .= "- U heeft een ongeldig e-Mail adres ingevuld. <br/>";} } else { $error .= "- Vul uw e-Mail adres in. <br />";} if (!empty($_POST['telefoon'])) { $telefoon = test_input($_POST['telefoon']);} if (!empty($_POST['peradres'])) { $peradres = test_input($_POST['peradres']);} if (!empty($_POST['eerstehond'])) { $eerstehond = test_input($_POST['eerstehond']);} if (!empty($_POST['verderehond'])) { $verderehond = test_input($_POST['verderehond']);} if (!empty($_POST['babypup'])) { $babypup = test_input($_POST['babypup']);} if (!empty($_POST['koppelklas'])) { $koppelklas = test_input($_POST['koppelklas']);} if (!empty($_POST['koppelhond1'])) { $koppelhond1 = test_input($_POST['koppelhond1']);} if (!empty($_POST['koppelhond2'])) { $koppelhond2 = test_input($_POST['koppelhond2']);} if (!empty($_POST['totaal'])) { $totaal = test_input($_POST['totaal']);} if (!empty($_POST['naamjh'])) { $naamjh = test_input($_POST['naamjh']);} if (!empty($_POST['leeftijdjh'])) { $leeftijdjh = test_input($_POST['leeftijdjh']);} if (!empty($_POST['akkoord'])) { $akkoord = $_POST['akkoord']; } else { $error .= "- U moet akkoord gaan met de voorwaarden voordat u het bericht kunt versturen. <br />";} //no errors were set if(empty($error)) { //code to send the email //The form has been submitted, prep a nice thank you message $output = '<center><b>Het Inschrijfformulier is verzonden <br />We zullen de gegevens verwerken <br/><u>Papillon & Phalène Vereniging Nederland</u></b></center>'; //Set the form flag to no display (cheap way!) $flags = 'style="display:none;"'; //Deal with the email $to = 'joke@pp-vn.nl'; $from = $_POST['email']; $subject = 'Inschrijfformulier'; $message = 'From: ' .$initialen .' ' .$eigachternaam . ' <' . $email . '>' ."\n\n"; $message .= 'Ras: ' .$ras ."\n"; $message .= 'Kleur: ' .$kleur ."\n"; $message .= 'Geslacht: ' .$geslacht ."\n"; $message .= 'Naam v/d hond: ' .$naamhond ."\n"; $message .= 'Stamboomnummer: ' .$stamboom ."\n"; $message .= 'Geboortedatum: ' .$geboorte ."\n"; $message .= 'Klasse: ' .$klasse ."\n"; $message .= 'Naam Fokker: ' .$fokker ."\n"; $message .= 'Naam Vaderhond: ' .$vader ."\n"; $message .= 'Naam Moederhond: ' .$moeder ."\n"; $message .= 'Eigenaar: ' .$initialen .' ' . $eigachternaam ."\n"; $message .= 'Mede-eigenaar: ' .$minitialen .' ' .$machternaam ."\n"; $message .= 'Adres: ' .$straat .' ' .$huisnr .' ' .$postcode .' ' .$plaats .' ' .$land ."\n"; $message .= 'Telefoon: ' .$telefoon ."\n"; $message .= 'e-Mail: ' .$email ."\n"; $message .= 'Per Adres: ' .$peradres ."\n"; $message .= 'Inschrijving eerste hond: ' .$eerstehond . "\n"; $message .= 'Andere honden ingeschreven: ' .$verderehond . "\n"; $message .= 'Baby- Puppyklasse: ' .$babypup . "\n"; $message .= 'Koppelklasse: ' .$koppelklas . "\n"; $message .= 'Koppelklasse Hond 1: ' .$koppelhond1 . "\n"; $message .= 'Koppelklasse Hond 2: ' .$koppelhond2 . "\n"; $message .= 'Totaalbedrag: ' .$totaal . "\n"; $message .= 'Naam Juniorhandler: ' .$naamjh . "\n"; $message .= 'Leeftijd Juniorhandler: ' .$leeftijdjh . "\n"; $message .= 'Akkoord: ' .$akkoord ."\n"; $attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name']))); $filename = $_FILES['file']['name']; $boundary =md5(date('r', time())); $headers = "From: fransien@pp-vn.nl"; $headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\""; $message="This is a multi-part message in MIME format. --_1_$boundary Content-Type: multipart/alternative; boundary=\"_2_$boundary\" --_2_$boundary Content-Type: text/plain; charset=\"iso-8859-1\" Content-Transfer-Encoding: 7bit $message --_2_$boundary-- --_1_$boundary Content-Type: application/octet-stream; name=\"$filename\" Content-Transfer-Encoding: base64 Content-Disposition: attachment $attachment --_1_$boundary--"; mail($to, $subject, $message, $headers); mail($from, $subject, $message, $headers); } else { //display errors echo '<center><span class="error"><strong>Uw bericht is niet verstuurd<br/> De volgende fout(en) zijn opgetreden:</strong><br/>' . $error . '<br /><strong><u>Pas op: Bij een foutmelding indien nodig Kampioenstitel opnieuw toevoegen!!</u></strong></span></center>'; } } ?>
  6. nope still not working, i literally copied your code and replaced mine with it. and indeed it does keep the checkbox ticked now when form submission fails... but im still having the same trouble with the rest as before, It still doesnt show the error set for "akkoord" at the top with the rest of the errors, basically now it doesnt matter whether or not i check the box or not, it sends the form anyway. and the value set for it still doesnt show up in the mail... im really at a loss for whats wrong I also tried the code without the echo for the checkbox but it gives me the same results you can send it w/ or w/o checking the box and the value wont show on the mail
  7. ahhh okay, now i get you haha darn really need to get more comfortable with php thnx for the amazing help
  8. is that all thats bothering it, cuz w/o the echo it didnt work either...
  9. Got most of my form done and everything works perfectly...but since i set all values to be returned after error it seems like it wont read the error for my checkbox anymore, and it doesnt show in my mail anymore either (before it would be "Accept: on") does anyone know how this is possible? cuz i believe theres nothing wrong about my code... Error check for the checkbox 'akkoord' if (!empty($_POST['akkoord'])) { $akkoord = $_POST['akkoord']; } else { $error .= "- U moet akkoord gaan met de voorwaarden voordat u het bericht kunt versturen. <br />";} } This is to set it should send the info (aka it has been ticked) within the mail $message .= 'Akkoord: ' .$akkoord . "\n"; And this is the HTML for the checkbox: <input type="checkbox" name="akkoord" id="akkoord" /> <label for="akkoord">Ik ga akkoord met de voorwaarden</label> Just in case something else is wrong and wants to check the full code ill add it as an attachment test.php
  10. btw one more question... The fields that are required ill have to set them seperate to get the error codes for each one but now for the not required fields im typing this everytime: if(!empty($_POST['nameofthefield'])){ $nameofthefield = $_POST['nameofthefield']; } would there be a way to say like "if there is information in any of these unrequired fields, then send the info thats within them"? so basically if(!empty -- string of all the unrequired fields-)) then send everything thats within those fields?
  11. ahhh yes yes thank you lol failed to see the last part indeed. but ye i do understand thanks for the help
  12. so: // code to validate all fields//after its emptyif(empty($error)){ //everything i had within //the form has been submitted}else{ $error = "";}Like that?
  13. Been working on this form and it does send a mail to me which is good...but the problem is, it always sends a mail to me. I can't seem to get a working check in it where it checks for required fields etc. This is what I have so far, so I'm wondering what I'm doing wrong...could someone send me in the right direction? This is the PHP part: <?php if(isset($_POST['submit'])) { $error = ""; if(!empty($_POST['naam'])) { $naam = $_POST['naam']; } else { $error .= "Vul uw naam in"; } //The form has been submitted, prep a nice thank you message $output = '<center><b><u>Uw Kampioenschapscertificaat is verzonden</u></b></center>'; //Set the form flag to no display (cheap way!) $flags = 'style="display:none;"'; //Deal with the email $to = 'nabben.daisy@live.nl'; $subject = 'Kampioenschapscertificaat'; $message = 'Naam: ' .$naam ."\n"; $message .= 'Naam Hond: ' .$naamhond ."\n"; $attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name']))); $filename = $_FILES['file']['name']; $boundary =md5(date('r', time())); $headers = "From: pp-vn@website.nl\r\nReply-To: pp-vn@website.nl"; $headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\""; $message="This is a multi-part message in MIME format. --_1_$boundary Content-Type: multipart/alternative; boundary=\"_2_$boundary\" --_2_$boundary Content-Type: text/plain; charset=\"iso-8859-1\" Content-Transfer-Encoding: 7bit $message --_2_$boundary-- --_1_$boundary Content-Type: application/octet-stream; name=\"$filename\" Content-Transfer-Encoding: base64 Content-Disposition: attachment $attachment --_1_$boundary--"; mail($to, $subject, $message, $headers); } ?> This is the HTML of the form: <body> <?php echo $output; ?> <div id="container"> <div id="form"> <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" <?php echo $flags;?>> <p> <label for="naam">Naam</label> <input type="text" name="naam" id="naam"> </p> <p>Uw Naam + Naam Hond: <textarea name="naamhond" id="naamhond" cols="80" rows="8"></textarea> </p> <label for="file">File</label><input type="file" name="file" id="file"></p> <center><input type="submit" name="submit" id="submit" value="Verzend Kampioenscertificaat"></center> </form> </div> </div> </body> Anyone has an idea on how to fix this?
  14. < ?php if (isset($_POST['submit'])) { $error = ""; if (!empty($_POST['ras'])) { $ras = $_POST['ras']; } else { $error .= "- Klik het ras van uw hond aan. <br />"; } //Bunch more of if(!empty) checks\\ if (empty($error)) { $from = 'From: ' .$initialen . $eigachternaam . ' <' . $email . '>'; $to = "nabben.daisy@live.nl"; $subject = "Inschrijfformulier"; $content = $eigachternaam . " heeft een inschrijfformulier ingevuld: \n"; $content .= 'Ras: ' .$ras . "\n"; $content .= 'Kleur: ' .$kleur . "\n"; $content .= 'Geslacht: ' .$geslacht . "\n"; $content .= 'Naam v/d Hond: ' .$naamhond . "\n"; $content .= 'Geboortedatum: ' .$geboorte . "\n"; $content .= 'Klasse: ' .$klasse . "\n"; $content .= 'Fokker: ' .$fokker . "\n"; $content .= 'Vaderhond: ' .$vader . "\n"; $content .= 'Moederhond: ' .$moeder . "\n"; $content .= 'Naam eigenaar: '.$initialen ; $content .= ' '.$eigachternaam . "\n"; $content .= 'Naam mede-eigenaar: '.$minitialen ; $content .= ' '.$meigachternaam . "\n"; $content .= 'Adresgegevens: ' .$straat ; $content .= ' '.$huisnr ; $content .= ' '.$postcode ; $content .= ' '.$woonplaats ; $content .= ' '.$land . "\n"; $content .= 'Telefoon: ' .$telefoon . "\n"; $content .= 'e-Mail: ' .$email . "\n"; $content .= 'Per Adres: ' .$peradres . "\n"; $content .= 'Eerste Hond: ' .$eerstehond . "\n"; $content .= 'Verdere Hond: ' .$verderehond . "\n"; $content .= 'Baby- Puppyklasse: ' .$babypup . "\n"; $content .= 'Koppelklasse: ' .$koppelklas . "\n"; $content .= 'Koppelklasse Hond 1: ' .$koppelhond1 . "\n"; $content .= 'Koppelklasse Hond 2: ' .$koppelhond2 . "\n"; $content .= 'Totaalbedrag: ' .$totaal . "\n"; $content .= 'Naam Juniorhandler: ' .$naamjh . "\n"; $content .= 'Leeftijd Juniorhandler: ' .$leeftijdjh . "\n"; $content .= 'Akkoord: ' .$akkoord . "\n"; $success = "<center><strong>Bedankt voor uw aanmelding!<br />We zullen de gegevens verwerken.<br />Papillon en Phalène Vereniging Nederland</strong></center>"; mail($to,$subject, $content, $from); } } ?> <div id="container"> <div id="form"> <?php if (!empty($error)) { echo '<p class="error"><strong>Uw bericht is niet verstuurd<br/> De volgende fout(en) zijn opgetreden:</strong><br/>' . $error . '</p>'; } elseif (!empty($success)) { echo $success; } ?> thats my PHP code which i use now... this deals with every regular input field and sends me an email after someone hits the submit button. The only thing i cant figure out is how to add a piece of coding into this to get attachments send with it (from an input file field). I dont know if its restricted to the way I've written the rest of the PHP text. If that makes sense....
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.