Hi,

can you pl help me on the submission of a form when submit button clicked the form content have to send as a mail.

Recommended Answers

All 4 Replies

Submit the form to a PHP script or the self page itself. And then use $_GET or $_POST to retrieve the values as per your method used in form ( get or post ).

Then you can format the message using the retrieved values.
for emailing simply use mail() function . Its format is mail ( to, subject, message, header )

here is something quick and easy i have put together

<html>
<head>
<title>Send an Email</title>
</head>
<body>
<h1>Send an Email
  <br>
  <?php
 if (isset($_POST['Send'])) {
 
  
// Read POST request params into global vars
$to      = $_POST['to'];
$from    = $_POST['from'];
$subject = $_POST['subject'];
$message = $_POST['message'];

$headers = "From: $from";

// Send the message
$ok = @mail($to, $subject, $message, $headers);
if ($ok) {
  echo "<p>Mail sent! Yay PHP!</p>";
} else {
  echo "<p>Mail could not be sent. Sorry!</p>";
}
}
?>
</h1>
<form id="form1" name="form1" method="post" action="">
<p>To: <input type="text" name="to" value="" /><br />
From: <input type="text" name="from" value="" /><br />
Subject: <input type="text" name="subject" value="" /></p>
<p>Message:<br />
<textarea cols="70" rows="20" name="message"></textarea></p>
<p><input name="Send" type="submit" id="Send" value="Send" /></p>
</form>
</body>
</html>

Can use the following header for more supports
$headers = "From: $from\r\nContent-type: text/html";

Can use the following header for more supports
$headers = "From: $from\r\nContent-type: text/html";

yea good call

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.