0

I want this code form is actually work and emailing to admin email of blog. I don't have any idea, to make it real.

<form id="partner" action="" method="post" name="contact-form" enctype="text/plain">
    <h3><span>Daftar Partner</span></h3>
    <label>Name Fansub</label>
    <input type="text" name="nama" placeholder="A3Substream" size="20" />
    <label>Website</label>
    <input type="text" name="alamat" placeholder="http://www.a3substream.net" size="20" />
    <label>Link Banner</label>
    <input type="text" name="mail" placeholder="imagelink" size="20" />
    <button id="ContactForm1_contact-form-submit" type="button">Kirim sekarang!</button>
    <button type="reset" value="Batal">Batal</button>
    <div style="max-width: 222px; text-align: center; width: 100%;">
        <div id="ContactForm1_contact-form-error-message">
        </div>
        <div id="ContactForm1_contact-form-success-message">
        </div>
    </div>
</form>
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
  • Possible duplicate of [Send email with PHP from html form on submit with the same script](http://stackoverflow.com/questions/18379238/send-email-with-php-from-html-form-on-submit-with-the-same-script) – showdev Aug 24 '16 at 16:35
  • Also relevant: [How to create an email form that can send email using html](http://stackoverflow.com/questions/8239782/how-to-create-an-email-form-that-can-send-email-using-html) – showdev Aug 24 '16 at 16:36
  • Alot of tutorials out there, first try them, and when you try one and it does not work, then come and some one will help you from there, after you have tried something. – Omari Victor Omosa Aug 24 '16 at 16:57

1 Answers1

0

It will depend with the server you are working with. Some will accept the simple example provided below. Adding the PHP code for sending the mail

<?php

if (isset($_POST['nama']) && ((isset($_POST['nama']) != ""))) {
$nameofsender = $_POST['nama'];
$to = 'myemail@gmail.com';
$message = $_POST['mail'];
$body ='<html>
<body>
<div class="content">
<p style="text-align:center;">'.$message.'<p><br />
</div>
</body>';

$headers='MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html;charset=iso-8859-1' . "\r\n";
$headers .= 'From: MY BLOG <info@myblog.com>' . "\r\n";
$subject = "$nameofsender - Message from blog";
//mail function
$mail = mail($to, $subject, $body, $headers);

if(!$mail) {   
     echo "Error sending email";   
} 
else {
    echo "Your email was sent successfully.";
}
}
?>

YOUR FORM......

Some servers are strict more so windows based servers and may require more detail before sending mails like the code below

/*email starts*/    
require_once "http://www.yourblog.com/Mail.php";

$from = "Your blog <info@yourblog.com>";
$email = 'myemail@gmail.com';
$to = "<$email>";
$subject = "$nameofsender - Message from blog";
$message = $_POST['mail'];
$body = $body ='<html>
<body>
<div class="content">
<p style="text-align:center;">'.$message.'<p><br />
</div>
</body>';

$host = "mail.yourwebsite.com";
$username = "info@yourwebsite.com";
$password = "passwordtousernameabove";

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);


$smtp = Mail::factory('smtp',
    array ('host' => $host,
    'port' => 25,
    'auth' => true,

    'username' => $username,
    'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
} else {
  echo("<p>Message successfully sent!</p>");
}
YOUR FORM....

For better understanding google for tutorials on this topic as it is a shot but wide interesting topic. Regards

Omari Victor Omosa
  • 2,814
  • 2
  • 24
  • 46
  • I'm sorry i'm not including my blog information, but i used blogger and you know that blogger don't support php, so if you pleasure please give me another way like javascript or another that support in blogger. – Cleosetric Vlyers Aug 25 '16 at 08:56
  • it has to support php. saving your files with an extension of. php . it is not about blogger. its about server. but this is the best solution i could give. – Omari Victor Omosa Aug 25 '16 at 09:00
  • so i cant just add function from blogger using id or javascript, to be honest using php is really complicated, but really thank you. – Cleosetric Vlyers Aug 25 '16 at 09:22
  • if your file is saved as e.g. index.html. change it to index.php simple. then add the code above just on top of your
    – Omari Victor Omosa Aug 25 '16 at 09:27