Monday 23 February 2015

Mail Scripting in PHP



Mail Scripting :

It is  common requirement to have a submit form on almost website.

In this we will create a PHP script that will send an email when a web form is submitted.
There are two parts for the web form:
 

  1. The HTML code for the form. The html standard form is as bellow.
  2. The PHP script for handling the form submission. The script receives the form submission     and sends an email.   

     
    HTML code for the email form:

    <form method="post" name="myemailfrm" action="form_to_email.php">

    Enter Name: <input type="text" name="name">

    Enter Email Address:<input type="text" name="email">

    Enter Message: <textarea name="message"></textarea>

    <input type="submit" value="Send Form">
    </form>



    • The form contains the following fields:
               name, email and message.
    • name and email are single  line text input fields where as message is a text area field.
    • On clicking the submit , the form will be submitted to “form_to_email.php”. 
              This form is submitted through the POST Method.
     


    Accessing the form submission data in the PHP script:

    Once your website visitor has submitted the form, the browser sends the form submission data to the script mentioned in the ‘action’ attribute of the form.

    Since we have the form submission method mentioned as POST in the form (method=’post’) we can access the form submission data through the $_POST[] in the PHP script.

    • The following code gets the values submitted for the fields: name, email and message.

    <?php
      $name = $_POST['name'];
      $visitor_email = $_POST['email'];
      $message = $_POST['message'];
    ?>


    Composing the Email:

    Now, we can use the above PHP variables to compose an email Here is the code:

    <?php
        $email_from = 'yourname@yourwebsite.com';

        $email_subject = "Form_Submit";

        $email_body = "You have received a new message from the user $name.\n".
                                "Here is the message:\n $message".
    ?>
     

    • The ‘From’ address, the subject and the body of the email is composed in the code above. Note the way the body of the message is composed using the variables.


    Sending the email:



    • The PHP function to send email is mail().
    • mail(to,subject,message,headers)


    • The headers parameter is to provide additional mail parameters ( like the from address, CC, BCC etc)
     

    Here is the code to send the email:

    <?php

      $to = "yourname@yourwebsite.com";

      $headers = "From: $email_from \r\n";

      $headers .= "Reply-To: $visitor_email \r\n";

      mail($to,$email_subject,$email_body,$headers);

     ?>
     

     
    Sending the email to more than one recipients:


    If you want to send the email to more than one recipients, then you just need to add these in the “$to” variable.

    <?php
      $to = "name1@website-name.com, name2@website-name.com,name3@website-name.com";

      mail($to,$email_subject,$email_body,$headers);
    ?>


    Example:

    <?php
    $to = "name1@website-name.com, name2@website-name.com,name3@website-name.com";

    $headers = "From: $email_from \r\n";

    $headers .= "Reply-To: $visitor_email \r\n";

    $headers .= "Cc: someone@domain.com \r\n";

    $headers .= "Bcc: someoneelse@domain.com \r\n";

    mail($to,$email_subject,$email_body,$headers);
    ?>














    Reference: Html-form-guid.com
         

    Sunday 28 December 2014

    Some Important Questions of MIS



    • What do you mean by an organization ? How can you classify them at macro level?
    • Explain the basic principle that need to be considered during designing an organization structure.
    • What do you mean by the term Organization Structure ? Compare Horizontal and Vertical type of Organization Structure.
    • With the help of suitable diagram describe the roles of management at various levels.
    • What is the important of requirement analysis ? Explain the tools and methods for requirement analysis.
    • Explain the various functions of management.
    • What is TPS? How is it used in sales and marketing management?
    • What is Knowledge Management? What is the importance of knowledge management in an organization.
    • What is DSS? Also, explain the different components of DSS and classification of DSS.
    • Explain the working of Fuzzy logic and Fuzzy expert systems.
    • What are the expert systems? Illustrate the concept with an example.
    • Explain working of TPS in an organization.
    • Briefly describe all six types of information system.
    • Write short note on Total Cost of ownership.
    • Write a short note on IRR and DCF.
    • How are culture and information systems related?
    • Write short note on Portfolio Management.
    • Write short note of NPV.
    • What is the role of IT in Risk Management of any organization?
    • What is the Portfolio Management? Explain the steps for implementation of portfolio management.
    • What is supply chain? What is up stream and down stream portion?
    • Write short note on Distinctive ways of ERP implementation.
    • What do you mean by SCM? How the concept of SCM differs from ERP?
    • Write short note on CRM.
    • Explain stages of business analytic s and its various types.
    • Explain the difference between Knowledge and Intelligence.
    • Write short note on OLAP.
    • Define genetic algorithms. Explain the advantages and disadvantages of genetic algorithm in business organizations.
    • Write short note on Data Mining.
    • Explain the role of Business intelligence reports in the information system of an organization.
    • What do you mean by knowledge? Compare and contrast Inferential Vs. Factual knowledge.
    • Write short note on Cyber Crime and its type.
    • Write short notes on RTI Act.
    • Write short note on Business Ethics.
    • Write short note on Types of computer crimes.
    • What are the security threats to information system? Explain.
    • Explain some of the security threats to information systems. Also, write solution of these threats. 












    Reference : IGNOU old Papers.