Click here to Skip to main content
       

JavaScript

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
GeneralRe: HTML5 Javascript IssuemvpJohn Simmons / outlaw programmer3 Dec '12 - 15:20 
GeneralRe: HTML5 Javascript IssuememberMedia2r18 Dec '12 - 0:51 
GeneralRe: HTML5 Javascript IssuememberBrainiacV18 Dec '12 - 3:46 
GeneralRe: HTML5 Javascript IssuemvpJohn Simmons / outlaw programmer3 Dec '12 - 5:29 
GeneralRe: HTML5 Javascript IssuemvpJohn Simmons / outlaw programmer4 Dec '12 - 1:06 
GeneralRe: HTML5 Javascript IssuemvpJohn Simmons / outlaw programmer4 Dec '12 - 7:31 
GeneralRe: HTML5 Javascript IssuememberZaf Khan19 Dec '12 - 20:36 
AnswerRe: HTML5 Javascript IssuememberZaf Khan19 Dec '12 - 20:42 
QuestionCatching Exceptions in JavascriptmemberVed Yo29 Nov '12 - 14:43 
QuestionPartial Overlay to cover ajax requestmemberSentenryu29 Nov '12 - 1:51 
QuestionHow to get value from TDmemberChitttapa26 Nov '12 - 10:03 
Questionhelp me pleasememberdoa'a_9224 Nov '12 - 4:16 
AnswerRe: help me please [modified]memberLeon Munir25 Nov '12 - 13: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"/> <br />
Password <input  type ="password" name ="password"/> <br />
<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<br/><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:15.

GeneralRe: help me pleasememberJ4amieC25 Nov '12 - 21:13 
GeneralRe: help me pleasememberLeon Munir26 Nov '12 - 2:06 
GeneralRe: help me pleasememberJ4amieC26 Nov '12 - 5:30 
GeneralRe: help me pleasememberMarcus Kramer26 Nov '12 - 5:37 
GeneralRe: help me pleasememberdoa'a_9226 Nov '12 - 9:28 
Questiononmouseover and document.getElementByIdmemberSRJ9223 Nov '12 - 4:18 
AnswerRe: onmouseover and document.getElementByIdmemberJ4amieC23 Nov '12 - 4:48 
GeneralRe: onmouseover and document.getElementByIdmemberSRJ9223 Nov '12 - 5:49 
AnswerRe: onmouseover and document.getElementByIdmemberjainsachin30 Nov '12 - 9:17 
Questiondisplaying different contentunder single layoutmemberradha123 from Hyderabad23 Nov '12 - 3:32 
AnswerRe: displaying different contentunder single layoutmembermanojwadnere28 Dec '12 - 0:07 
QuestionRegular expressionmemberMember 962181822 Nov '12 - 2:25 
AnswerRe: Regular expression [modified]membern.podbielski22 Nov '12 - 20:00 
GeneralRe: Regular expressionmvpManfred R. Bihy22 Nov '12 - 21:20 
GeneralRe: Regular expressionmembern.podbielski23 Nov '12 - 21:15 
Questionform validationmembertherainking7821 Nov '12 - 22:07 
AnswerRe: form validationmvpRichard MacCutchan21 Nov '12 - 22:17 
GeneralRe: form validationmembertherainking7828 Nov '12 - 13:14 
AnswerRe: form validationmemberbVagadishnu28 Nov '12 - 11:14 
GeneralRe: form validationmembertherainking7828 Nov '12 - 13:17 
Questionopeing a new window in JS after time intervalmemberWaqasCheema20 Nov '12 - 23:36 
AnswerRe: opeing a new window in JS after time intervalmemberAndrew Stoute30 Nov '12 - 4:51 
QuestionDraw circuit diagram using javascriptmemberanishkannan18 Nov '12 - 22:31 
AnswerRe: Draw circuit diagram using javascriptmembern.podbielski19 Nov '12 - 21:07 
Answerto transfer items in select list to another select list without duplicatesmemberraviteja999200014 Nov '12 - 20:09 
QuestionHow does Yandex do its trick?memberXarzu14 Nov '12 - 19:42 
AnswerRe: How does Yandex do its trick? [modified]mvpManfred R. Bihy14 Nov '12 - 20:44 
Questiondisplay record from two different timememberuti123fil8 Nov '12 - 17:15 
AnswerRe: display record from two different timemvpRichard MacCutchan8 Nov '12 - 23:47 
QuestionAdding a month to the current datememberSadiqMohammed6 Nov '12 - 23:48 
AnswerRe: Adding a month to the current datememberRichard Deeming7 Nov '12 - 2:00 
GeneralRe: Adding a month to the current datememberSadiqMohammed7 Nov '12 - 18:31 
GeneralRe: Adding a month to the current datememberRichard Deeming8 Nov '12 - 2:11 
GeneralRe: Adding a month to the current datememberSadiqMohammed8 Nov '12 - 19:08 
AnswerRe: Adding a month to the current datememberdeepak.m.shrma19 Nov '12 - 18:07 
GeneralRe: Adding a month to the current datememberPeter_in_278019 Nov '12 - 18:58 
GeneralRe: Adding a month to the current datememberdeepak.m.shrma19 Nov '12 - 19:52 

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


Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 21 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid