Welcome Guest, Not a member yet? Create Account  


email sender in php

#1
Lightbulb  (This post was last modified: 10-23-2018, 06:54 PM by alexxk5111.)

https://will-power-forum.com/email.php demo page.

support page 


if we look on the code here you can also see this handel errors 
<?php
if(isset($_POST['submit'])){
$to = $_POST['temail'];
if(!filter_var($toFILTER_VALIDATE_EMAIL)){
echo("enter the correct email");}
else{
$from = $_POST['femail'];
if(!filter_var($fromFILTER_VALIDATE_EMAIL)){
echo("enter the correct email");}

handel error
-------------------







sender name 
-------------------------

<form action="email.php" method="post">

you can rename email.php to something you want            also rename the email.php to your file name! in the code!




<!doctype html>
<?php
if(isset($_POST['submit'])){
$to = $_POST['temail'];
if(!filter_var($to, FILTER_VALIDATE_EMAIL)){
echo("enter the correct email");}
else{
$from = $_POST['femail'];
if(!filter_var($from, FILTER_VALIDATE_EMAIL)){
echo("enter the correct email");}
else {
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$message = $fname."".$lname."\n".$_POST['message'];
$message = wordwrap($message, 70);
$headers = "From:" . $from;
$subject = "form submission";
mail($to , $subject, $message, $headers);
echo("mail send");
}
}
}
?>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<form action="email.php" method="post">
<table align="center">
<tr>
<td>Name:</td>
<td><input type="text" name="fname" placeholder="first name">
<input type="text" name="lname" placeholder="last name"></td>
</tr>
<tr><td>To:</td>
<td><input type ="email" name="temail" placeholder="example@example.com"></td<-- if we look here we can see this show example@example.com
</tr><br><br>                                                                                                                     as none text look on in the page on in the top url
<tr>     
<td>From:</td>
<td><input type="email" name="femail" placeholder="example@example.com"></td></tr>
<tr>
<td>Message:</td>
<td><textarea cols="40" rows="5" placeholder="Enter your useful message here" name="message"></textarea></td></tr>
<tr><td></td><td><input type="submit" name="submit" value="send"></td>
</tr>
</table>
</form>
</body>
</html>




you can also download the file!

Attached Files
.php   contact-us.php (Size: 1.32 KB / Downloads: 2)
Reply




Users browsing this thread:
1 Guest(s)