Page 282 - Computer Software Application TP - Volume 1
P. 282

COMPUTER SOFTWARE APPLICATION - CITS



                 ?>

                       </body>
                                </html>
              3  Save the program in C:\Apache24\htdocs in a folder as querystring2.php extension
              4  Run the Apache services from windows services
              5  Open the browser and type the following address

                                     http://localhost/foldername/
              6  Click the php file to run  and verify the output
















           TASK 11: Sending E-mail using PHP
           1  Open the text editor

           2  Write the following codes
              Note: This code needs a functioning mail server configured in the PHP environment to send emails.

                              <html>
                              <body>
                            <?php
                   $to = “recipient@example.com”;//provide the  actual email address

                             $subject = “My Email Subject”;
                             $message = “This is the email body.”;


                             // Optional headers
                             $headers = “From: sender@example.com” . “\r\n” .
                                                      “Reply-To: reply@example.com”;



                            // Send the email
                            if (mail($to, $subject, $message, $headers))
                            {

                                    echo “Email sent successfully!”;
                            }
                            else
                            {
                                    echo “Error sending email.”;

                            }


                                                           267
 CITS : IT & ITES - Computer Software Application - Exercise 54   CITS : IT & ITES - Computer Software Application - Exercise 54
   277   278   279   280   281   282   283   284   285   286   287