D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
bambooinn.in
/
admin
/
Filename :
demo.php
back
Copy
<html> <head> <title>PHP Contact Form</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div class="form-container"> <form name="frmContact" id="" frmContact="" method="post" action="" enctype="multipart/form-data" onsubmit="return validateContactForm()"> <div class="input-row"> <label style="padding-top: 20px;">Name</label> <span id="userName-info" class="info"></span><br /> <input type="text" class="input-field" name="userName" id="userName" /> </div> <div class="input-row"> <label>Email</label> <span id="userEmail-info" class="info"></span><br /> <input type="text" class="input-field" name="userEmail" id="userEmail" /> </div> <div class="input-row"> <label>Subject</label> <span id="subject-info" class="info"></span><br /> <input type="text" class="input-field" name="subject" id="subject" /> </div> <div class="input-row"> <label>Message</label> <span id="userMessage-info" class="info"></span><br /> <textarea name="content" id="content" class="input-field" cols="60" rows="6"></textarea> </div> <div> <input type="submit" name="send" class="btn-submit" value="Send" /> <div id="statusMessage"> <?php if (! empty($message)) { ?> <p class='<?php echo $type; ?>Message'><?php echo $message; ?></p> <?php } ?> </div> </div> </form> </div> <script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script> <script type="text/javascript"> function validateContactForm() { var valid = true; $(".info").html(""); $(".input-field").css('border', '#e0dfdf 1px solid'); var userName = $("#userName").val(); var userEmail = $("#userEmail").val(); var subject = $("#subject").val(); var content = $("#content").val(); if (userName == "") { $("#userName-info").html("Required."); $("#userName").css('border', '#e66262 1px solid'); valid = false; } if (userEmail == "") { $("#userEmail-info").html("Required."); $("#userEmail").css('border', '#e66262 1px solid'); valid = false; } if (!userEmail.match(/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/)) { $("#userEmail-info").html("Invalid Email Address."); $("#userEmail").css('border', '#e66262 1px solid'); valid = false; } if (subject == "") { $("#subject-info").html("Required."); $("#subject").css('border', '#e66262 1px solid'); valid = false; } if (content == "") { $("#userMessage-info").html("Required."); $("#content").css('border', '#e66262 1px solid'); valid = false; } return valid; } </script> </body> </html> <?php function strip_crlf($string) { return str_replace("\r\n", "", $string); } if (! empty($_POST["send"])) { $name = $_POST["userName"]; $email = $_POST["userEmail"]; $subject = $_POST["subject"]; $content = $_POST["content"]; $toEmail = "admin@phppot_samples.com"; // CRLF Injection attack protection $name = strip_crlf($name); $email = strip_crlf($email); if (! filter_var($email, FILTER_VALIDATE_EMAIL)) { echo "The email address is invalid."; } else { // appending \r\n at the end of mailheaders for end $mailHeaders = "From: " . $name . "<" . $email . ">\r\n"; if (mail($toEmail, $subject, $content, $mailHeaders)) { $message = "Your contact information is received successfully."; $type = "success"; } } } // $ToEmail = 'youremail@site.com'; // $EmailSubject = 'Site contact form'; // $mailheader = "From: ".$_POST["email"]."\r\n"; // $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; // $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; // $MESSAGE_BODY = "Name: ".$_POST["name"].""; // $MESSAGE_BODY .= "Email: ".$_POST["email"].""; // $MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"]).""; // mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); // require_once "inquiry-list.php"; ?>