Author Topic: Contact Us page for your website  (Read 22 times)

October 17, 2019, 12:09:54 PM
Read 22 times

jdaniele

  • *****
  • Information Offline
  • Sr. Member
  • Administrator
  • Posts: 1214
  • Never stop questioning
    • View Profile
    • JeremyDaniele.com
So this is a big thing nowadays because people are afraid of all the SPAM. I wouldn't personally call it the proper way to go about it but it is popular so here is an article that goes about making it.

https://www.formget.com/send-an-email-on-form-submission-using-php/

I used a Linux format because of the hosting we use but there's also options for Window Server.

One is https://docs.microsoft.com/en-us/aspnet/web-pages/overview/getting-started/11-adding-email-to-your-web-site
or https://www.w3schools.com/asp/webpages_email.asp
or https://www.codeproject.com/Tips/371417/Send-Mail-Contact-Form-using-ASP-NET-and-Csharp
or http://www.tizag.com/aspTutorial/aspFormsEmail.php

Quote
HTML file: secure_email_form.php
Code: [Select]
<!DOCTYPE html>
<html>
<head>
<title>FeedBack Form With Email Functionality</title>
<link href="css/elements.css" rel="stylesheet">
</head>
<!-- Body Starts Here -->
<body>
<div class="container">
<!-- Feedback Form Starts Here -->
<div id="feedback">
<!-- Heading Of The Form -->
<div class="head">
<h3>FeedBack Form</h3>
<p>This is feedback form. Send us your feedback !</p>
</div>
<!-- Feedback Form -->
<form action="#" id="form" method="post" name="form">
<input name="vname" placeholder="Your Name" type="text" value="">
<input name="vemail" placeholder="Your Email" type="text" value="">
<input name="sub" placeholder="Subject" type="text" value="">
<label>Your Suggestion/Feedback</label>
<textarea name="msg" placeholder="Type your text here..."></textarea>
<input id="send" name="submit" type="submit" value="Send Feedback">
</form>
<h3><?php include "secure_email_code.php"?></h3>
</div>
<!-- Feedback Form Ends Here -->
</div>
</body>
<!-- Body Ends Here -->
</html>

PHP File: secure_email_code.php
Code: [Select]
<?php
if(isset($_POST["submit"])){
// Checking For Blank Fields..
if($_POST["vname"]==""||$_POST["vemail"]==""||$_POST["sub"]==""||$_POST["msg"]==""){
echo 
"Fill All Fields..";
}else{
// Check if the "Sender's Email" input field is filled out
$email=$_POST['vemail'];
// Sanitize E-mail Address
$email =filter_var($emailFILTER_SANITIZE_EMAIL);
// Validate E-mail Address
$emailfilter_var($emailFILTER_VALIDATE_EMAIL);
if (!
$email){
echo 
"Invalid Sender's Email";
}
else{
$subject $_POST['sub'];
$message $_POST['msg'];
$headers 'From:'$email2 "rn"// Sender's Email
$headers .= 'Cc:'$email2 "rn"// Carbon copy to Sender
// Message lines should not exceed 70 characters (PHP rule), so wrap it
$message wordwrap($message70);
// Send Mail By PHP Mail Function
mail("recievers_mail_id@xyz.com"$subject$message$headers);
echo 
"Your mail has been sent successfuly ! Thank you for your feedback";
}
}
}
?>

The rest are styling information.

This is a great way to have customers send you emails without knowing your actual email address. I wouldn't just copy and paste because you need to make it work on your site and also not just break copyrights is some are there.
"The true sign of intelligence is not knowledge but imagination." - Albert Einstein


There are no comments for this topic. Do you want to be the first?