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

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

<html>
<title>Greyhound Adoptions</title>
<LINK REL="StyleSheet" HREF="default.css" TYPE="text/css">
<body>
<center>
<h1>Greyhound Adoptions</h1><BR>
<form action='loginck.php' method=post>
<table border='0' cellspacing='0' cellpadding='0' align=center>
<tr id='cat'>
<tr><td><font face='verdana, arial, helvetica' size='2' align='center'>  Login ID    </font></td> 
    <td align='center'><font face='verdana, arial, helvetica' size='2'><input type ='text' name='userid' ></font></td>
</tr>

<tr><td><font face='verdana, arial, helvetica' size='2' align='center'>  Password</font></td> 
    <td align='center'><font face='verdana, arial, helvetica' size='2'><input type ='password' class='bginput' name='password' ></font></td>
</tr>

<tr><td colspan='2' align='center'><font face='verdana, arial, helvetica' size='2' align='center'>
  <input type='submit' value='Submit'> <input type='reset' value='Reset'></font></td> 
</tr>
<tr> <td colspan='2' align='center'><font face='verdana, arial, helvetica' size='2' align='center'> </font></td> </tr>

</table>
</form>
</center>
</body>
</html>

File: loginck.php

<?php
session_start();
include "dbConn.php";

$userid = $_POST['userid'];
$password = $_POST['password'];

$userid=mysql_real_escape_string($userid);
$password=mysql_real_escape_string($password);

$password = md5($password);

if($rec=mysql_fetch_array(mysql_query("SELECT * FROM users WHERE name='$userid' AND pwd = '$password'"))){
    if(($rec['name']==$userid)&&($rec['pwd']==$password)){
        $_SESSION['id']=session_id();
        $_SESSION['userId']=$userid; 

        header("Location: viewDogs.php");
    }
}
else {

    session_unset();
    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>";
    session_destroy();
}
?>

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.