Click here to Skip to main content
11,429,345 members (68,040 online)

JavaScript

 
GeneralRe: HTML5 Javascript Issue Pin
Graham Breach3-Dec-12 12:02
memberGraham Breach3-Dec-12 12:02 
GeneralRe: HTML5 Javascript Issue Pin
John Simmons / outlaw programmer3-Dec-12 16:20
mvpJohn Simmons / outlaw programmer3-Dec-12 16:20 
GeneralRe: HTML5 Javascript Issue Pin
Media2r18-Dec-12 1:51
memberMedia2r18-Dec-12 1:51 
GeneralRe: HTML5 Javascript Issue Pin
BrainiacV18-Dec-12 4:46
memberBrainiacV18-Dec-12 4:46 
GeneralRe: HTML5 Javascript Issue Pin
John Simmons / outlaw programmer3-Dec-12 6:29
mvpJohn Simmons / outlaw programmer3-Dec-12 6:29 
GeneralRe: HTML5 Javascript Issue Pin
John Simmons / outlaw programmer4-Dec-12 2:06
mvpJohn Simmons / outlaw programmer4-Dec-12 2:06 
GeneralRe: HTML5 Javascript Issue Pin
John Simmons / outlaw programmer4-Dec-12 8:31
mvpJohn Simmons / outlaw programmer4-Dec-12 8:31 
GeneralRe: HTML5 Javascript Issue Pin
Zaf Khan19-Dec-12 21:36
memberZaf Khan19-Dec-12 21:36 
AnswerRe: HTML5 Javascript Issue Pin
Zaf Khan19-Dec-12 21:42
memberZaf Khan19-Dec-12 21:42 
QuestionCatching Exceptions in Javascript Pin
Ved Yo29-Nov-12 15:43
memberVed Yo29-Nov-12 15:43 
QuestionPartial Overlay to cover ajax request Pin
Sentenryu29-Nov-12 2:51
memberSentenryu29-Nov-12 2:51 
QuestionHow to get value from TD Pin
Chitttapa26-Nov-12 11:03
memberChitttapa26-Nov-12 11:03 
Questionhelp me please Pin
doa'a_9224-Nov-12 5:16
memberdoa'a_9224-Nov-12 5:16 
AnswerRe: help me please [modified] Pin
Leon Munir25-Nov-12 14:46
memberLeon Munir25-Nov-12 14:46 
Here is the complete code without ajax functionality. You didn't mention in the question if you wanted to display result without loading the php page.The login.html could looks like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
<script type = "text/javascript">
function validate(){
    if((f1.login.value == "") || (f1.password.value == ""))
    {
        alert("you must enter your name and password");
	return false;
    }
    else
    {    
	return true;
    }
}
</script>  
</head> 
<body>
<form  id ="f1"  action = "validate.php" method="post" onsubmit ="return validate(this);">
User Name <input  type ="text"  name = "login"/> 
 
Password <input  type ="password" name ="password"/> 
 
<input type = "submit"  value ="login"/>
</form> 
</body> 
</html>

The validate.php could look like this:

<?php
// fetching username and password
$userName = $_REQUEST["login"];
$userPassword = $_REQUEST["password"];
	
// using regular expressions to evaluate username
if(preg_match("/^[a-zA-Z][a-zA-Z0-9_]+$/", $userName, $matches)	)
{
    CheckWithDatabase($userName,$userPassword);
}
	
function CheckWithDatabase(&$usr, &$pw)
{
    // connecting to the database 
    mysql_connect("localhost", "userleon", "Pa55word") or die(mysql_error()); 
    mysql_select_db("students") or die(mysql_error()); 
    $data = mysql_query("SELECT login, password FROM login_password") or die(mysql_error());  
    while($info = mysql_fetch_array( $data )) 
    { 
         if( ($usr == $info['login']) && ( $pw == $info['password'] ))
	{
            echo "Thank you for logging in";
            // two choices offered on successful login
            echo "<form><input type=\"radio\" name=\"choice\" value=\"Add a new student\">Add a new student
<input type=\"radio\" name=\"choice\" value=\"Remove a student\"/>Remove a student</form>";
	}
	else
	{
            // GO BACK link
            echo "<a href=\"javascript:history.go(-1)\">GO BACK</a>";
            // javascript displays message
            echo "<script type=\"text/javascript\">alert(\"wrongpassword and/or login please try again\");</script>";
	}
    } 
}
?>

Hope it answers your question Smile | :)
follow me on twitter @leon_developer


modified 25-Nov-12 20:15pm.

