User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 423,396 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,603 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 705 | Replies: 2
Reply
Join Date: Jul 2007
Posts: 106
Reputation: Designer_101 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
Designer_101 Designer_101 is offline Offline
Junior Poster

Question Loading Variables?

  #1  
Sep 7th, 2007
Hey
I'm having a bit of trouble. I am currently learning php and mysql to access my servers database and collect data. In which i want to use a username and password form. However in the meen time i would like to create one using plain html and javascript. I am quite experienced with javascript, although i have forgotten how to load variables from an external .txt file. Otherwise my users would simply be able to view my source code and see the username and password they need to type.

Any help on this is greatly appreciated

thanks
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 2,817
Reputation: Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all 
Rep Power: 12
Solved Threads: 282
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Posting Maven

Re: Loading Variables?

  #2  
Sep 7th, 2007
Well, you would probably have better luck asking this over in the javascript forum, as this one is just Java.

From the php standpoint though, here is a simple login form and verification for a small site I put together for a local grayhound group. Maybe it will help you along:
File: index.php
  1. <html>
  2. <title>Greyhound Adoptions</title>
  3. <LINK REL="StyleSheet" HREF="default.css" TYPE="text/css">
  4. <body>
  5. <center>
  6. <h1>Greyhound Adoptions</h1><BR>
  7. <form action='loginck.php' method=post>
  8. <table border='0' cellspacing='0' cellpadding='0' align=center>
  9. <tr id='cat'>
  10. <tr><td><font face='verdana, arial, helvetica' size='2' align='center'> Login ID </font></td>
  11. <td align='center'><font face='verdana, arial, helvetica' size='2'><input type ='text' name='userid' ></font></td>
  12. </tr>
  13.  
  14. <tr><td><font face='verdana, arial, helvetica' size='2' align='center'> Password</font></td>
  15. <td align='center'><font face='verdana, arial, helvetica' size='2'><input type ='password' class='bginput' name='password' ></font></td>
  16. </tr>
  17.  
  18. <tr><td colspan='2' align='center'><font face='verdana, arial, helvetica' size='2' align='center'>
  19. <input type='submit' value='Submit'> <input type='reset' value='Reset'></font></td>
  20. </tr>
  21. <tr> <td colspan='2' align='center'><font face='verdana, arial, helvetica' size='2' align='center'> </font></td> </tr>
  22.  
  23. </table>
  24. </form>
  25. </center>
  26. </body>
  27. </html>

File: loginck.php
  1. <?php
  2. session_start();
  3. include "dbConn.php";
  4.  
  5. $userid = $_POST['userid'];
  6. $password = $_POST['password'];
  7.  
  8. $userid=mysql_real_escape_string($userid);
  9. $password=mysql_real_escape_string($password);
  10.  
  11. $password = md5($password);
  12.  
  13. if($rec=mysql_fetch_array(mysql_query("SELECT * FROM users WHERE name='$userid' AND pwd = '$password'"))){
  14. if(($rec['name']==$userid)&&($rec['pwd']==$password)){
  15. $_SESSION['id']=session_id();
  16. $_SESSION['userId']=$userid;
  17.  
  18. header("Location: viewDogs.php");
  19. }
  20. }
  21. else {
  22.  
  23. session_unset();
  24. echo "<font face='Verdana' size='2' color=red>Wrong Login. Use your correct Userid and Password and Try <br><center><input type='button' value='Retry' onClick='history.go(-1)'></center>";
  25. session_destroy();
  26. }
  27. ?>
Last edited by Ezzaral : Sep 7th, 2007 at 4:51 pm. Reason: messed up code tags
Reply With Quote  
Join Date: Jul 2007
Posts: 106
Reputation: Designer_101 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
Designer_101 Designer_101 is offline Offline
Junior Poster

Re: Loading Variables?

  #3  
Sep 7th, 2007
erm thanks but this is individual unique scripting set up but i do understand the flow from a php point of view but like i said, still learning in that area. Il take your advise il ask at the javascript forum.

thanks ezarell
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 1:03 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC