Articles

Please find some interesting Code Snippets or CSS-Tricks that could help the software developers or the front-end designers some how.

Articles PHP Feed Back Form

It is nice to meet you again in the Feed Back Form development through the following codes, and the Feed Back Form consists of two main pages. The first page is the HTML form while the second page is the PHP, ASP or JSP page where the second page has to receive the sent data and send it again to the Email address. Let us first start with the HTML form page.

1- HTML Form Page:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
<title> Form Page</title>
</head>
<body>
<form action="send.php" method="POST">
First Name: <input type="text" name="first" value="">
<br>
Last Name: <input type="text" name="last" value="">
<br>
Mobile: <input type="text" name="mobile" value="">
<br>
Country: <input type="text" name="country" value="">
<br>
Email: <input type="text" name="email" value="">
<br>
Body: <textarea cols="40" rows="8" name="body"></textarea>
<br>
<input type="submit" name="" value="SEND">
</form>
</body>
</html>

2- PHP send.php Page:

<?php

// Receiving the data from the fields and set the data to a variables 
$first = $_POST; 
$last = $_POST;
$mobile = $_POST;
$country = $_POST;
$email = $_POST;
$body = $_POST;

// Testing the missing data
if ($first == "" || $last == "" || $mobile == "" || $country == "" || $body == ""){
    print "Missing data sent, please check the data before sending";
    print "<a href='javascript:history.go(-1);'>BACK</a>";
    exit;
}

// Testing the validation of the Email
if (eregi("^+@+\.+$>", $email)) {
    print "Please check the Email format before sending";
    print "<a href='javascript:history.go(-1);'>BACK</a>";
    exit;
}

// defining the sent data
$to = "youremail@companyname.com";
$subject = "Message from your website";
$body = strip_tags($body);
$header = "From: ". $first . " <" . $email . ">\r\n";

// Sending the mail
$sent = mail($to,$subject,$body,$header);

// Testing the sent status
if($sent){
    print "Your mail has been sent successfully";
}
?>

Regards,
Wail Shalabi.