Difference between revisions of "PHP-and-MySQL/C4/Sending-Email-Part-1/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
Line 7: Line 7:
 
|-
 
|-
 
|00:12
 
|00:12
|How do you send them an email confirming that they have registered.  I will do that partly by creating a script - a "Send me an email" script.  
+
|How do you send them an email confirming that they have registered.  I will do that partly by creating a '''script''' - a "Send me an email" script.  
 
|-
 
|-
 
|00:24
 
|00:24
|This will be in an HTML form in which you can write a subject and a message and send to a specified address.  
+
|This will be in an '''HTML form''' in which you can write a subject and a message and send to a specified address.  
 
|-
 
|-
 
|00:34
 
|00:34
|So, we will create an address variable.  
+
|So, we will create an '''$address''' variable.  
 
|-
 
|-
 
|00:39
 
|00:39
Line 19: Line 19:
 
|-
 
|-
 
|00:48
 
|00:48
|You can see when I open up my current "hotmail" page and click on "Inbox", there are no emails here from me.
+
|You can see when I open up my current "hotmail" '''page''' and click on "Inbox", there are no emails here, from me.
 
|-
 
|-
 
|00:55
 
|00:55
Line 25: Line 25:
 
|-
 
|-
 
|01:05
 
|01:05
|So This is the address in my address variable. I will rename the variable as "to" instead.
+
|So, this is the address in my '''address''' variable. I will rename the variable as '''$to''' instead.
 
|-
 
|-
 
|01:13
 
|01:13
|We will use the mail function to send this out.
+
|We will use the '''mail''' function to send this out.
 
|-
 
|-
 
|01:17
 
|01:17
|We will have the from and subject in here.
+
|We will have the '''from''' and '''subject''' in here.
 
|-
 
|-
 
|01:21
 
|01:21
|We will have a standard subject which says "Email from PHPAcademy".
+
|We will have a standard '''$subject''' which says "Email from PHPAcademy".
 
|-
 
|-
 
|01:32
 
|01:32
|Next we need an HTML form that will submitI will create a self submission one.  
+
|Next, we need an '''HTML form''' that will submit and I will create a self submission one.  
 
|-
 
|-
 
|01:39
 
|01:39
|So lets put some html code here. I will have a form here which will submit to this page with "send me an email dot php".
+
|So, let's put some '''html code''' here. I will have a '''form''' here which will submit to this page with "send me an email dot php".
 
|-
 
|-
 
|01:54
 
|01:54
|The method is going to be POST.  
+
|The '''method''' is going to be '''POST'''.  
 
|-
 
|-
 
|01:59
 
|01:59
|We will end our form here.
+
|We will end our '''form''' here.
 
|-
 
|-
 
|02:02
 
|02:02
Line 52: Line 52:
 
|-
 
|-
 
|02:10
 
|02:10
|Obviously you can take this into account. When creating a form, you could say you want to send to this particular address.   
+
|Obviously you can take this into account. When creating a '''form''', you could say you want to send to this particular address.   
 
|-
 
|-
 
|02:18
 
|02:18
Line 64: Line 64:
 
|-
 
|-
 
|02:34
 
|02:34
|So you have type "text" whose name is "name"
+
|So, you have '''type''' "text" whose '''name''' is "name".
 
|-
 
|-
 
|02:39
 
|02:39
Line 73: Line 73:
 
|-
 
|-
 
|02:49
 
|02:49
|So I will type "textarea" and end it like that.
+
|So, I will type "textarea" and end it like that.
 
|-
 
|-
 
|02:53
 
|02:53
|Then we will name it as "message".  
+
|Then we will '''name''' it as "message".  
 
|-
 
|-
 
|02:59
 
|02:59
|We put a paragraph beginning and a paragraph ending here  
+
|We put a paragraph beginning and a paragraph ending here.
 
|-
 
|-
 
|03:04
 
|03:04
|And down here we will create a submit button whose value equals "Send"
+
|And down here we will create a submit button whose '''value''' equals "Send"
  
 
|-
 
|-
Line 89: Line 89:
 
|-
 
|-
 
|03:17
 
|03:17
|So if you come to our page and choose this page here  
+
|So, if you come to our page and choose this page here,
 
|-
 
|-
 
|03:21
 
|03:21
Line 95: Line 95:
 
|-
 
|-
 
|03:25
 
|03:25
|So let me just put "Name:" in here and "Message:" in here.  
+
|So, let me just put "Name:" in here and "Message:" in here.  
 
|-
 
|-
 
|03:31
 
|03:31
Line 104: Line 104:
 
|-
 
|-
 
|03:44
 
|03:44
|Okay so first of all inside our php code we need to check whether the submit button has been pressed.
+
|Okay, so first of all, inside our '''php code''' we need to check whether the submit button has been pressed.
 
|-
 
|-
 
|03:53
 
|03:53
|For that we have our "if" statement here in parenthesis and our curly brackets for our block if the condition is TRUE.  
+
|For that we have our '''if''' statement here in parenthesis and our curly brackets for our block, if the '''condition''' is TRUE.  
 
|-
 
|-
 
|04:01
 
|04:01
|The condition will be inside these parenthesis.  
+
|The '''condition''' will be inside these parenthesis.  
 
|-
 
|-
 
|04:05
 
|04:05
|The condition will be the post variable of the "submit" button.
+
|The condition will be the '''POST''' variable of the "submit" button.
 
|-
 
|-
 
|04:15
 
|04:15
Line 119: Line 119:
 
|-
 
|-
 
|04:19
 
|04:19
|So long as the submit button has been pressed, this will contain a value and that value is "Send me this".  
+
|So long as the "submit" button has been pressed, this will contain a '''value''' and that value is "Send me this".  
 
|-
 
|-
 
|04:30
 
|04:30
|That would just mean that the form has been submitted because the button has been pressed.
+
|That would just mean that the '''form''' has been submitted because the button has been pressed.
 
|-
 
|-
 
|04:37
 
|04:37
|So inside here the first thing we need to do is get the data from the form.  
+
|So, inside here the first thing we need to do is get the data from the '''form'''.  
 
|-
 
|-
 
|04:44
 
|04:44
|And that is the name of the person sending the email by submitting the form.
+
|And that is the name of the person sending the email by submitting the '''form'''.
 
|-
 
|-
 
|04:49
 
|04:49
|And their name is contained within this form here - sorry this field here called "name".
+
|And their name is contained within this '''form''' here - sorry this field here called "name".
 
|-
 
|-
 
|04:56
 
|04:56
|Also we have the message so we can easily duplicate this variable structure and say message in there.
+
|Also we have the '''$message''' so we can easily duplicate this variable structure and say 'message' in there.
 
|-
 
|-
 
|05:08
 
|05:08
|To test this out I'll say echo name.  
+
|To test this out, I'll say '''echo $name'''.  
 
|-
 
|-
 
|05:12
 
|05:12
|And I'll concatenate the message into that.  
+
|And I'll concatenate the '''$message''' into that.  
 
|-
 
|-
 
|05:17
 
|05:17
|Lets just test this out.  Here I'll type "Alex".  
+
|Let's just test this out.  Here I'll type "Alex".  
 
|-
 
|-
 
|05:21
 
|05:21
Line 152: Line 152:
 
|-
 
|-
 
|05:28
 
|05:28
|Ok so, we know that the form data has been submitted correctly.
+
|Ok so, we know that the '''form''' data has been submitted correctly.
 
|-
 
|-
 
|05:33
 
|05:33
|In the next part of this video we will learn how to validate this and eventually send this mail to the user specified in this email-id here.  
+
|In the next part of this video, we will learn how to validate this and eventually send this email to the user specified in this email-id here.  
 
|-
 
|-
 
|05:42
 
|05:42
|So join me in the next part. Bye for now.
+
|So, join me in the next part. Bye for now.
 
|-
 
|-
 
|05:45
 
|05:45
|This is Evan Varkey dubbing for the Spoken Tutorial Project.
+
|This is Evan Varkey, dubbing for the Spoken Tutorial Project.

Latest revision as of 18:18, 5 June 2015

Time Narration
00:00 Hello and welcome. Today I will teach you how to create an email script particularly when you are registering a user onto a website.
00:12 How do you send them an email confirming that they have registered. I will do that partly by creating a script - a "Send me an email" script.
00:24 This will be in an HTML form in which you can write a subject and a message and send to a specified address.
00:34 So, we will create an $address variable.
00:39 I will type my "hotmail" address here.
00:48 You can see when I open up my current "hotmail" page and click on "Inbox", there are no emails here, from me.
00:55 There are no new emails at the moment.
01:05 So, this is the address in my address variable. I will rename the variable as $to instead.
01:13 We will use the mail function to send this out.
01:17 We will have the from and subject in here.
01:21 We will have a standard $subject which says "Email from PHPAcademy".
01:32 Next, we need an HTML form that will submit and I will create a self submission one.
01:39 So, let's put some html code here. I will have a form here which will submit to this page with "send me an email dot php".
01:54 The method is going to be POST.
01:59 We will end our form here.
02:02 The user can type in whatever they want to send to the email address that is specified here.
02:10 Obviously you can take this into account. When creating a form, you could say you want to send to this particular address.
02:18 This one will just be "send me an email" script - the email that you want to include in one of your website.
02:27 Now we will have a "text" input.
02:31 This will be the name of the person sending me the email.
02:34 So, you have type "text" whose name is "name".
02:39 We'll have "max length" equal 20 for now.
02:45 Underneath this we will create a text area.
02:49 So, I will type "textarea" and end it like that.
02:53 Then we will name it as "message".
02:59 We put a paragraph beginning and a paragraph ending here.
03:04 And down here we will create a submit button whose value equals "Send"
03:14 Or.... "Send me this", okay?
03:17 So, if you come to our page and choose this page here,
03:21 this is the space for the name and this is the space for the message.
03:25 So, let me just put "Name:" in here and "Message:" in here.
03:31 And this will look much better now. We have our name box and our message box.
03:38 And when we click this button, the email will send.
03:44 Okay, so first of all, inside our php code we need to check whether the submit button has been pressed.
03:53 For that we have our if statement here in parenthesis and our curly brackets for our block, if the condition is TRUE.
04:01 The condition will be inside these parenthesis.
04:05 The condition will be the POST variable of the "submit" button.
04:15 As long as the submit button has a value.... a spelling mistake....
04:19 So long as the "submit" button has been pressed, this will contain a value and that value is "Send me this".
04:30 That would just mean that the form has been submitted because the button has been pressed.
04:37 So, inside here the first thing we need to do is get the data from the form.
04:44 And that is the name of the person sending the email by submitting the form.
04:49 And their name is contained within this form here - sorry this field here called "name".
04:56 Also we have the $message so we can easily duplicate this variable structure and say 'message' in there.
05:08 To test this out, I'll say echo $name.
05:12 And I'll concatenate the $message into that.
05:17 Let's just test this out. Here I'll type "Alex".
05:21 And here I will type "Hi there!"
05:23 Click "Send me this" and we get "Alex" and "Hi there!" up there.
05:28 Ok so, we know that the form data has been submitted correctly.
05:33 In the next part of this video, we will learn how to validate this and eventually send this email to the user specified in this email-id here.
05:42 So, join me in the next part. Bye for now.
05:45 This is Evan Varkey, dubbing for the Spoken Tutorial Project.

Contributors and Content Editors

Gyan, Pratik kamble, Sandhya.np14