Start learning with our library of video tutorials taught by experts. Get started

Dynamic Dreamweaver Websites: Creating and Validating Forms
Watching:

Commenting code


From:

Dynamic Dreamweaver Websites: Creating and Validating Forms

with Candyce Mairs

Video: Commenting code

I want to talk about commenting your code when you begin working in PHP, or any type of programming. It's very important to comment your code in order for you to understand two, three, six months from now what you were doing within the pages. As you work in static pages, it's not too important particularly in HTML. So a lot of people moving into dynamic web sites using server side languages, tend not to remember to comment.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
Dynamic Dreamweaver Websites: Creating and Validating Forms
3h 34m Intermediate May 19, 2011

Viewers: in countries Watching now:

Forms perform an essential function in modern websites, making it possible to gather information from users and validate that information. In this course, Adobe Certified Expert Candyce Mairs shows how to create forms to email user information and validate user data using various methods of form validation. These validation methods include client-side, server-side, and custom validation; CAPTCHA images; and Spry validation fields. You'll also see how to set up a PHP testing environment and preview PHP pages in Dreamweaver. Along the way you'll build your skills in areas like using admin consoles, commenting code, working with variables and includes, and much more.

Topics include:
  • Installing XAMPP on a Windows system
  • Installing MAMP on a Mac system
  • Using admin consoles
  • Creating PHP pages
  • Commenting code
  • Working with web forms
  • Adding custom validation
  • Using redirects
  • Dealing with email issues
Subjects:
Developer Web Web Design Web Development video2brain
Software:
Dreamweaver
Author:
Candyce Mairs

Commenting code

I want to talk about commenting your code when you begin working in PHP, or any type of programming. It's very important to comment your code in order for you to understand two, three, six months from now what you were doing within the pages. As you work in static pages, it's not too important particularly in HTML. So a lot of people moving into dynamic web sites using server side languages, tend not to remember to comment.

And it's a very important part of the process to save you time long term. So what we want to do is add a comment within our PHP code block. Now let me show you a couple of things with regards to comments. So I'm going to type out under the body tag, this code creates variables, and prints them to the page. Now this is such simple code.

Prints them to the page. Let me focus on what I'm doing here. So I'm going to make this comment an HTML comment, and DreamWeaver does have a commenting area... This little piece here, where it looks like it's somebody talking is how you apply a comment. This is how you remove a comment. So, if I want to make this an HTML comment, I use the first one. So, I'll go ahead and do that. You can see HTML comments turn a light gray.

Now, what if I put that same information inside the php code block. So this is the opening part of the code block, this is the closing portion, just like HTML has an opening and closing tag. So I'll paste that in. Whoops, looks like I didn't copy, just one second. I'll put a copy in here, and paste. There we go. Now notice what happens in dream weaver, it's telling me there's an error here.

Php can't understand this line of code. First of all php lines have to have a semi colon but in order to make this a comment I could do a couple of things. One is since I have this php tab up in my inset bar. I can go ahead, and if I highlight this piece, notice it say's comment. So I can comment in that manner. Now the html comment is gray, the php comment is orange, and notice I no longer have syntax errors..

So that's one type of comment. Now I'll select that and click the red X. And that'll remove the comment. Now, let me show you the other type of comment you can use in PHP. There's actually a couple of others. But I'll just show you one other. I can also apply that type of comment here. Or I can use this type of comment. And notice that turns orange. And I have no syntax errors. So that's one way to type out a comment.

Let me leave both of these comments in here. Let's save the page,and put it out in the browser. Now you can see your page doesn't look any different than it did before the comment. But what happens to our comments within the source code? This is my HTML comment that's showing in the source code. Any PHP within a PHP code block, the entire code block is stripped out and the page is sent back to the browser via the web server without any PHP coding in it.

So any of your PHP comments are stripped out. So just keep in mind any HTML, Javascript or CSS comments are visible to anybody out on the web. But any server side language code, including comments is stripped out and that all occurs before the page is sent to the user via the web server and the browser. So, that's how you create PHP comments. Now within this course and even within my classroom enviornment we don't always take time to sit and type out the comments.

And for people new to a server side language, you can get in the habit of not doing that, and I would strongly recommend you do that immediately. Think about putting a comment in each PHP code block. I also, if I modify something while I'm working on a website, I put a comment about why I modified it. The date I modified it, and my initials. Sometimes, I even put, depending upon the client, who approved the modification, so it gives you a way to store information within your pages that won't be visible to anybody but you, but that is commenting.

Please assume that we would be putting comments in every code block even though I don't take the time to do it throughout this course. So that's the importance of commenting code. If you can get in the habit of doing it right away, you will be much better off in the long term. So PHP comments come in a variety of ways. You can do it up in here in the insert bar, or you can use this comment. This is known as the Coding toolbar. So those are PHP comments.

There are currently no FAQs about Dynamic Dreamweaver Websites: Creating and Validating Forms.

Share a link to this course
Please wait... Please wait...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Dynamic Dreamweaver Websites: Creating and Validating Forms.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked