javascript validation not work in php coding

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
praban
Forum Newbie
Posts: 1
Joined: Thu Feb 28, 2013 10:47 pm

javascript validation not work in php coding

Post by praban »

Code: Select all

<?php
include("include/connection.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// username and password sent from Form
$myusername=addslashes($_POST['username']);
$mypassword=addslashes($_POST['password']);

$sql="SELECT * FROM customer WHERE user='$myusername' and pass='$mypassword'";
$result=mysql_query($sql) or die(mysql_error());;
$row=mysql_fetch_array($result);
$active=$row['active'];
$count=mysql_num_rows($result);


// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)
{
session_register("myusername");
$_SESSION['login_user']=$myusername;

header("location: uploadads.php");
}
else
{
echo $error="Your Login Name or Password is invalid";
}
}
?>


<!doctype html>

<html lang="en-US">
<head>
<meta charset="UTF-8" />
<title>addfreeads</title>


<style type="text/css">
<!--
.style13 {color: #333333; }
.style14 {
	color: #666666;
}

</style>
<script type="text/javascript">
$(document).ready(function(){
$('#submit').click(function(){
var username=$('#username').val();
var password=$('#password').val();

if(username=="")
{
$('#dis').slideDown().html("<span>Please type Username</span>");
return false;
}
if(password=="")
{
$('#dis').slideDown().html('<span id="error">Please type Password</span>');
return false;
}
});
});
</script>
</head>

<body>
<div id="wrap">
<section id="left">
	<header id="mainheader">
	  <img src="images/logo.jpg" width="250" height="120" > 
    </header>
   
   
    <section id="sidebar">
     <div class="sb-block" style="border:inset 5px #665e52; padding:0;">
     
<label id="dis"> </label><br>
      <h2>LOGIN</h2>
      <form smethod="post" action=""> 
      
                        <label>UserName:</label>
                        <input type="text" name="username" id="username"/><br /><br /><br />
                        <label>Password :</label>
                        <input type="password" name="password" id="password"/><br /><br />
            <br/>
                        <input type="submit" value="submit"  id="submit" /><br /><br />
    			</form>
                </div>



error message is not work in this coding. coding working in other form .
User avatar
Grizzzzzzzzzz
Forum Contributor
Posts: 125
Joined: Wed Sep 02, 2009 8:51 am

Re: javascript validation not work in php coding

Post by Grizzzzzzzzzz »

what error message?

where about in the code?

what's "not working" about it?
User avatar
mecha_godzilla
Forum Contributor
Posts: 375
Joined: Wed Apr 14, 2010 4:45 pm
Location: UK

Re: javascript validation not work in php coding

Post by mecha_godzilla »

Hi,

Are you trying to use jQuery with this script? I don't think slideDown() is a standard JavaScript method, so you need to make sure you've included a link to the jQuery API somewhere in your page.

HTH,

Mecha Godzilla
Post Reply