We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,473 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Contact Form Submission

I have a contact form. I need to deliver it to bala_palash@yahoo.com when anyone clicked on send. Please anyone help me...

My form is

<form name="contact_form" method="post" action="">
                  <table width="400" border="0">
                    <tr>
                      <td><label>Your Name (Required)<br>
                          <input class="name" name="name" type="text" id="name" value="" size="50">
                        </label></td>
                      </tr>
                    <tr>
                      <td><label>Your Email (Required)<br>
                          <input class="email" name="email" type="text" id="email" value="" size="50">
                        </label></td>
                      </tr>
                    <tr>
                      <td><label>Subject<br>
                          <input class="subject" name="subject" type="text" id="subject" value="" size="50">
                        </label></td>
                      </tr>
                    <tr>
                      <td><label>Your Message
                        <textarea class="message" name="message" cols="50" rows="10" id="message">
7
Contributors
8
Replies
2 Weeks
Discussion Span
2 Months Ago
Last Updated
49
Views
pol.bala
Newbie Poster
6 posts since Feb 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

You must will implement php script, which be get data and send on mail.
For send mail you may use function mail http://www.php.net/manual/en/function.mail.php or PHPMailer http://phpmailer.worxware.com/index.php?pg=tutorial.

radow
Junior Poster in Training
73 posts since Oct 2012
Reputation Points: 7
Solved Threads: 18
Skill Endorsements: 0

I've written a code for you.

<?php
If($_POST)
{
// Contact subject

$name=$_POST['name'];

$subject =$_POST['subject'];
$detail = $_POST['message'];
$mail_from=$name=$_POST['email'];
// Details
$message=" From: $name \n Subject : $subject \n Email : $mail_from \n Message : $detail ";


// Mail of sender
$mail_from=$name=$_POST['email'];

// From
$header="from: $name <$mail_from>";


// Enter your email address
$to ='bala_palash@yahoo.com';

$send_contact=mail($to,$subject,$message,$header);


// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}}
?>
<form name="form1" method="post" action="">
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <table width="500" border="0" cellspacing="0">
    <tr>
      <td>Your Name</td>
      <td><label>
        <input type="text" name="name" id="name">
      </label></td>
    </tr>
    <tr>
      <td>Your Email</td>
      <td><label>
        <input type="text" name="email" id="email">
      </label></td>
    </tr>
    <tr>
      <td>Subject</td>
      <td><label>
        <input type="text" name="subject" id="subject">
      </label></td>
    </tr>
    <tr>
      <td>Message</td>
      <td><label>
        <input type="text" name="message" id="message">
      </label></td>
    </tr>
  </table>
  <p>
    <label>
    <input type="submit" name="button" id="button" value="Submit">
    </label>
  </p>
</form>
Shalomd
Light Poster
29 posts since Feb 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

See first of all your server must have SMTP support otherwise you can't send mail.
First checks that.If it supports SMTP then check mail method of php.
Click Here.
Syntax is :
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

So in your case it would be somethink like this:-

<?php
If($_POST)
{
// Contact subject
$name=$_POST['name'];
$subject =$_POST['subject'];
$detail = $_POST['message'];
$mail_from=$name=$_POST['email'];
// Details
$message= $detail;//you can format message  as the header content type is html.So you can add HTML tags
// Mail of sender
$mail_from=$name=$_POST['email'];
// From
$headers = "From: ". $_POST['to'] . "\r\n" .
            "Content-type: text/html; charset=UTF-8" . "\r\n".
// Enter your email address
$to ='bala_palash@yahoo.com';
$send_contact=mail($to,$subject,$message,$headers);
// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}}
?>
<form name="form1" method="post" action="">
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <table width="500" border="0" cellspacing="0">
    <tr>
      <td>Your Name</td>
      <td><label>
        <input type="text" name="name" id="name">
      </label></td>
    </tr>
    <tr>
      <td>Your Email</td>
      <td><label>
        <input type="text" name="email" id="email">
      </label></td>
    </tr>
    <tr>
      <td>Subject</td>
      <td><label>
        <input type="text" name="subject" id="subject">
      </label></td>
    </tr>
    <tr>
      <td>Message</td>
      <td><label>
        <input type="text" name="message" id="message">
      </label></td>
    </tr>
  </table>
  <p>
    <label>
    <input type="submit" name="button" id="button" value="Submit">
    </label>
  </p>
</form>
IIM
Practically a Master Poster
638 posts since Jun 2011
Reputation Points: 127
Solved Threads: 136
Skill Endorsements: 7

this code snippet is written with dirty values? why write code for semeone and allow dirty values in one of the most vulnerable of php functions?
sanitize the post values or suffer the consequences.

moneeshot
Light Poster
33 posts since Nov 2011
Reputation Points: 10
Solved Threads: 5
Skill Endorsements: 0

this code snippet is written with dirty values? why write code for semeone and allow dirty values in one of the most vulnerable of php functions?
sanitize the post values or suffer the consequences.

this code snippet is written with dirty values? why write code for semeone and allow dirty values in one of the most vulnerable of php functions?
sanitize the post values or suffer the consequences.

This is very true.

Although the majority of code snippets you will get will require you to add code sanitizing.

Squidge
Posting Pro in Training
413 posts since Dec 2009
Reputation Points: 111
Solved Threads: 62
Skill Endorsements: 5

Use PHPMailer to send the email. It works for me. Here is the link;

https://code.google.com/a/apache-extras.org/p/phpmailer/

Webville312
Posting Whiz in Training
245 posts since Feb 2012
Reputation Points: 10
Solved Threads: 24
Skill Endorsements: 0

Thanks a lot

pol.bala
Newbie Poster
6 posts since Feb 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Or, if it helps, then here is a code I use;

<?php
require("class.phpmailer.php");
    $email = $_POST['email'];
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->Host = "localhost";
    $mail->From = "source_email@domain.com";
    $mail->FromName  =  "Your_name";
    $mail->AddAddress("recipient_1@domain.com");
    //$mail->AddAddress("recipient_2@domain.com");
    $msg = "This is the sample message";
    $subject = "My first Email";
    $mail->SMTPAuth = "true";
    $mail->Username = "your_gmail_account@gmail.com";
    $mail->Password =  "your_gmail_password";
    $mail->Port  =  "25";

    $mail->Subject = $subject;
    $mail->Body = $msg;
    $mail->WordWrap = 50;

    if(!$mail->Send())
    {
        echo 'Message was not sent.';
        echo 'Mailer error: ' . $mail->ErrorInfo;
    }
    else
    {
        echo 'Mail has been sent.';
    }

?>

This will only work on condition that you have uncompressed phpMailer and this file is within the same folder as the extracted phpMailer.

Webville312
Posting Whiz in Training
245 posts since Feb 2012
Reputation Points: 10
Solved Threads: 24
Skill Endorsements: 0

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0942 seconds using 2.72MB