Login

Welcome, Guest. Please login or register.

July 26, 2025, 04:31:23 am

Author Topic: Quick question on Dreamweaver.  (Read 3245 times)  Share 

0 Members and 1 Guest are viewing this topic.

abd123

  • Guest
Quick question on Dreamweaver.
« on: March 22, 2012, 08:51:54 pm »
0
How do I make a username and password on dreamweaver?

observer7

  • Victorian
  • Forum Obsessive
  • ***
  • Posts: 234
  • Respect: +6
  • School Grad Year: 2011
Re: Quick question on Dreamweaver.
« Reply #1 on: March 22, 2012, 10:59:06 pm »
0
thats a really open ended question, can you elaborate?
if you are talking about a membership type system where you need to login you will need an aligned database and probably some php.
for the purpose of ITA you only need to model a website, it does not need to be 100% functional. 'prototype'
Finished in 2011. Business 50. ATAR 96

Lasercookie

  • Honorary Moderator
  • ATAR Notes Legend
  • *******
  • Posts: 3167
  • Respect: +326
Re: Quick question on Dreamweaver.
« Reply #2 on: March 22, 2012, 11:26:11 pm »
+1
for the purpose of ITA you only need to model a website, it does not need to be 100% functional. 'prototype'
Assuming this is the case, it should be satisfactory to merely have just have a webpage with a form that has the field 'username' and 'password'. Upon pressing submit, the user can then be redirected to the 'member-only, closed access pages'. If a user was navigating your website by clicking on links only, they should not be able to land on these 'member-only, closed access pages' without having gone through the login page which contains the form.

I don't remember what the automatic dialog thingy for dreamweaver is like, but the form would be something like
Code: [Select]
<form name="loginFORM" method="POST" action="/members/index.html">
<label for="username">Username</label>
<input type="text" name="username" id="username" value="" tabindex="1" />
<label for="password">Password</label>
<input type="password" name="password" id="password" value="" tabindex="2" />
<input type="submit" name="login" id="login" value="Login" />
<input type="checkbox" name="remember" id="remember" value="1" tabindex="3" /> Remember Me?</input>
</form>
You could alter the value for 'action' to be any webpage on your server. You probably wouldn't need to be using POST since there isn't any actual server-side code.

Some of the other attributes I included are a bit unnecessary for minimal function as well (i.e. all the name and id attributes, but they do come in quite handy once you start applying CSS and all that). The label stuff is somewhat unnecessary as well.

If you're bored and wanted to take the prototype website thing one step further, you could implement a fake database kind of functionality through javascript (have it check if the username and password entered into the form are equal to a predefined username and password in the code). Obviously that's not necessary for IT Apps and not something you'd ever use for a functioning website.

If you wanted this login form to actually be functioning, you'd most likely set action to land on a server-side scripting enabled page (php in combination with a database for example, like Observer7 mentioned above). The login form itself would probably be a php page as well, and you could set up get some fancy validation going on - also something that can be done solely through javascript in some cases. Depending on the extent of validation you're running - if you just wanted to check if the user hasn't entered funny symbols or gone over a predefined character limit, yeah that's do-able in javascript, but if you wanted to check if a username existed in the database. Kind of like those check availability things when you register on websites is what I'm thinking of, then that's something you'd need server-side scripting + a database for] (once again, you could fake that functionality in Javascript [and once again, that's not a necessary thing to do for a prototype website, just kind of saying that it could be done if you really wanted]).
« Last Edit: March 22, 2012, 11:28:34 pm by laseredd »

Ndon95

  • Victorian
  • Trailblazer
  • *
  • Posts: 45
  • Respect: 0
  • School: Salesian College CHADSTONE
  • School Grad Year: 2012
Re: Quick question on Dreamweaver.
« Reply #3 on: March 28, 2012, 08:37:30 pm »
0
oh yea @laserdd
on the fake login system with javascript how would you go on around doing that i was trying that for hours and hours and eventually gave up my sac is finished... but im still curious.....
thanks in advance :D

Lasercookie

  • Honorary Moderator
  • ATAR Notes Legend
  • *******
  • Posts: 3167
  • Respect: +326
Re: Quick question on Dreamweaver.
« Reply #4 on: March 28, 2012, 08:44:10 pm »
+2
oh yea @laserdd
on the fake login system with javascript how would you go on around doing that i was trying that for hours and hours and eventually gave up my sac is finished... but im still curious.....
thanks in advance :D
Yeah sure, I'll write up an example of how I would go about it when I'm not busy.

Lasercookie

  • Honorary Moderator
  • ATAR Notes Legend
  • *******
  • Posts: 3167
  • Respect: +326
Re: Quick question on Dreamweaver.
« Reply #5 on: March 28, 2012, 09:39:27 pm »
+2
login.html:
Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Login Page</title>
<script type="text/javascript">
function login(data) {
var username = data.username.value; //sets variable 'username' based upon the input in the form
var password = data.password.value; //same thing, data.username and data.password refers to the form element with that ID

if (username == "day" && password == "tripper") {
data.action = "members.html"; //changes the form 'action' attribute to the page the form will redirect to
} else {
//Inform the user that an incorrect username/password has been entered
//this section of code basically just inserts text into the div 'formError'
var field = document.getElementById("formError");
while(field.childNodes.length >= 1) {
field.removeChild(field.firstChild);
}
field.appendChild(fieldNameElement.ownerDocument.createTextNode("Invalid Username or Password"));
}
}
</script>

</head>

<body>
<!-- action is set to '#', this will be updated if the username/password prove to be valid-->
<form name="loginForm" method="post" action="#">
<label for="username">Username</label>
<input type="text" name="username" id="username" tabindex="1" />

<label for="password">Password</label>
<input type="password" name="password" id="password" tabindex="2" />

<!-- take note of onClick, it will pass on and run that javascript function -->
<input type="submit" name="doLogin" id="doLogin" onClick="login(this.form);" value="Login" />
<!-- this div will be updated through javascript-->
<div class="formError" id="formError"></div>
</form>

</body>
</html>

There's also a page called 'members.html', which is the page it redirects to upon logging in.

So, basically what I did was:
1. Have a login form.
2. Pass the data from that form to a JavaScript function
3. Check if the data entered matches the predefined username and password
4a. If it is valid, then redirect the user
4b. If it is invalid, then alert the user of the error

You could extend part 3 by setting up a data structure that contains a set of usernames and passwords and then checking if the username and password exists in that data structure. That would allow you to 'fake' the functionality of having multiple users in a database.

Again, obviously it's not a solution that you would ever use, but it's good enough for faking the functionality.

Ndon95

  • Victorian
  • Trailblazer
  • *
  • Posts: 45
  • Respect: 0
  • School: Salesian College CHADSTONE
  • School Grad Year: 2012
Re: Quick question on Dreamweaver.
« Reply #6 on: April 15, 2012, 10:19:27 pm »
0
thanks mate omg i was trying to verify using javascript and using a form to redirect ..
no wonder it didnt work thanks man i learn something new everyday xD