php - Form Sending Email but Showing blank Page -
i have homepage on testing server. when submit form, page shows blank page, sending email.
the second problem is, checkbox values not shown in email, don't think read php-file...
my button has proper type (submit), don't have spelling mistakes in names...and not php, therefore don't know, wrong. appreciated.
html-code
<form action="contact.php" id="form" method="post" name="send"> <span class="input input--kuro"> <div class="row"> <h3 class="big-blue">kontaktformular</h3> <h2 class="small-grey">bitte füllen sie das formular aus, damit wir ihnen ein individuelles angebot zukommen lassen können.</h2> </div> <div class="row"> <div class="row"> <div class="input-wrapper col-md-4 col-centered"> <input class="requiredfield name subscribe-requiredfield input__field input__field--kuro" type="text" name="name" placeholder="name" id="name"> <label class="input__label input__label--kuro" for="subscribe-email"> <span class="mail input__label-content input__label-content--kuro">name</span> </label> </div> <div class="input-wrapper col-md-4 col-centered"> <input class="requiredfield subscribe-requiredfield input__field input__field--kuro" type="text" name="firma" placeholder="firma" id="firma"> <label class="input__label input__label--kuro" for="subscribe-email"> <span class="mail input__label-content input__label-content--kuro">firma</span> </label> </div> </div> <div class="row"> <div class="input-wrapper col-md-4 col-centered"> <input class="requiredfield email subscribe-requiredfield input__field input__field--kuro" type="text" name="email" placeholder="email" id="email"> <label class="input__label input__label--kuro" for="subscribe-email"> <span class="mail input__label-content input__label-content--kuro">email</span> </label> </div> <div class="input-wrapper col-md-4 col-centered"> <input class="requiredfield subscribe-requiredfield input__field input__field--kuro" type="text" name="number" placeholder="telefonnummer" id="number"> <label class="input__label input__label--kuro" for="subscribe-email"> <span class="mail input__label-content input__label-content--kuro">telefonnummer</span> </label> </div> </div> </div> </div> </ul> <li><button class="submit-button" id="submit" type="submit">senden</button></li> <li><button type="button" class="btn btn-primary added-btn" title="zur Übersicht." id="gesamt-zurueck" name="submit-clear" >zurück zur Übersicht</button></li> </ul> </div> </span> <div class="hidden"> <ul class="checker-wrap"> <li><input type="checkbox" id="0" value="zielgruppendefinition" class="0 checker" name="checkbox-group[]"></li> <li><input type="checkbox" id="1" value="namensfindung & logoentwicklung" class="1 checker" name="checkbox-group[]"></li> <li><input type="checkbox" id="2" value="exposé" class="2 checker" name="checkbox-group[]"></li> <li><input type="checkbox" id="3" value="textdesign" class="3 checker" name="checkbox-group[]"></li> <li><input type="checkbox" id="4" value="anzeigenkampagnen" class="4 checker" name="checkbox-group[]"></li> <li><input type="checkbox" id="5" value="außenwerbung" class="5 checker" name="checkbox-group[]"></li> <li><input type="checkbox" id="6" value="bautafelgestaltung" class="6 checker" name="checkbox-group[]"></li> <li><input type="checkbox" id="8" value="website" class="8 checker" name="checkbox-group[]"></li> <li><input type="checkbox" id="9" value="social media" class="9 checker" name="checkbox-group[]"></li> <li><input type="checkbox" id="10" value="digitale präsentation" class="10 checker" name="checkbox-group[]"></li> <li><input type="checkbox" id="11" value="innenvisualisierungen" class="11 checker" name="checkbox-group[]"></li> <li><input type="checkbox" id="14" value="außenvisualisierungen" class="11 checker" name="checkbox-group[]"></li> <li><input type="checkbox" id="12" value="virtuelle begehung" class="12 checker" name="checkbox-group[]"></li> <li><input type="checkbox" id="13" value="augmented reality" class="13 checker" name="checkbox-group[]"></li> </ul> </div>
the php-file code:
<?php $errors = ''; $myemail = 'schroeder@exposedesign.de'; if(empty($_post['name']) || empty($_post['email']) || empty($_post['number']) || empty($_post['firma'])) { $errors .= "\n error: required field"; } $name = $_post['name']; $email = $_post['email']; $number = $_post['number']; $firma = $_post['firma']; $checkbox = $_post['checkbox-group']; if (!eregi( "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { $errors .= "\n error: invalid email address"; } if( empty($errors)) { $to = $myemail; $email_subject = "angebot angefordert"; $email_body = "\n name: $name \n email: $email \n firma: $firma \n telefon: \n $number"; $headers = "from: $email"; $leistungen = "\n gewählte leistungen: $checkbox"; mail($to, $email_subject, $email_body, $headers, $leistungen); } ?>
the jquery code:
// contact form $("form#form").submit(function() { $("form#form .error").remove(); var s = !1; if ($(".requiredfield").each(function() { if ("" === jquery.trim($(this).val())) { $(this).prev("label").text(), $(this).parent().append('<span class="error">this field required</span>'), $(this).addclass( "inputerror"), s = !0; } else if ($(this).hasclass("email")) { var r = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; r.test(jquery.trim($(this).val())) || ($(this).prev("label").text(), $(this).parent().append('<span class="error">invalid email address</span>'), $( this).addclass("inputerror"), s = !0); } }), !s) { $("form#form input.submit").fadeout("normal", function() { $(this).parent().append(""); }); var r = $(this).serialize(); $.post($(this).attr("action"), r, function() { $("form#form").slideup("fast", function() { $(this).before('<div class="success">your email sent successfully.</div>'); $(".done-wrapper").toggleclass("hidden"); }); }); } $('.label-wrap ul').find('.'+btn_class[0]).toggleclass("hide-me added haken"); $('#form')[0].reset(); return !1; });
regarding blank-page issue: you're processing, not outputting anything. post redirect-header @ end - possibly according errors occuring or not.
// 307 temporary redirect header("location: /foo.php",true,307);
..or output stuff after processing. practice might keep processing , form-display in 1 file - pre-populate form fields did not produce errors , mark failed user can try again.
regarding checkbox-group issue:
echo implode( ", ", $_post['checkbox-group'] );
to prove got passed along:
header("content-type:text/plain;charset=utf-8"); echo print_r($_post,true);
Comments
Post a Comment