The order of tbody, td, form and table, if they are not in order, it might not work.
===================================================================
<html>
<head>
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<script>
$(function(){
$("#changePWDForm").validate({
rules:{
currentPwd: "required",
newPwd:{
required:true,
minlength: 8
},
checkPwd:{
required:true,
minlength: 8
},
},
messages:{
currentPwd: "Please enter your current password.",
newPwd: {
required: "Please enter your new password.",
minlength: "Your password must be at least 8 characters long"
},
checkPwd: {
required: "Please enter your new password.",
minlength: "Your password must be at least 8 characters long"
},
}
});
$(document).on('click', "#submitChange", function (e) {
alert('A');
});
});
</script>
</head>
<body>
<table border=0 id="embededLoginTable" class="outLineTable">
<tr>
<tbody id="oraPWDDiv">
<td align="center">
<form id="changePWDForm" method="post" class="ora_form" action="#">
<table border=0 class="centreTable">
<fieldset>
<tr>
<td><userLable><userLable>Current Password:</userLable></td><td><input type="password" name="currentPwd" id="currentPwd" class="ora_pwd"/></td>
</tr>
<tr>
<td><userLable>New Password:</userLable></td><td><input type="password" name="newPwd" id="newPwd" class="ora_pwd" /></td>
</tr>
<tr>
<td><userLable>Confirm New Password:</userLable></td>
<td><input type="password" name="checkPwd" id="checkPwd" class="ora_pwd"/> </td>
</tr>
<tr>
<td align="right"><input type="submit" name="submit" value="Change Password" id="submitChange" /></td>
<td align="left"><input type="reset" name="reset" value="Reset" id="resetinputs" /></td>
</tr>
</fieldset>
</table>
</form>
</td>
</tbody>
</tr>
<tr>
<td align="center">
<div id="messageDiv" class="mssgDiv"><md></md> </div>
</td>
</tr>
</table>
</body>
</html>
Tuesday, April 11, 2017
Wednesday, April 5, 2017
PHP oci_connect: ORA-01017: invalid username/password; logon denied
Symptom:
In browser, user click button to search Oracle Database by the username typed in input field. It works once, then complain:ORA-01017: invalid username/password; logon denied , click again it works, if click again, it pops up the error message again.
What I did:
1. Double quoted the connection password (in wallet in my case.)
2. creating a file called "20-oci8.ini" in directory "/etc/php.d" with the following content.
In browser, user click button to search Oracle Database by the username typed in input field. It works once, then complain:ORA-01017: invalid username/password; logon denied , click again it works, if click again, it pops up the error message again.
What I did:
1. Double quoted the connection password (in wallet in my case.)
2. creating a file called "20-oci8.ini" in directory "/etc/php.d" with the following content.
; Enable oci8 extension module
extension=oci8.so
3. Disable the extension=oci8.so in /etc/php.ini
Thursday, March 16, 2017
Autocomplete with PHP, Jquery UI and Oracle - 2
searchUser.php
<?php
session_start();
date_default_timezone_set('EST');
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
foreach ($_POST as $key => $value)
eval("\$$key = \"$value\";");
}
$userName = trim($_GET['term']);
$userName = strtoupper($userName);
putenv("TNS_ADMIN=/opt/.wallet");
putenv("ORACLE_HOME=/app/oracle/product/11.2.0.3");
putenv("LD_LIBRARY_PATH=/app/oracle/product/11.2.0.3/lib");
$conn = oci_connect("SYS", "password", "mydatabase", null, OCI_SYSDBA);
//$conn = oci_connect("/", "", "ITSERVICE", "AL32UTF8", OCI_CRED_EXT);
if (!$conn) {
$m = oci_error();
echo $m['message'] . "\n";
exit;
} else {
//$sql = 'BEGIN system.exposed_to_low_privs_users.GET_ACCOUNT_STATUSES(:P_OUT); END;';
//$sql = "select username,ACCOUNT_STATUS from dba_users where username like '" . $userName . "%'";
$sql = "select username,ACCOUNT_STATUS from dba_users order by USERNAME";
$stmt = oci_parse($conn,$sql);
// Bind the output parameter
oci_execute($stmt);
//oci_execute($cursor);
$return_array=array();
while (($row = oci_fetch_array($stmt, OCI_BOTH)) != false) {
$row_array['id'] = $row['USERNAME'];
$row_array['value'] = $row['USERNAME'];
$row_array['label'] =$row['USERNAME'];
//array_push($return_array,$row['USERNAME'],$row['ACCOUNT_STATUS']);
array_push($return_array,$row_array);
}
//var_dump($return_array);
echo json_encode($return_array);
}
// Close the Oracle connection
oci_free_statement($stmt);
oci_close($conn);
?>
<?php
session_start();
date_default_timezone_set('EST');
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
foreach ($_POST as $key => $value)
eval("\$$key = \"$value\";");
}
$userName = trim($_GET['term']);
$userName = strtoupper($userName);
putenv("TNS_ADMIN=/opt/.wallet");
putenv("ORACLE_HOME=/app/oracle/product/11.2.0.3");
putenv("LD_LIBRARY_PATH=/app/oracle/product/11.2.0.3/lib");
$conn = oci_connect("SYS", "password", "mydatabase", null, OCI_SYSDBA);
//$conn = oci_connect("/", "", "ITSERVICE", "AL32UTF8", OCI_CRED_EXT);
if (!$conn) {
$m = oci_error();
echo $m['message'] . "\n";
exit;
} else {
//$sql = 'BEGIN system.exposed_to_low_privs_users.GET_ACCOUNT_STATUSES(:P_OUT); END;';
//$sql = "select username,ACCOUNT_STATUS from dba_users where username like '" . $userName . "%'";
$sql = "select username,ACCOUNT_STATUS from dba_users order by USERNAME";
$stmt = oci_parse($conn,$sql);
// Bind the output parameter
oci_execute($stmt);
//oci_execute($cursor);
$return_array=array();
while (($row = oci_fetch_array($stmt, OCI_BOTH)) != false) {
$row_array['id'] = $row['USERNAME'];
$row_array['value'] = $row['USERNAME'];
$row_array['label'] =$row['USERNAME'];
//array_push($return_array,$row['USERNAME'],$row['ACCOUNT_STATUS']);
array_push($return_array,$row_array);
}
//var_dump($return_array);
echo json_encode($return_array);
}
// Close the Oracle connection
oci_free_statement($stmt);
oci_close($conn);
?>
Autocomplete with PHP, Jquery UI and Oracle - 1
searchUserUI.php
<?php
session_start();
date_default_timezone_set('EST');
echo "
<!doctype html>
<html>
<head>
<TITLE>jQuery AJAX Autocomplete - Country Example</TITLE>
";
echo '
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/css/autocomplete.css">
<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
';
echo "
<script>
$(document).ready(function () {
$(\"#userName\").autocomplete({
dataType: \"json\",
minLength: 2,
source: \"searchUser.php\",
select: function(event,ui) {
$(\"#userName\").val(ui.item.username);
}
});
});
</script>
";
echo "
<script>
$(function(){
$(document).on('click', \"#checkUserSessions\", function (e) {
var user=$(\"#userName\").val();
e.preventDefault(); $(\"#typeinUserName\").hide();
var inputData=$(\":input\").serializeArray();
$.ajax({
type: \"POST\",
url: \"/oraoperation/showUserActiveSessions.php\",
dataType : 'html',
data: inputData,
success: function(data, textStatus, jQxhr ){
$(\"#contentDiv\").html(data);
},
error: function( jqXhr, textStatus, errorThrown ){
$(\"#typeinUserName\").show();
$(\"#messageDiv\").html(errorThrown);
console.log( errorThrown );
}
});
});
});
</script>
";
echo "
</head>
<body>
";
echo "<table border=0 id=\"outLineTable\" class=\"centretable\" width=\"100%\">";
echo "<tbody id=\"typeinUserName\">";
echo "<tr>";
echo "<td align=\"center\">";
echo "<table border=1 id=\"sessionContentTable\">";
echo "<form id=\"chkDBSessions\" method=\"POST\">";
echo "<tr>";
echo "<td>Oracle User Name: </td> <td><input type=\"text\" id=\"userName\" name=\"userName\" class=\"search\"/>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td align=\"center\">";
echo "<input type=\"submit\" id=\"checkUserSessions\" name=\"checkUserSessions\" value=\"Check User Sessions\"/>";
echo "</td>";
echo "</tr>";
echo "</form>";
echo "</tbody>";
echo "<tr>";
echo "<td>";
echo "<div id=\"messageDiv\" class=\"mssgDiv\">";
echo "<md></md>";
echo "</div>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</body>
</html>
";
?>
<?php
session_start();
date_default_timezone_set('EST');
echo "
<!doctype html>
<html>
<head>
<TITLE>jQuery AJAX Autocomplete - Country Example</TITLE>
";
echo '
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/css/autocomplete.css">
<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
';
echo "
<script>
$(document).ready(function () {
$(\"#userName\").autocomplete({
dataType: \"json\",
minLength: 2,
source: \"searchUser.php\",
select: function(event,ui) {
$(\"#userName\").val(ui.item.username);
}
});
});
</script>
";
echo "
<script>
$(function(){
$(document).on('click', \"#checkUserSessions\", function (e) {
var user=$(\"#userName\").val();
e.preventDefault(); $(\"#typeinUserName\").hide();
var inputData=$(\":input\").serializeArray();
$.ajax({
type: \"POST\",
url: \"/oraoperation/showUserActiveSessions.php\",
dataType : 'html',
data: inputData,
success: function(data, textStatus, jQxhr ){
$(\"#contentDiv\").html(data);
},
error: function( jqXhr, textStatus, errorThrown ){
$(\"#typeinUserName\").show();
$(\"#messageDiv\").html(errorThrown);
console.log( errorThrown );
}
});
});
});
</script>
";
echo "
</head>
<body>
";
echo "<table border=0 id=\"outLineTable\" class=\"centretable\" width=\"100%\">";
echo "<tbody id=\"typeinUserName\">";
echo "<tr>";
echo "<td align=\"center\">";
echo "<table border=1 id=\"sessionContentTable\">";
echo "<form id=\"chkDBSessions\" method=\"POST\">";
echo "<tr>";
echo "<td>Oracle User Name: </td> <td><input type=\"text\" id=\"userName\" name=\"userName\" class=\"search\"/>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td align=\"center\">";
echo "<input type=\"submit\" id=\"checkUserSessions\" name=\"checkUserSessions\" value=\"Check User Sessions\"/>";
echo "</td>";
echo "</tr>";
echo "</form>";
echo "</tbody>";
echo "<tr>";
echo "<td>";
echo "<div id=\"messageDiv\" class=\"mssgDiv\">";
echo "<md></md>";
echo "</div>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</body>
</html>
";
?>
Monday, March 6, 2017
PHP and Oracle oci_connect() fails sometimes
In system level, I can connect to database using the wallet name, but sometimes, got below error:
1) PHP Warning: oci_connect(): ORA-12715: invalid character set specified
2) ORA-01017: invalid username/password; logon denied
3) PHP Warning: oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with your system
PHP and Oracle oci_connect() fails sometimes, I tried change Character Set, cannot fix it.
In PHP,
putenv("TNS_ADMIN=/opt/.wallet");
putenv("ORACLE_HOME=/usr/app/oracle/product/11.2.0.3");
putenv("LD_LIBRARY_PATH=/usr/app/oracle/product/11.2.0.3/lib");
$conn = oci_connect("/", "", "WalletName", null, OCI_CRED_EXT);
In /etc/sysconfig/httpd:
export ORACLE_HOME=/usr/app/oracle/product/11.2.0.3
export LD_LIBRARY_PATH=/usr/app/oracle/product/11.2.0.3/lib
export TNS_ADMIN=/opt/.wallet
1) PHP Warning: oci_connect(): ORA-12715: invalid character set specified
2) ORA-01017: invalid username/password; logon denied
3) PHP Warning: oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with your system
PHP and Oracle oci_connect() fails sometimes, I tried change Character Set, cannot fix it.
In PHP,
putenv("TNS_ADMIN=/opt/.wallet");
putenv("ORACLE_HOME=/usr/app/oracle/product/11.2.0.3");
putenv("LD_LIBRARY_PATH=/usr/app/oracle/product/11.2.0.3/lib");
$conn = oci_connect("/", "", "WalletName", null, OCI_CRED_EXT);
In /etc/sysconfig/httpd:
export ORACLE_HOME=/usr/app/oracle/product/11.2.0.3
export LD_LIBRARY_PATH=/usr/app/oracle/product/11.2.0.3/lib
export TNS_ADMIN=/opt/.wallet
Wednesday, February 22, 2017
JQuery and Ajax Serialization for PHP
- serializeArray form serialization for method POST
- serialize form serialization for method POST
PHP to accept GET and POST
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
foreach ($_POST as $key => $value)
eval("\$$key = \"$value\";");
}
else if ($_SERVER['REQUEST_METHOD'] === 'GET')
{
echo "<strong>HTTP GET</strong> <br/><br/>";
echo $_SERVER['QUERY_STRING'];
}
{
foreach ($_POST as $key => $value)
eval("\$$key = \"$value\";");
}
else if ($_SERVER['REQUEST_METHOD'] === 'GET')
{
echo "<strong>HTTP GET</strong> <br/><br/>";
echo $_SERVER['QUERY_STRING'];
}
Subscribe to:
Posts (Atom)