GeneralRe: help me please Pin
J4amieC25-Nov-12 22:13
memberJ4amieC25-Nov-12 22:13 
GeneralRe: help me please Pin
Leon Munir26-Nov-12 3:06
memberLeon Munir26-Nov-12 3:06 
GeneralRe: help me please Pin
J4amieC26-Nov-12 6:30
memberJ4amieC26-Nov-12 6:30 
GeneralRe: help me please Pin
Marcus Kramer26-Nov-12 6:37
memberMarcus Kramer26-Nov-12 6:37 
GeneralRe: help me please Pin
doa'a_9226-Nov-12 10:28
memberdoa'a_9226-Nov-12 10:28 
Questiononmouseover and document.getElementById Pin
SRJ9223-Nov-12 5:18
memberSRJ9223-Nov-12 5:18 
AnswerRe: onmouseover and document.getElementById Pin
J4amieC23-Nov-12 5:48
memberJ4amieC23-Nov-12 5:48 
GeneralRe: onmouseover and document.getElementById Pin
SRJ9223-Nov-12 6:49
memberSRJ9223-Nov-12 6:49 
AnswerRe: onmouseover and document.getElementById Pin
jainsachin30-Nov-12 10:17
memberjainsachin30-Nov-12 10:17 
Questiondisplaying different contentunder single layout Pin
radha123 from Hyderabad23-Nov-12 4:32
memberradha123 from Hyderabad23-Nov-12 4:32 
AnswerRe: displaying different contentunder single layout Pin
manojwadnere28-Dec-12 1:07
membermanojwadnere28-Dec-12 1:07 
QuestionRegular expression Pin
Member 962181822-Nov-12 3:25
memberMember 962181822-Nov-12 3:25 
AnswerRe: Regular expression [modified] Pin
n.podbielski22-Nov-12 21:00
membern.podbielski22-Nov-12 21:00 
GeneralRe: Regular expression Pin
Manfred R. Bihy22-Nov-12 22:20
mvpManfred R. Bihy22-Nov-12 22:20 
GeneralRe: Regular expression Pin
n.podbielski23-Nov-12 22:15
membern.podbielski23-Nov-12 22:15 
Questionform validation Pin
therainking7821-Nov-12 23:07
membertherainking7821-Nov-12 23:07 
AnswerRe: form validation Pin
Richard MacCutchan21-Nov-12 23:17
mvpRichard MacCutchan21-Nov-12 23:17 
GeneralRe: form validation Pin
therainking7828-Nov-12 14:14
membertherainking7828-Nov-12 14:14 
AnswerRe: form validation Pin
bVagadishnu28-Nov-12 12:14
memberbVagadishnu28-Nov-12 12:14 
GeneralRe: form validation Pin
therainking7828-Nov-12 14:17
membertherainking7828-Nov-12 14:17 
Questionopeing a new window in JS after time interval Pin
WaqasCheema21-Nov-12 0:36
memberWaqasCheema21-Nov-12 0:36 
AnswerRe: opeing a new window in JS after time interval Pin
Andrew Stoute30-Nov-12 5:51
memberAndrew Stoute30-Nov-12 5:51 
QuestionDraw circuit diagram using javascript Pin
anishkannan18-Nov-12 23:31
memberanishkannan18-Nov-12 23:31 
AnswerRe: Draw circuit diagram using javascript Pin
n.podbielski19-Nov-12 22:07
membern.podbielski19-Nov-12 22:07 
Answerto transfer items in select list to another select list without duplicates Pin
raviteja999200014-Nov-12 21:09
memberraviteja999200014-Nov-12 21:09 
QuestionHow does Yandex do its trick? Pin
Xarzu14-Nov-12 20:42
memberXarzu14-Nov-12 20:42 
AnswerRe: How does Yandex do its trick? [modified] Pin
Manfred R. Bihy14-Nov-12 21:44
mvpManfred R. Bihy14-Nov-12 21:44 
Questiondisplay record from two different time Pin
uti123fil8-Nov-12 18:15
memberuti123fil8-Nov-12 18:15 
AnswerRe: display record from two different time Pin
Richard MacCutchan9-Nov-12 0:47
mvpRichard MacCutchan9-Nov-12 0:47 
QuestionAdding a month to the current date Pin
SadiqMohammed7-Nov-12 0:48
memberSadiqMohammed7-Nov-12 0:48 
AnswerRe: Adding a month to the current date Pin
Richard Deeming7-Nov-12 3:00
memberRichard Deeming7-Nov-12 3:00 
GeneralRe: Adding a month to the current date Pin
SadiqMohammed7-Nov-12 19:31
memberSadiqMohammed7-Nov-12 19:31 
GeneralRe: Adding a month to the current date Pin
Richard Deeming8-Nov-12 3:11
memberRichard Deeming8-Nov-12 3:11 
GeneralRe: Adding a month to the current date Pin
SadiqMohammed8-Nov-12 20:08
memberSadiqMohammed8-Nov-12 20:08 
AnswerRe: Adding a month to the current date Pin
deepak.m.shrma19-Nov-12 19:07
memberdeepak.m.shrma19-Nov-12 19:07 
GeneralRe: Adding a month to the current date Pin
Peter_in_278019-Nov-12 19:58
memberPeter_in_278019-Nov-12 19:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.8.150428.2 | Last Updated 30 Apr 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid