How to activate a form

by 8 replies
9
Hi Warriors,

Can someone please explain to me how visitors can use my contact form on my website, through my website and not using their e-mail account?

I really appreciate any help.

Best,
#programming #activate #form
    • [ 1 ] Thanks
    • [1] reply
    • Html form in file form.html:

      <form action="send.php" method="post">
      <input type="text" name="name" placeholder="First name" />
      <input type="text" name="phone" placeholder="Phone" />
      <input type="text" name="email" placeholder="E-mail" />
      <input type="submit" value="Send" />
      </form>

      php script in file send.php:

      <?php
      $admin_email='';

      $subject='New message';
      if(isset($_POST['phone']) AND !empty($admin_email)){
      $firstname='';
      $phone='';
      $email='';
      $message=$firstname.$phone.$email;
      $site_email= 'info@'.$_SERVER['SERVER_NAME'];
      if($_POST['name'])$firstname='Name: '.$_POST['name'].$PHP_EOL;
      if($_POST['phone'])$phone='Phone: '.$_POST['phone'].$PHP_EOL;
      if($_POST['email'])$email='E-mail: '.$_POST['email'].$PHP_EOL;

      $header = 'MIME-Version: 1.0' . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'From: '.$site_email.' <' . $site_email . ">\n";
      mail(trim($admin_email), '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header);
      echo 'Thanks!';
      }

      ?>

      sample: http://wordpress-expert.net/demo/php...orm/script.zip
      • [2] replies
  • If your server does not support the mail php
    then you can use php emailer. create a gmail account and use it as the sender
    and you put yourself as the receiver

    https://github.com/PHPMailer/PHPMailer

    its very easy to use. if you know php
    • [1] reply
    • It's easy to find a php code snippet that will process your form input, however, there are some security issues you should consider before you try to deploy any back-end code.
  • Banned
    [DELETED]
  • PM me with details. I'm doing a week of free programming help to Warriors
  • Hey in order to the form to work you need to connect it to your website using php.
    The way it works once the user click on the form button and get activated by the php file and send the email to the user or to yourself.

Next Topics on Trending Feed