Hello everybody.
Got a problem at inserting data to database. i.e when i m using the pdo script with
a php script having session. the data is not inserted. but data insertion executes
successfully while i use that PDO script individually.
you may view the link http://www.codeofaninja.com/2013/05/...hp-jquery.html
which i followed. Now my
language.php contains :
Code:
<?php
session_start();
error_reporting(E_ALL | E_STRICT);
/*****************************************************************************
/*****************************************************************************/
include_once('includes/queryfunctions.php');
include_once('includes/functions.php');
$conn=mysql_connect(HOST . ":" . PORT , USER, PASS);
if (!$conn) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db(DB);
//check if user is logged in
SignedIn();
//check if user has clicked on logout button
if(isset($_POST["submit"]) && $_POST["submit"]=='Logout') LogOut();
if(isset($_GET["search"]) && !empty($_GET["search"])){
//have this as a search function
$id=$_GET["search"];
$_POST["submit"]=$_GET["action"];
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>language</title>
<link rel="stylesheet" type="text/css" href="css/internal.css"/><link href="css/main.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="css/epoch_styles.css"/>
<?php headericon(); ?>
</head>
<body bgcolor="#FFFFFF">
<form action="language.php" method="post" name="language" id="language" enctype="multipart/form-data">
<div align="center">
<table width="92%">
<tr>
<td colspan="3" align="right"><?php mainheader(); ?></td>
</tr>
<tr align="center">
<th colspan="3" align="right"><img src="images/head.png" width="100%" height="95px" /></th>
</tr>
<tr>
<th><?php loginheader(); ?></th>
<th colspan="2"><?php profileheader(); ?></th>
</tr>
<tr>
<td width="20%" valign="top" align="left"><?php leftmenu(); ?></td>
<td colspan="2" valign="top" align="left"><table border="0" width="100%">
<tr>
<th colspan="3" bgcolor="#CCCCCC"><strong>LANGUAGE</strong></th>
</tr>
<tr>
<td colspan="2"><em>Currently no data exist! Please click on the following button to add language information.</em></td>
</tr>
<tr>
<td colspan="3" bgcolor="#fff">
<div style='margin:0 0 .5em 0;'>
<!-- when clicked, it will load the add user form -->
<div id='addLanguage' class='customBtn'>Add New</div>
<!-- when clicked, it will show the user's list -->
<div id='viewLanguages' class='customBtn'>View Existing</div>
<!-- this is the loader image, hidden at first -->
<div id='loaderImage'><img src='images/ajax-loader.gif' /></div>
<div style='clear:both;'></div>
</div>
<!-- this is wher the contents will be shown. -->
<div id='pageContent'></div>
<script src='js/jquery-1.9.1.min.js'></script>
<script type='text/javascript'>
$(document).ready(function(){
// VIEW USERS on load of the page
$('#loaderImage').show();
showUsers();
// clicking the 'VIEW USERS' button
$('#viewLanguages').click(function(){
// show a loader img
$('#loaderImage').show();
showUsers();
});
// clicking the '+ NEW USER' button
$('#addLanguage').click(function(){
showCreateUserForm();
});
// clicking the EDIT button
$(document).on('click', '.editBtn', function(){
var user_id = $(this).closest('td').find('.userId').text();
console.log(user_id);
// show a loader image
$('#loaderImage').show();
setTimeout("$('#pageContent').load('update_form.php?user_id=" + user_id + "', function(){ $('#loaderImage').hide(); });",1000);
});
// when clicking the DELETE button
$(document).on('click', '.deleteBtn', function(){
if(confirm('Are you sure?')){
// get the id
var user_id = $(this).closest('td').find('.userId').text();
// trigger the delete file
$.post("delete.php", { id: user_id })
.done(function(data) {
// you can see your console to verify if record was deleted
console.log(data);
$('#loaderImage').show();
// reload the list
showUsers();
});
}
});
// CREATE FORM IS SUBMITTED
$(document).on('submit', '#addLanguageForm', function() {
// show a loader img
$('#loaderImage').show();
// post the data from the form
$.post("create_lang.php", $(this).serialize())
.done(function(data) {
// 'data' is the text returned, you can do any conditions based on that
showUsers();
});
return false;
});
// UPDATE FORM IS SUBMITTED
$(document).on('submit', '#updateUserForm', function() {
// show a loader img
$('#loaderImage').show();
// post the data from the form
$.post("update.php", $(this).serialize())
.done(function(data) {
// 'data' is the text returned, you can do any conditions based on that
showUsers();
});
return false;
});
});
// READ USERS
function showUsers(){
setTimeout("$('#pageContent').load('read.php', function(){ $('#loaderImage').hide(); });", 1000);
}
// CREATE USER FORM
function showCreateUserForm(){
// show a loader image
$('#loaderImage').show();
setTimeout("$('#pageContent').load('create_form_lang.php', function(){ $('#loaderImage').hide(); });",1000);
}
</script>
</td>
</tr>
</table></td>
<tr><td height="26" colspan="3" align="center"><?php footer(); ?></td></tr>
</table>
</div>
</form>
</body>
</html>
Bookmarks