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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ramalingam
    New Member
    • Oct 2006
    • 1

    #1

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

    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="funChe ck()"/>, 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.p hp
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Employ ee 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=javasc ript>
    function funCheck()
    {
    if(document.frm employeedata.te xtEmployeeID.va lue == "")
    {
    alert("Enter the Employee ID");
    // return false;
    }
    else if (document.frmem ployeedata.txtP assword.value == "")
    {
    alert("Enter the Password");
    // return false;
    }
    else{
    // dataConnection( );
    // document.frmemp loyeedata.actio n="Form_2.php ";
    // document.frmemp loyeedata.submi t();
    // return True;
    }
    }
    function funCancel()
    {
    document.frmemp loyeedata.actio n="Employee_Dat a.php";
    document.frmemp loyeedata.submi t();
    }
    </script>
    <body>
    <form method="post" name="frmemploy eedata">
    <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="textEmplo yeeID" 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="txtPasswo rd" type="password" size="18" />
    </td>
    </tr>
    <tr>
    <td align="right">
    <input name="Submit" type="button" value="Submit" onClick="funChe ck()"/>
    </td>
    <td align="left">
    <input name="Cancel" type="button" value="Cancel" onClick="funCan cel()" />
    </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.frm employeedata.te xtEmployeeID.va lue == "")
    {
    alert("Enter the Employee ID");
    // return false;
    }
    else if (document.frmem ployeedata.txtP assword.value == "")
    {
    alert("Enter the Password");
    // return false;
    }
    else{
    dataConnection( );
    // document.frmemp loyeedata.actio n="Form_2.php ";
    // document.frmemp loyeedata.submi t();
    // 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","roo t","symcon") ;
    echo("connected ");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    else{
    mysql_select_db ("fin_hr_tables ", $con);
    $result = mysql_query("SE LECT 1 FROM fin_hr_tables.e mp_info_passwor d where EmployeeID='" . $textEmployeeID ."' and EmpPassword='" . $txtPassword. "'");
    if($result =1)
    {
    echo "1";
    }
    else{
    echo "error in page";
    }
    }
    mysql_close($co n);
    }
    ?>



    Could some one show me the right thing to do here.
    Thanks
    Raji
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    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:

    Comment

    Working...