//I want to call a function of javascript which is on login.php page from second page index1.php on the value of wrong username and password.. how can I do that//
//first page//
//login.php//
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<script type="text/javascript">
function validate_form(thisform)
{
with (thisform)
{
if (FirstName.value==null||FirstName.value=="")
{
alert("username should not be empty");
return false;
}
if(passwordd.value=="")
{
alert("password field should not be empty");
return false;
}
return true;
}
}
</script>
</head>
<body>
<table width="200" border="1">
<form action="index1.php" method="post" onsubmit="return validate_form(this)"><br /><br/><br />
<tr>
<td>UserName:</td>
<td><input type="text" name="FirstName" size="20" /></td>
</tr>
<tr>
<td>Password: </td>
<td><input type="password" name="passwordd" size="20" /></td>
</tr>
<tr>
<td><input type="submit" value="Login" /></td>
</form>
<form action="register.html" method="post">
<td><input type="submit" value="signup" /></td>
</tr>
</form>
</table>
</tr>
</table>
</body>
</html>
//second page//
//index1.php//
<?php
$con=mysql_connect("localhost","root","");
if(!$con)
{
die("could not connect".mysql_error());
}
mysql_select_db("db1",$con);
$uname=$_POST['FirstName'];
$pwd=$_POST['passwordd'];
$sql="select username,password from register where username='$uname' and password='$pwd' ";
$result=mysql_query($sql);
if(mysql_num_rows($result) > 0)
{
echo "<strong>welcome user ".$uname."</strong> ";
}
else
{
echo '<script language="Javascript">';
echo 'window.location="login.php"';
echo '</script>';
}
?>
Call a JavaScript function on a different html page from php
Moderator: General Moderators