Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Contact Form, Contact form using mail() function
FaLgoR
post Jan 4 2005, 06:12 PM
Post #1


Super Member
*********

Group: Members
Posts: 217
Joined: 2-January 05
Member No.: 3,084



In first place, make an html page with the form.

<html>
<head>
<title>My first form with PHP</title>
</head>
<body>
<form action="sendmail.php" method="post">
<table border="0">
<tr>
<td>Name:</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>E-Mail:</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>Subject:</td>
<td><input type="text" name="subject"></td>
</tr>
<tr>
<td>Mesage:</td>
<td><textarea name="mesage"></textarea></td>
</tr>
<tr>
<td><input type="submit" value="Send Mesage"></td>
<td><input type="reset" value="Reset Form"></td>
</tr>
</table>
</form>

</body>
</html>

OK, now, lets make sendmail.php:

<?
$myemail = 'yourmail@blah.com'; // Put here your e-mail address

mail($myemail,$subject,$mesage,$email) // To, Subject, Mesage and From

echo 'Thank you for your e-mail!';
?>

Simple, huh?
Any questions just post here.
Go to the top of the page
 
+Quote Post
OpaQue
post Jan 4 2005, 06:25 PM
Post #2


Administrator
Group Icon

Group: Admin
Posts: 1,480
Joined: 11-June 04
From: Somewhere in Time & Space.
Member No.: 1



THE SENDMAIL.PHP can be improved much further by using the following code
CODE

<?php
/* recipients */
$to  = $_POST["email"];  . ", "; // note the comma
$to .= "any-extra-people-u-want-to-send-email@example.com";

/* subject */
$subject = $_POST["subject"];

/* message */
$message = <<<END
<html>
<head>
<title>$_POST["subject"]</title>
</head>
<body>
$_POST["message"]
</body>
</html>
END;

/* To send HTML mail, you can set the Content-type header. */
// SENDING EMAIL IN HTML FORMAT RATHER THAN TEXT IN PREVIOUS EXAMPLE

$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* additional headers */
$headers .= "To: $_POST["name"]<$_POST["email"]>\r\n";
$headers .= "From: ANYGOOD NAME <YOUR-EMAIL@example.com>\r\n";  // Your address
$headers .= "Cc: EXAMPLE@example.com\r\n";  // Send CC
$headers .= "Bcc: BCC-EXAMPLE@example.com\r\n";  // SEND BCC

/* and now mail it */

mail($to, $subject, $message, $headers);
?>


The code in previous example is perfect, but the one above can be used to improve the email exprence
Go to the top of the page
 
+Quote Post
FaLgoR
post Jan 4 2005, 06:30 PM
Post #3


Super Member
*********

Group: Members
Posts: 217
Joined: 2-January 05
Member No.: 3,084



Yes, this topic is only an example of how to do an contact form, I did not put any other advanced things. Thank you for your help! :P
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Getting List Of Directories And Files Using Php(6)
  2. Form To Php Mail. Attachment(14)
  3. How To Use A Link To Call Function In Php?(8)
  4. Include File.php?id=something(13)
  5. How To Enable Mail() Function In Php(1)
  6. Question About The Mail() Function(2)
  7. Help With Mail And Attachments(4)
  8. Bulk Mail(5)
  9. Regexp Function Preg_match_all()(0)
  10. Wappymail_v1.50(15)
  11. Want To Send Mail But Smtp Disabled, Help Me!(7)
  12. Explode Function Help(1)
  13. How Good Is This Data Cleaning Function?(2)
  14. The Extract() Function(6)
  15. Error With Joomla Template(1)
  1. [php] Header Function(2)
  2. [php](simple) Using Functions To Combine Values In A Form(2)
  3. Mail() Clone(5)
  4. The Best Zip Function(1)
  5. Php Explode Function Help(4)
  6. How To Check If Fsockopen Function Is Enabled?(2)
  7. Prequirement For Mail()(1)
  8. Arrays Outside A Function(3)
  9. Php Functions To Send Mail(9)
  10. Requirements For Mail()(2)
  11. Endif function?(6)
  12. PHP Function To Add Previous and Next Page Feature(5)
  13. A Question About Php Mail(1)


 



- Lo-Fi Version Time is now: 7th October 2008 - 01:40 AM