PHP script is not getting executed
Posted: Sun May 10, 2009 6:49 am
Hi I am quite new to PHP.
I have a simple login page ,which validates the text fields using Java Script and then submits the data to a php page .
Here is my login page:
Here is the code for the a1.php page which is called by the previous form:
Can anyone tell me what am I doing wrong here?? When I call the same script from flash,it gets executed.
Thanks.
I have a simple login page ,which validates the text fields using Java Script and then submits the data to a php page .
Here is my login page:
Code: Select all
<html>
<head>
<SCRIPT LANGUAGE="javascript">
<!--
function focus()
{
document.forms[0].username.focus();
}
function checkme() //check for required fields
{
var flag=0;
if (document.Login.username.value == "")
{alert("You did not enter your user name. Please provide it.");
document.Login.username.focus();
flag=1;return(false)
}
if (document.Login.username.value.length<6)
{alert("Username is too short. ");
document.Login.username.focus();
flag=1;return(false)
}
if (document.Login.password.value == "")
{alert("You did not password. Please provide it.");
document.Login.password.focus();
flag=1;return(false)
}
if (document.Login.password.value.length<6)
{alert("Password is too short.");
document.Login.password.focus();
flag=1;return(false)
}
}
//-->
</SCRIPT>
</head>
<body onLoad="focus()">
<div class="tdstyle">
<table width ="100%" border="0">
<tr>
<td width="20%"><a href"#">GUEST?Click here to Start</a>
</td>
<td width="80%" align="left"><a href"#">Take the Baseline Test</a>
</td>
</tr>
</table>
<form action="a1.php" method="GET" name="Login">
<table width="100%" height="80%" border="0">
<tr width="100%">
<td>
<p>Username: <input type="text" name="username" ><br></p>
<p>Password: <input type="password" name="password"></p>
<p><input type="Submit" value="Login"size="16" class="myButton" onclick="return checkme()"></p>
</td>
</tr>
</table>
</form>
</div>
<table border="0"width="100%">
<tr>
<td align ="left" width="10%">
<a href"#">About Us</a></td>
<td align="left" width="10%"><a href"#">Contact</a>
</td>
<td align="right" width="80%">
<a href"#">Legal</a>
</td>
</tr>
</table>
</body>
</html>
Code: Select all
<?php
/******** DATABASE SETTING *******/
$dbhost = 'hodt'; // database host
$dbuser = 'user'; // database username
$dbpass = 'pwd'; // database password
$dbname = 'dbname'; // database name
$mysql = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname);
$tuname=mysql_real_escape_string($_POST['username']);
$tpwd=mysql_real_escape_string($_POST['password']);
/*INSERT INTO DB*/
$Query='INSERT INTO login(`username`,`password`)VALUES (\''.$tuname.'\',\''.$tpwd.'\')';
mysql_query($Query);
echo $tuname;
// ECHO TO FLASH
if(mysql_query($Query))
{
$answer='ok';
echo "answer=".$answer;
echo $tuname;
}
else
{
$answer='nope';
echo "answer=".$answer;
}
mysql_close($mysql);
?>
Thanks.