By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 1,115 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

OnClick from HTML should trigger a query - depending upon that a new PHP page should

P: 1
Hi
I am very new to PHP. Please help.
I have a HTML code in a php file which takes in USERID and password. I have <input name="Submit" type="button" value="Submit" onClick="funCheck()"/>, funCheck is a function which makes sure that something is entered in the userid/password fields. This function is present in the same PHP file.
employee_data.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Employee Data</title>
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif}
.style2 {font-family: "Times New Roman", Times, serif}
-->
</style>
</head>
<script language=javascript>
function funCheck()
{
if(document.frmemployeedata.textEmployeeID.value == "")
{
alert("Enter the Employee ID");
// return false;
}
else if (document.frmemployeedata.txtPassword.value == "")
{
alert("Enter the Password");
// return false;
}
else{
// dataConnection();
// document.frmemployeedata.action="Form_2.php";
// document.frmemployeedata.submit();
// return True;
}
}
function funCancel()
{
document.frmemployeedata.action="Employee_Data.php ";
document.frmemployeedata.submit();
}
</script>
<body>
<form method="post" name="frmemployeedata">
<h4 align="center" class="style2">EMPLOYEE DATA</h4>
<p align="center" class="style2">&nbsp;</p>
<h4 align="center" class="style2">Please make sure you have an SGT Employee Number to enter this system</h4>
<h4 align="center" class="style2">Please enter your Employee Id and password to enter this system</h4>

<table align="center" width="240" border="0">
<tr>
<td align="left" width="132" height="45">
<label><strong>Employee ID</strong></label>
</td>
<td align="left" width="108" height="45">
<input name="textEmployeeID" type="text" size="18" />
</td>
</tr>
<tr>
<td align="left" width="132" height="45">
<label><strong>Password</strong></label>
</td>
<td align="left" width="108" height="45">
<input name="txtPassword" type="password" size="18" />
</td>
</tr>
<tr>
<td align="right">
<input name="Submit" type="button" value="Submit" onClick="funCheck()"/>
</td>
<td align="left">
<input name="Cancel" type="button" value="Cancel" onClick="funCancel()" />
</td>
</tr>
</table>
</form>
</body>
</html>




Once that is done, I want to call a function from the following php file. Actually if I say include in my previous file it is not taking it.
I am giving the following code inside funcheck function
function funCheck()
{
include ('C:\htdocs\HR-FIN\sample.php');
if(document.frmemployeedata.textEmployeeID.value == "")
{
alert("Enter the Employee ID");
// return false;
}
else if (document.frmemployeedata.txtPassword.value == "")
{
alert("Enter the Password");
// return false;
}
else{
dataConnection();
// document.frmemployeedata.action="Form_2.php";
// document.frmemployeedata.submit();
// return True;
}
}

If I do this I am getting an error at line include ('C:\htdocs\HR-FIN\sample.php');

My sample.php looks like this.
<?php
function dataConnection()
{
$con = mysql_connect("localhost","root","symcon");
echo("connected");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
else{
mysql_select_db("fin_hr_tables", $con);
$result = mysql_query("SELECT 1 FROM fin_hr_tables.emp_info_password where EmployeeID='" . $textEmployeeID ."' and EmpPassword='" . $txtPassword. "'");
if($result =1)
{
echo "1";
}
else{
echo "error in page";
}
}
mysql_close($con);
}
?>



Could some one show me the right thing to do here.
Thanks
Raji
Nov 2 '06 #1
Share this Question
Share on Google+
1 Reply


ronverdonk
Expert 2.5K+
P: 4,258
Before you post in this forum you must read the Posting Guidelines or, when you are replying in the msg editor, the REPLY GUIDELINES at the right side of the screen. Especially the part about enclosing you code with html, php or code tags.

You cannot expect our members to wade throught a lot of unstructured code lines. I certainly will not.

Ronald :cool:
Nov 2 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.