Home
Username:
Password:
Macromedia ColdFusion Tutorials

The Cork Board Continued / Corkboard_action.cfm




Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com’s entire library of video tutorials.


Learn More

Subtitles of the Movie

You will see if I click on modify, if I wanted to change this message's village from Millers Falls which is what it's started of as to all of Montague, you click on modify and it comes back, same message with all of Montague. So you know that it actually changed. Let's go take a look at the corkboard_action code. corkboard_action. We come in here and we do the include, in case something breaks, we'll still have the admin menu at the top, and then we set all these things - email, phone, date, time, IP_number and user_agent. If they come in blank, we put in a single space in there, and that's specifically because you know let's say that I wanted to modify this. Well look, the phone is empty. Well now it's a single space. You know if I wanted to edit let's say this message here and make a change, well there is a lot of information missing here, the phone, the email, the IP_number and the user_agent, they are all empty. And see they are not even single spaced, they are totally empty. So if it's empty, I don't want to stick it into Access, totally empty because I just prefer to have at least a single character in there like a space. So we set them all to be a space on the way in and we are not doing it to all of them, because they really cant have a message without a name, they can't have a message without a message, it's not possible to have a message without a village_ID or a corkboard, I mean a subject_ID or a user_ID. Those things are brought it, and from now on, it's not possible to have a message without time or date. But some of these messages are, see, 'please enter in the time'. And that's because of the cfinput and saying that this is a required field, some of these you know might be empty for older messages, so that's why I threw that in there. And then if form.modifythisrecord is defined, which means that we are modifying something here, let's go to the form. Here's our form and then we say input type is hidden, name is modifythisrecord, value is message_ID. So I wanted to pass along with the message_ID was, without it being editable and you know text input or something like that. I mean you would not want to change the message_ID, so this is a hidden piece of information that you pass along. I know it's not incredibly secure, but you are hoping that the people that are coming into this backend here are friendly. So form.modifythisrecord, if it's defined then come in and do all this, else just send them right back to the corkboard, you know. Somehow they got to corkboard_action.cfm and they are trying to, you know do something - or who knows, something went wrong. So we don't know what you are trying to do, just send you right back. And the only things in here are modify and delete. There is no insert, because if you want to add something to the corkboard, go out to the corkboard and do it out there. So we're updating all the stuff that was passed from the form - the subject_ID, the date, the time. Notice that these are in the square brackets because I believe that they are, haven't tested it, one of them for sure, if not both of them are special commands in SQL. Name, email, phone, village_ID, message, user_ID. Notice that subject_ID, user_ID, village_ID are not in quotes - that's because they are numbers. Also approved is a yes/no and is actually equal to 1 or 0. IP_number, user_agent, these are all in quotes and these are passed over. I had to put form. here because apparently Cold Fusion, if you pass it a variable, they could be one or two things - in this case it could even be form.user_agent or cgi.user_agent. It figures that because form.user_agent is empty, in the case where it might be empty, it will take cgi.useragent. So if you were to update any message including this one, if you were to modify this and have nothing in user_agent in here to be a value, then it will assume that you mean cgi.user_agent and it will put your user_agent, your whatever browser and operating system string you know, this information right here, it will stick that in there from your machine. If you didn't put that in. For instance, if I had edited this one and I said modify, because I wanted to change the village or whatever, then suddenly this information here would appear in there. Because user_agent is you know, something that's used by Cold Fusion. So I had to scope it properly. So update_message set these things where message_ID is equal to form.modifythisrecord. And then after we come out of that, we go back to corkboard and the message_ID is equal to this. So we want to go back and edit the same message after we've modified it, just to make sure that everything is ok. And we could actually say add token is no. So you don't get all this extra, well it's not up here now or is it, whatever. Anyway, we won't add all that extra stuff in, alright. With this URL is up here because we just clicked on something down here, we didn't actually modify this. So if form.submit is modify, form.submit, submit is the actual submit button coming from the form, form.submit equals delete, then do this, delete everything from message table where message_ID is equal to that. So that's what happens if we click on the delete button. No we don't do it, Close this particular if-else, meaning if they didn't pass us a modifythisrecord number, then just go back to the corkboard.cfm in here and then we close it out and that's it. Really simple and really quick. You could do the same thing for businesses, you could do the same thing for anything. Just once you make one, you come in, just copy all the code change the form around a little bit. A lot of the elements are going to be the same, you'll find out like village and subject I just grabbed that from you know other pages, including out on the actual website. And you know this input here with this piece of little code in here, if approved, I just grabbed that from somewhere else. After a while you will find that you are just not going to be writing that much new code unless you do something drastically different. And I like the design of this little thing here with the table and that form, and then being able to look at all these things. So come on back to the next chapter where we will get into users logging in and thus having a different user_ID here, and changing the corkboard so that, come on, changing the corkboard so that if they have logged in, then their name here will be linked. And you can click on it and see who they are, if they've set up some user criteria, and that will be in the whole next chapter. in, then their name here will be linked. And you can click on it and see who they are, if they've set up some user criteria, and that will be in the whole next chapter.

Tutorial Information

Course: Macromedia ColdFusion
Author: Mike Muller
SKU: 33287
ISBN: 1930519656
Release Date: 2001-12-19
Duration: 8 hrs / 86 lessons
Work Files: Yes
Captions: For Online University members only
Compatibility: Vista/XP/2000, OS X, Linux
QuickTime 7, Flash 8

VTC Sign up & Benefits

  • Unlimited Access
  • 98,729 Video Tutorials (23,265 free)
  • Video Available as Flash or QuickTime
  • Over 1026 Courses
  • $30 for One Month Access
  • Multi-User Discounts Available