Jump to content
Killersites Forums

newbie to javascript would appreciate some help


izcrab
 Share

Recommended Posts

Hi all,

 

As a very very newbie to Javascript I have been banging my head against a brick wall.........please help it is starting to hurt.......:)

 

what I am trying to achieve is this:-

 

I want to be able to set up a log in page for a website, which asks for a username and password and once validated to bring up another page which will allow new data to be typed in to a field and then when submitted this new data (numeric by the way) is then amended to another webpage in a table.

 

I have managed to get the login in bit sorted, but only by downloading a script that someone else posted on another forum, I have also been able to get the 2 page to load after the validation process and display a prompt box. What I can't seem to get is the script needed to take the number from the input field of the second page and then write that data into another seperate web page in a table!!!!!

 

I hope this makes sense, if you need any snippets of code that I have got so far please let me know, with how I can get it to you, and I will gladly provide.

 

I am hoping one or more of you clever more advanced guys can help.

 

Thanking you in advance.

Link to comment
Share on other sites

This isn't something you would want to do with javascript. Javascript isn't secure, since the code is displayed directly in the browser. A user could easily bypass login validation by modifying the javascript on their local machine and then reopening the page. As for the bit about allowing a user to type in data and save it to another page, that is something you would want to do with PHP/MySQL and a database -- I don't believe that Javascript can do that. All PHP is processed on the server, so it is much more secure, and it will allow you to do the getting of form data and processing it the Javascript will have trouble with.

 

Basically, these are the steps you'd need to take:

 

-- Allow the user to login. To do this, you'd need to:

---- Create an HTML form to log the user in

---- When the user clicks the "submit" button, you'd need to get the data in the form fields using PHP's POST[] function

---- do some basic logic using an "if" statement to check if the username/password is correct (or, more advanced, check the username/password against values in a database)

---- If the username matches, set a session variable that the user is logged in (http://www.tizag.com/phpT/phpsessions.php), and redirect them to a new page (http://us.php.net/manual/en/function.header.php)

 

-- On the new page, check if the user is logged in. If so, keep them on the page. If not, redirect back.

-- On the new page, build a form that allows the user to input data, and then uses PHP to save that data to a database (http://www.tizag.com/mysqlTutorial/mysqlconnection.php / http://www.tizag.com/mysqlTutorial/mysqlinsert.php)

-- Build a basic logout function that destroys the session variable once the user is finished, and redirects them away from the admin area

 

-- On the page where you want the data to display, use PHP to connect to the database and retrieve the saved data, displaying it in a table (http://www.tizag.com/mysqlTutorial/mysqlselect.php)

 

I'd suggest taking a look at Tizag's PHP tutorials (http://www.tizag.com/phpT/index.php). They do a good job of explaining some of the basic functions of PHP.

 

Also, take a look at this: http://net.tutsplus.com/videos/screencasts/how-to-build-a-login-system-for-a-simple-website/ and take a glance through the variety of articles/screencasts that NetTuts offers on PHP.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...