/create_form_lang.php Secret
Last active
December 18, 2015 21:39
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
-we have our html form here where user information will be entered | |
-we used the 'required' html5 property to prevent empty fields | |
--> | |
<?php //include_once('includes/functions.php');?> | |
<form id='addLanguageForm' action='#' method='post' border='0'> | |
<table width="100%"> | |
<tr> | |
<td width="26%">Employee ID</td> | |
<td width="74%"><input type="text" name="employeeid" id="employeeid" required /></td> | |
</tr> | |
<tr> | |
<td width="26%">Language</td> | |
<td width="74%"><select name="language" id="language"> | |
<option value="">--Select Language--</option> | |
<option value="Bangoli">Bangoli</option> | |
<option value="English">English</option> | |
</select> | |
</td> | |
</tr> | |
<tr> | |
<td width="26%">Read</td> | |
<td width="74%"> | |
<label> | |
<input type="radio" name="readlevel" value="Beginner"> | |
Beginner</label> | |
<label> | |
<input type="radio" name="readlevel" value="Intermediate"> | |
Intermediate | |
</label> | |
<label> | |
<input type="radio" name="readlevel" value="Advanced (Fluent)"> | |
Advanced (Fluent) | |
</label> | |
</td> | |
</tr> | |
<td></td> | |
<td> | |
<input type='submit' value='Save' class='customBtn' /> | |
</td> | |
</tr> | |
</table> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//include database connection | |
session_start(); | |
//include_once('includes/queryfunctions.php'); | |
include 'libs/db_connect.php'; | |
try{ | |
//write query | |
$query = "INSERT INTO language SET applicantid = ?, employeeid = ?, language = ?, readlevel = ? "; | |
//prepare query for excecution | |
$stmt = $con->prepare($query); | |
//bind the parameters | |
//this is the first question mark | |
$stmt->bindParam(1, $_SESSION["userid"]); | |
//this is the second question mark | |
$stmt->bindParam(2, $_POST["employeeid"]); | |
//this is the third question mark | |
$stmt->bindParam(3, $_POST["language"]); | |
//this is the fourth question mark | |
$stmt->bindParam(4, $_POST["readlevel"]); | |
// Execute the query | |
if($stmt->execute()){ | |
echo "Language inserted Successfully."; | |
}else{ | |
echo "Unable to Language insertion ."; | |
} | |
} | |
//to handle error | |
catch(PDOException $exception){ | |
echo "Error: " . $exception->getMessage(); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$host = "hostname"; | |
$db_name = "databasename"; | |
$username = "username"; | |
$password = ""; | |
try { | |
$con = new PDO("mysql:host={$host};dbname={$db_name}", $username, $password); | |
}catch(PDOException $exception){ //to handle connection error | |
echo "Connection error: " . $exception->getMessage(); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include_once ("queryfunctions.php"); | |
error_reporting(E_ALL & ~E_NOTICE); | |
function populate_select($table,$fields_id,$fields_value,$selected){ | |
$conn=db_connect(HOST,USER,PASS,DB,PORT); | |
$sql="Select $fields_id,$fields_value From $table Order By $fields_value"; | |
$results=query($sql,$conn); | |
while ($row = fetch_object($results)){ | |
$SelectedField=($row->$fields_id==$selected) ? " selected" : ""; | |
echo "<option value='" . $row->$fields_id ."'". $SelectedField . ">" . $row->$fields_value . "</option>"; | |
} | |
free_result($results); | |
} | |
//same as populate_select but has option of passing a sql statement | |
function Lookup($fields_id='',$fields_value='',$selected,$sql){ | |
$conn=db_connect(HOST,USER,PASS,DB,PORT); | |
$results=query($sql,$conn); | |
while ($row = fetch_object($results)){ | |
$SelectedField=($row->$fields_id==$selected) ? " selected" : ""; | |
echo "<option value=" . $row->$fields_id . $SelectedField . ">" . $row->$fields_value . "</option>"; | |
} | |
free_result($results); | |
} | |
function SignedIn() | |
{ | |
if (!isset($_SESSION["userid"])) die("<center><font color=red>You have not yet Logged in.<a href=login.php>Please click here to log in.</a></font><center>"); | |
} | |
function LogOut() | |
{ | |
$iappid=0; | |
$_SESSION = array(); | |
session_destroy(); | |
echo "<center><font color=\"#0033CC\"><b>Session successful ended.</b></font></center>"; | |
echo "<meta http-equiv=\"Refresh\" content=\"2;url=./index.php\">"; //put index.php | |
} | |
function loginheader1(){ | |
$user = $_SESSION["user"]; | |
if(isset($_SESSION["userid"])){ | |
echo "<center><a href=\"index_login.php\">Home</a>:: | |
<a href=\"myprofile.php\">My Profile</a>::"; | |
// echo "<a href=\"vacancies.php\">Vacancies</a>"; | |
} | |
if(isset($_SESSION["userid"])) echo "<br><img src=\"images/s_loggoff.png\" width=\"16\" height=\"16\">"; | |
echo "<input type=\"submit\" name=\"submit\" value=\""; | |
echo isset($_SESSION["userid"]) ? "Logout" : "Login"; echo "\"><b>$user<b></center>"; | |
} | |
function headericon(){ | |
echo "<link REL=\"shortcut icon\" HREF=\"favicon.ico\"/>"; | |
echo "<link REL=\"icon\" HREF=\"favicon.ico\"/>"; | |
} | |
function profileheader(){ | |
echo "<table border=\"0\" align=\"left\"> | |
<tr>"; | |
if ($_SESSION["usercategory"]=='A'){ | |
echo "<!--<th scope=\"col\"><a href=\"myjobs.php\">My Taifa Jobs</a> ::</th>--> | |
<!--<th scope=\"col\"><a href=\"cvbuilder.php\">Build/Edit My CV</a> ::</th>-->"; | |
} | |
if ($_SESSION["usercategory"]=='D'){ | |
echo "<th scope=\"col\"><a href=\"users.php\">Users</a> ::</th>"; | |
} | |
echo "<!--<th scope=\"col\"><a href=\"history.php\">History</a> ::</th> | |
<th scope=\"col\"><a href=\"account.php\">Account</a> ::</th> | |
<th scope=\"col\"><a href=\"mymessages.php\">Message Board</a></th> | |
</tr>--> | |
</table>"; | |
} | |
function leftmenu(){ | |
$user = $_SESSION["user"]; | |
if(isset($_SESSION["userid"])){ | |
switch ($_SESSION["usercategory"]){ | |
case 'A': | |
//if applicant is logged in display this menu | |
echo "<table border=\"0\" valign=\"top\" width=\"100%\"> | |
<tr><td><a href=\"personaldata.php?search=$_SESSION[userid]\">Personal Information</a></td></tr> | |
<tr><td><a href=\"language.php\">Language Information</a></td></tr> | |
<tr><td><a href=\"education.php\">Educational Qualification</a></td></tr> | |
<tr><td><a href=\"training.php\">Training</a></td></tr> | |
<tr><td><a href=\"profexp.php\">Additional Professional Qualification</a></td></tr> | |
<tr><td><a href=\"service.php\">Service Information</a></td></tr> | |
<tr><td><a href=\"magisterial_power.php\">Vesting Of Magisterial Power</a></td></tr> | |
<tr><td><a href=\"foreign.php\">Foreign Travel</a></td></tr> | |
<tr><td><a href=\"leaves.php\">Leave(except CL) Particulars</a></td></tr> | |
<tr><td><a href=\"promotion.php\">Promotion Particulars</a></td></tr> | |
<tr><td><a href=\"posting.php\">Posting Information</a></td></tr> | |
<tr><td><a href=\"honours.php\">Honours And Award</a></td></tr> | |
<tr><td><a href=\"discipline.php\">Disciplinary Actions/ Criminal Prosecution</a></td></tr> | |
<!-- <tr><td><a href=\"careerobjective.php\">Career Objective</a></td></tr> | |
<tr><td><a href=\"qualsumm.php\">Summary of Qualifications</a></td></tr> | |
<tr><td><a href=\"viewcv.php\" target=\"_blank\">Preview my CV</a></td> <tr><td><a href=\"reference.php\">Reference</a></td></tr> | |
</tr> | |
<tr><td><a href=\"profmem.php\">Professional Memberships</a></td></tr> | |
--> <tr><td><a href=\"photo2.php\">Photo</a></td></tr> | |
<tr><td><a href=\"status.php\">Status</a></td></tr> | |
<tr><td> </td></tr>"; | |
if ($_SESSION["admin"]==1) echo "<tr><td><b>Admin options</b></td></tr><tr><td><a href=\"users.php\">Users</td></tr>"; | |
echo "</table>"; | |
break; | |
case 'E': | |
//if employer is logged in display this menu | |
echo "<table border=\"0\" valign=\"top\" width=\"100%\"> | |
<tr><td><a href=\"employer.php?search=$_SESSION[userid]\">Employers Data</a></td></tr> | |
<tr><td><a href=\"jobs.php\">Post jobs</a></td></tr> | |
<tr><td><a href=\"applicants.php\">Applicants</a></td></tr> | |
<tr><td><a href=\"jobslist.php\">Job Lists</a></td></tr> | |
<tr><td> </td></tr>"; | |
if ($_SESSION["admin"]==1) echo "<tr><td><b>Admin options</b></td></tr><tr><td><a href=\"users.php\">Users</td></tr>"; | |
echo "</table>"; | |
break; | |
case 'D': | |
//if employer is logged in display this menu | |
echo "<table border=\"0\" valign=\"top\" width=\"100%\"> | |
<tr><td><b>Admin options</b></td></tr> | |
<tr><td><a href=\"users.php\">Manage Users</td></tr> | |
<!-- <tr><td><a href=\"jobslist.php\">Job Lists</td></tr> | |
--> <tr><td> </td></tr> | |
</table>"; | |
break; | |
} | |
} | |
} | |
function mainheader(){ | |
echo "<a href=\"index.php\"> HOME</a> <!--| <a href=\"vacancies.php\">VACANCIES</a>-->"; | |
} | |
function loginheader(){ | |
if(isset($_SESSION["userid"])) echo "<a href=\"status.php\">My profile</a> | <a href=\"login.php?submit=Logout\">Logout</a><br> | |
You are logged as - $_SESSION[user]"; | |
} | |
function GetUser(){ | |
// checks if the username is in use | |
if (!get_magic_quotes_gpc()) { | |
$_POST['loginname'] = addslashes($_POST['loginname']); | |
} | |
$check = mysql_query("SELECT loginname,email FROM users WHERE loginname = '$usercheck'") | |
or die(mysql_error()); | |
$check2 = mysql_num_rows($check); | |
//if the name exists loginname exists | |
if ($check2 !== 0) { | |
$msg = "<center><font color=\"#0033CC\"><b>Sorry, the loginname ".$_POST['loginname']." is already in use.</b></font></center>"; | |
return($msg); | |
} | |
// this makes sure both passwords entered match | |
if ($_POST['pass'] !== $_POST['confpass']) { | |
$msg = '<center><font color=\"#0033CC\"><b>Your passwords did not match.</b></font></center>'; | |
return($msg); | |
} | |
} | |
function navigationtop(){ | |
global $rowsPerPage,$pageNum,$offset; | |
$rowsPerPage = 20; // how many rows to show per page | |
$pageNum = 1; // by default we show first page | |
// if $_GET['page'] defined, use it as page number | |
if(isset($_GET['page'])) | |
{ | |
$pageNum = $_GET['page']; | |
} | |
$offset = ($pageNum - 1) * $rowsPerPage; // counting the offset | |
} | |
function navigationbottom(){ | |
global $conn,$rowsPerPage,$pageNum; | |
// how many rows we have in database | |
$query = "SELECT COUNT(sharesid) AS numrows FROM coop_shares"; | |
$result = query($query,$conn) or die('Error, query failed'); | |
$row = fetch_array($result, MYSQL_ASSOC); | |
$numrows = $row['numrows']; | |
// how many pages we have when using paging? | |
$maxPage = ceil($numrows/$rowsPerPage); | |
$self = $_SERVER['PHP_SELF']; | |
// creating 'previous' and 'next' link | |
// plus 'first page' and 'last page' link | |
// print 'previous' link only if we're not | |
// on page one | |
if ($pageNum > 1) | |
{ | |
$page = $pageNum - 1; | |
$prev = " <a href=\"$self?page=$page\"><img src=\"images/prev.gif\" width=\"16\" height=\"16\" border=\"0\"></a> "; | |
$first = " <a href=\"$self?page=1\"><img src=\"images/first.gif\" width=\"16\" height=\"16\" border=0></a> "; | |
} | |
else | |
{ | |
$prev = ' <img src="images/prevdisab.gif" width="16" height="16"> '; // we're on page one, don't enable 'previous' link | |
$first = ' <img src="images/firstdisab.gif" width="16" height="16"> '; // nor 'first page' link | |
} | |
// print 'next' link only if we're not | |
// on the last page | |
if ($pageNum < $maxPage) | |
{ | |
$page = $pageNum + 1; | |
$next = " <a href=\"$self?page=$page\"><img src=\"images/next.gif\" width=\"16\" height=\"16\" border=0></a> "; | |
$last = " <a href=\"$self?page=$maxPage\"><img src=\"images/last.gif\" width=\"16\" height=\"16\" border=0></a> "; | |
} | |
else | |
{ | |
$next = ' <img src="images/nextdisab.gif" width="16" height="16"> '; // we're on the last page, don't enable 'next' link | |
$last = ' <img src="images/lastdisab.gif" width="16" height="16"> '; // nor 'last page' link | |
} | |
// print the page navigation link | |
echo $first . $prev . " Showing page <strong>$pageNum</strong> of <strong>$maxPage</strong> pages " . $next . $last; | |
} | |
function footer(){ | |
echo "Copyright © ". date("Y"); | |
} | |
function StatusComplete($file){ | |
$conn=db_connect(HOST,USER,PASS,DB,PORT); | |
/* Creates SQL statement to retrieve the copies using the releaseID */ | |
$sql = "SELECT id FROM $file WHERE applicantid =$_SESSION[userid]"; | |
$rows=query($sql,$conn); | |
$numrows = num_rows($rows); | |
if($numrows>0) echo "<img src=\"images/check-r.gif\">"; | |
else echo "<img src=\"images/check-w.gif\">"; | |
free_result($rows); | |
} | |
function delete_copy(){ | |
/* makes connection */ | |
$conn=db_connect(HOST,USER,PASS,DB,PORT); | |
/* Creates SQL statement to retrieve the copies using the releaseID */ | |
$sql = "DELETE FROM $file WHERE $recordid =" . $_POST['ID']; | |
$results=query($sql,$conn); | |
$msg[0]="Sorry ERROR in deletion"; | |
$msg[1]="Record successful DELETED"; | |
AddSuccess($results,$conn,$msg); | |
/* Closes connection */ | |
mysql_close ($conn); | |
/* calls get_data */ | |
//get_data(); | |
}; | |
function num_format($number, $digits) { | |
return str_replace(",","",number_format($number,$digits)); | |
}; | |
function AddSuccess($results,&$conn,$msg){ | |
if ((int) $results==0){ | |
//should log mysql errors to a file instead of displaying them to the user | |
echo 'Invalid query: ' . mysql_errno($conn). "<br>" . ": " . mysql_error($conn). "<br>"; | |
echo "<div align=\"center\"><h1>$msg[0]</h1></div>"; | |
}else{ | |
echo "<div align=\"center\"><h1>$msg[1]</h1></div>"; | |
} | |
} | |
function dateconvert($date,$func){ | |
if ($func == 1){ //insert conversion | |
list($day, $month, $year) = preg_split("/[\/.-]/", $date); | |
$year=trim($year); | |
$date = "$year-$month-$day"; | |
return $date; | |
} | |
if ($func == 2){ //output conversion | |
list($year, $month, $day) = preg_split("/[-.]/", $date); | |
if(trim($date)!=='') $date = "$day/$month/$year"; | |
return $date; | |
} | |
} | |
//make this into a search script | |
function GetFieldsValue($sql){ | |
$conn=db_connect(HOST,USER,PASS,DB,PORT); | |
$results=query($sql,$conn); | |
if($results) $mem = fetch_object($results); | |
return($mem->id); | |
} | |
//sendmail | |
function sendemail($commentinfo,$support_email='',$bcc='',$notify_owner_email,$subject) | |
{ | |
$text= $commentinfo; | |
$text=stripslashes($text); | |
$emailm=$text; | |
$headers = "From: $support_email\n"; | |
$headers .= "Return-Path: <$support_email>\n"; | |
$headers .= "X-Sender: <$support_email>\n"; | |
$headers .= "X-Mailer: PHP\n"; //mailer | |
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Medium | |
$headers .= "Bcc: $bcc\r\n"; | |
$smptserver = ini_set ( "SMTP", "mail.supremecluster.com" ); | |
ini_set ( "smtp_port", "25" ); | |
ini_get ("SMTP"); | |
mail("$notify_owner_email",$subject,$emailm,$headers); | |
} | |
//To have a report function | |
function vacancies($where=''){ | |
$conn=db_connect(HOST,USER,PASS,DB,PORT); | |
$querystr="SELECT job.jobid,job.employerid,job.jobcategory,job.employeetype,job.city,job.countryid,job.jobtitle, | |
job.summary,job.requirements,job.dateposted,job.dateclosing,job.pay,countries.country,employer.organization | |
FROM job | |
Left Join countries ON job.countryid = countries.countryid | |
Left Join employer ON job.employerid = employer.employerid | |
$where"; | |
$results=query($querystr,$conn); | |
$today = getdate(); | |
//check if data is returned | |
echo "<table width=\"90%\" border=\"0\">"; | |
echo "<tr><th colspan=\"9\">Vacancy List</th></tr>"; | |
while ($jobs = fetch_object($results)){ | |
//alternate row colour | |
$j++; | |
if($j%2==1){ | |
echo "<tr id=\"row$j\" onmouseover=\"javascript:setColor('$j')\" onmouseout=\"javascript:origColor('$j')\" bgcolor=\"#CCCCCC\">"; | |
}else{ | |
echo "<tr id=\"row$j\" onmouseover=\"javascript:setColor('$j')\" onmouseout=\"javascript:origColor('$j')\" bgcolor=\"#EEEEF8\">"; | |
} | |
echo "<td align=\"left\"><h4>$jobs->jobtitle</h4></td></tr>"; | |
echo "<tr><td align=\"left\">$jobs->summary...</td></tr>"; | |
echo "<tr><td align=\"left\"> | |
<span class=\"boldtext\">Organization Name:-</span> $jobs->organization | | |
<span class=\"boldtext\">Country:-</span> $jobs->country | | |
<span class=\"boldtext\">Job Type:-</span> $jobs->employeetype | | |
<span class=\"boldtext\">Date posted:-</span> $jobs->dateposted | | |
<span class=\"boldtext\">Closing date:</span> $jobs->dateclosing | |
</td></tr>"; | |
echo "<tr><td align=\"left\"><a href=\"jobdetails.php?jobid=$jobs->jobid\" target=\"_blank\">More Detail/Apply</a></td></tr>"; | |
} | |
echo "</table>"; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Table structure for table `language` | |
-- | |
CREATE TABLE `language` ( | |
`id` int(11) NOT NULL auto_increment, | |
`applicantid` int(11) NOT NULL, | |
`employeeid` int(11) default NULL, | |
`language` varchar(255) default NULL, | |
`orallevel` varchar(20) default NULL, | |
`readlevel` varchar(20) default NULL, | |
`writtenlevel` varchar(20) default NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ; | |
-- | |
-- Dumping data for table `language` | |
-- | |
INSERT INTO `language` (`id`, `applicantid`, `employeeid`, `language`, `orallevel`, `readlevel`, `writtenlevel`) VALUES | |
(19, 1, 123, 'English', NULL, 'Beginner', NULL), | |
(3, 14, NULL, 'Bangoli', 'Advanced (Fluent)', '', 'Advanced (Fluent)'), | |
(4, 26, NULL, 'English', 'Advanced (Fluent)', '', 'Advanced (Fluent)'), | |
(5, 27, NULL, 'Bangoli', 'Advanced (Fluent)', '', 'Advanced (Fluent)'), | |
(20, 1, 456, 'English', NULL, 'Advanced (Fluent)', NULL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//session_start(); | |
require_once("config.php"); | |
error_reporting(E_ALL | E_STRICT); | |
function db_connect($HOST,$USER,$PASS,$DB) | |
{ | |
$conn = mysql_connect($HOST, $USER, $PASS); | |
mysql_select_db($DB); | |
return $conn; | |
} | |
//close a connection | |
function db_close($conn) | |
{ | |
mysql_close($conn); | |
} | |
function query($strsql,$conn) | |
{ | |
$rs = mysql_query($strsql,$conn); | |
return $rs; | |
} | |
function num_rows($rs) | |
{ | |
return @mysql_num_rows($rs); | |
} | |
function fetch_array($rs) | |
{ | |
return mysql_fetch_array($rs); | |
} | |
function fetch_object($rs) | |
{ | |
return mysql_fetch_object($rs); | |
} | |
function free_result($rs) | |
{ | |
@mysql_free_result($rs); | |
} | |
function data_seek($rs,$cnt) | |
{ | |
@mysql_data_seek($rs, $cnt); | |
} | |
function error() | |
{ | |
return mysql_error(); | |
} | |
?> | |
<?php | |
define("HOST", "hostname"); | |
define("USER", "username"); | |
define("PASS", ""); | |
define("DB", "databasename"); | |
/* define("smptserver",'smtpserver'); | |
define("supportemail",'emailadress'); | |
define("bcc",'emailaddress'); | |
*/?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//include database connection | |
include 'libs/db_connect.php'; | |
try{ | |
//include_once('includes/functions2.php'); | |
//write query | |
//in this case, it seemed like we have so many fields to pass and | |
//its kinda better if we'll label them and not use question marks | |
//like what we used here | |
$query = "update | |
language | |
set | |
employeeid = :employeeid, | |
language = :language, | |
readlevel = :readlevel | |
where | |
id = :id"; | |
//prepare query for excecution | |
$stmt = $con->prepare($query); | |
//bind the parameters | |
$stmt->bindParam(':employeeid', $_POST['employeeid']); | |
$stmt->bindParam(':language', $_POST['language']); | |
$stmt->bindParam(':readlevel', $_POST['readlevel']); | |
$stmt->bindParam(':id', $_POST['id']); | |
// Execute the query | |
if($stmt->execute()){ | |
echo "Language was updated."; | |
}else{ | |
echo "Unable to update language."; | |
} | |
} | |
//to handle error | |
catch(PDOException $exception){ | |
echo "Error: " . $exception->getMessage(); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
try { | |
include 'libs/db_connect.php'; | |
// include 'includes/queryfunctions.php'; | |
// include_once('includes/functions2.php'); | |
//prepare query | |
$query = "select | |
id, employeeid, language, readlevel | |
from | |
language | |
where | |
id = ? | |
limit 0,1"; | |
$stmt = $con->prepare( $query ); | |
//this is the first question mark | |
$stmt->bindParam(1, $_REQUEST['user_id']); | |
//execute our query | |
if($stmt->execute()){ | |
//store retrieved row to a variable | |
$row = $stmt->fetch(PDO::FETCH_ASSOC); | |
//values to fill up our form | |
$id = $row['id']; | |
$employeeid = $row['employeeid']; | |
$language = $row['language']; | |
$readlevel = $row['readlevel']; | |
}else{ | |
echo "Unable to read record."; | |
} | |
} | |
//to handle error | |
catch(PDOException $exception){ | |
echo "Error: " . $exception->getMessage(); | |
} | |
?> | |
<!--we have our html form here where new user information will be entered--> | |
<form id='updateUserForm' action='#' method='post' border='0'> | |
<table width="100%"> | |
<tr> | |
<td width="26%">Employee ID</td> | |
<td width="74%"><input name="employeeid" type="text" id="employeeid" value="<?php echo $employeeid; ?>"/></td> | |
</tr> | |
<tr> | |
<td width="26%">Language</td> | |
<td width="74%"> <select name="language" id="language"> | |
<option value="">--Select Language--</option> | |
<option value="Bangla" <?php if($language=='Bangoli') echo 'selected'?>>Bangla</option> | |
<option value="English" <?php if($language=='English') echo 'selected'?>>English</option> | |
</select> | |
</td> | |
</tr> | |
<tr> | |
<td width="26%">Read</td> | |
<td width="74%"> | |
<label> | |
<input type="radio" name="readlevel" value="Beginner" <?php if($readlevel=='Beginner') echo 'checked'?>> | |
Beginner</label> | |
<label> | |
<input type="radio" name="readlevel" value="Intermediate" <?php if($readlevel=='Intermediate') echo 'checked'?>> | |
Intermediate | |
</label> | |
<label> | |
<input type="radio" name="readlevel" value="Advanced (Fluent)" <?php if($readlevel=='Advanced (Fluent)') echo 'checked'?>> | |
Advanced (Fluent) | |
</label> | |
</td> | |
</tr> | |
<td></td> | |
<td> | |
<!-- so that we could identify what record is to be updated --> | |
<input type="hidden" name="id" value=<?php echo $id; ?>> | |
<input type='submit' value='Update' class='customBtn' /> | |
</td> | |
</tr> | |
</table> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Table structure for table `users` | |
-- | |
CREATE TABLE `users` ( | |
`userid` int(11) NOT NULL auto_increment, | |
`name` varchar(60) default NULL, | |
`loginname` varchar(15) NOT NULL default '', | |
`pass` varchar(32) NOT NULL default '', | |
`email` varchar(65) NOT NULL, | |
`dateregistered` date default NULL, | |
`admin` tinyint(1) default '0', | |
`status` char(1) default NULL COMMENT 'Active,Locked,Disabled', | |
`usercategory` char(1) default NULL COMMENT 'A= applicant, D= admin, E= employer', | |
PRIMARY KEY (`userid`,`loginname`,`email`), | |
UNIQUE KEY `userid` (`userid`), | |
UNIQUE KEY `loginname` (`loginname`), | |
UNIQUE KEY `email` (`email`) | |
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='InnoDB free: 121856 kB; InnoDB free: 121856 kB; InnoDB free:' AUTO_INCREMENT=28 ; | |
-- | |
-- Dumping data for table `users` | |
-- | |
INSERT INTO `users` (`userid`, `name`, `loginname`, `pass`, `email`, `dateregistered`, `admin`, `status`, `usercategory`) VALUES | |
(1, NULL, 'megha', '123', 'megha@ymail.com', '2013-03-04', 0, 'A', 'A'), | |
(2, NULL, 'hasan', '123', 'hasan@ab.com', '2013-03-04', 0, NULL, 'A'), | |
(7, NULL, 'ya', '123', 'ya@gh.com', '2013-03-12', 0, NULL, 'A'), | |
(6, NULL, 'mou', '123', 'mou@fmail.com', '2013-03-06', 0, NULL, 'A'), | |
(5, 'ab', 'ab', '123', '', NULL, 0, NULL, 'D'), | |
(8, NULL, 'jia', '123', 'jia@yahoo.com', '2013-03-27', 0, NULL, 'A'), | |
(9, 'nai', 'test_adm', '123', 'test_adm@gm.com', '2013-03-27', 0, NULL, 'E'), | |
(10, NULL, 'lima', '123', 'lima@gm.com', '2013-03-31', 0, NULL, 'A'), | |
(11, NULL, 'mou_12', '123', 'mou@m.com', '2013-03-31', 0, NULL, 'E'), | |
(12, NULL, 'himu', '123', 'himu@gm.com', '2013-03-31', 0, NULL, 'A'), | |
(13, NULL, 'neha', '123', 'neha@yahoo.com', '2013-04-03', 0, NULL, 'A'), | |
(14, NULL, 'lia', '123', 'lia@yahoo.com', '2013-04-03', 0, NULL, 'A'), | |
(15, NULL, 'tom', '123', 'tom@yahoof.com', '2013-04-03', 0, NULL, 'E'), | |
(18, 'dia', 'dia', '123', 'dia@yahoof.com', '2013-04-03', 0, NULL, 'A'), | |
(20, 'Sadia Jahan', 'Sadia', '123', 'sadia@gm.com', '2013-04-07', 0, NULL, 'A'), | |
(21, 'newusr', 'new', '123', 'new@new.com', '2013-04-07', 0, NULL, 'A'), | |
(22, 'quality', 'quality', '123', 'quality@qual.com', '2013-04-08', 0, NULL, 'A'), | |
(23, 'hello', 'hello', '123', 'hello@yahoof.com', '2013-04-08', 0, NULL, 'A'), | |
(24, 'nilufa', 'nilu', '123', 'nilu@yahoof.com', '2013-04-08', 0, NULL, 'A'), | |
(25, 'jinat', 'jinat', '123', 'jinat@yahoof.com', '2013-04-08', 0, NULL, 'A'), | |
(26, 'vista', 'vista', '123', 'vista@vis.com', '2013-04-08', 0, NULL, 'A'), | |
(27, 'testFinal', 'final', '123', 'test_final@gm.com', '2013-04-09', 0, NULL, 'A'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The files are included here.