Your SlideShare is downloading. ×
10 Email Etc
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

10 Email Etc

943
views

Published on

Day 10 Email sending with php

Day 10 Email sending with php

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
943
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. PHP Day 10 Geshan Manandhar Developer, Young Innovations Private Limited www.geshanmanandhar.com http://www.php.net http://www.mysql.com
  • 2. Email with PHP
    • <?php
    • $to = 'someone@somemail.com';
    • $subject = 'Test email';
    • $message = &quot;Hello World! This is my first mail.&quot;;
    • //define the headers we want passed. Note that they are separated with
    • $headers = &quot;From: webmaster@example.com Reply-To: webmaster@example.com&quot;;
    • //send the email
    • $mail_sent = mail( $to, $subject, $message, $headers );
    • if($mail_sent){
    • print &quot;Mail sent&quot;;
    • }
    • else {
    • print &quot;Mail failed.&quot;;
    • }
    • ?>
  • 3. Use of Emails
    • Emails are used as an alert system in database focused application.
    • It is sent to notify application user about various activities.
    • Applications like e-card system rely heavily on email.
    • Server configuration, no. or emails allowed etc are also vital in applications that use e-mail.
  • 4. Back to basics
    • Simple program to find a number is odd or even.
    • <?php
    • $number = 4;
    • if($number%2){
    • $odd = 1;
    • }
    • else {
    • $odd = 0;
    • }
    • //contd…
  • 5. Back to basics – C style printf
    • if($odd){
    • printf (&quot;%d is odd.&quot;, $number);
    • }
    • else {
    • printf (&quot;%d is even.&quot;, $number);
    • }
    • ?>
  • 6. Back to the basics - Ternary
    • Ternary operator
    • <?php
    • $number = 4;
    • $odd = ($number%2) ? 1 : 0; //ternary operator
    • // above single line is equivalent to 6 lines of code of previous program
    • if($odd){
    • printf (&quot;%d is odd.&quot;, $number);
    • }
    • else {
    • printf (&quot;%d is even.&quot;, $number);
    • }
    • ?>
  • 7. Better programming mantras
    • Use Ternary Operator to save time and LOC- Lines of code.
    • Utilize array and array related functions to the maximum.
    • Implement DRY in coding.
      • Instead of creating multiple functions just add a parameter to existing function to do the job.
    • Use debugging techniques
      • Use functions like print, echo, print_r, var_dump at relevant breakpoints to check the value of the variable.
  • 8. If you have no web template
    • If you layout looks too dull and you can’t design or don’t want to design.
    • Then try out these websites to get free web templates:
      • http://www.opendesigns.org/
      • http://www.freecsstemplates.org/
      • http://www.freewebsitetemplates.com/
      • More at http://delicious.com/geshan/WebTemplates
  • 9. Simply theme your code
    • Download the template you want.
    • See the <div> structure.
    • Change the static content to the dynamic (PHP) content you want to replace with.
    • Check your output.
    • Hit and trail works if you are not good at designing.
  • 10. A themed users table
  • 11. Questions
  • 12. To do
    • Inject your code to a layout from above mentioned website.
    • Make your login system fully functional.
    • Review you code – implement the mantras.
    • Assign message to a variable $message as per login information supplied by user, using the ternary operator.
    • Upload your files to your newly created sub-domain at 000webhost, test them.