Ive need help making a form for a contact form,ive got the html side sorted but whenever i make a php form to actually post the information to my email i recieve an email but no message ? Can anyone help me out as to what the correct php code should be ? Heres the html : <form class="cmxform" id="contactForm" method="POST" action="mailer.php"> <fieldset> <p> <label for="cname">Name</label> <input type="text" name="cname" class="required" value="" id="cname" /> </p> <p> <label for="cemail">Email</label> <input type="text" name="cemail" class="required email" value="" id="cemail" /> </p> <p> <label for="csubject">Website</label> <input type="text" name="csubject" class="required" value="" id="csubject" /> </p> <p> <label for="ccomment">Message</label> <textarea cols="30" rows="10" class="required" name="ccomment" id="ccomment"></textarea> </p> </fieldset> <p><button class="submit" type="submit">Send</button></p> </form> HTML: Thanks in advance
Can you show us your PHP code for this? From what it looks like, there is no issues with the form, only how the PHP is handling the data that you are passing to it
<?php // Contact subject $subject ="$csubject"; // Details $message="$ccomment"; // Mail of sender $mail_from="$cemail"; // From $header="from: $cname <$mail_from>"; // Enter your email address $to ='test@test.com'; $send_contact=mail($to,$subject,$message,$header); // Check, if message sent to your email // display message "We've recived your information" if($send_contact){ echo "We've recived your contact information"; } else { echo "ERROR"; } ?> PHP:
Make it into: I have assumed you've not used the $_POST to get the data first from the snippet you provided It is also worth implementing some level of data cleansing to prevent any malicous use of the form
add in mailer.php just after <?php foreach($_GET AS $key => $value) { ${$key} = $value; } foreach($_POST AS $key => $value) { ${$key} = $value; }