/home/mip/public_html_/old_mip/admin/sqlupdate.php
<?php
session_start();
require_once("common_msg.inc");
require_once("func_all.php");
$db = db_connect();
switch($what){
case 'user':
if($password1 || $password2){
if($password1!=$password2) error_message('Passwords entered were not the same.');
if(strlen($password1)<3 || strlen($password1)>16) error_message('Password must be between 3 to 16 characters.');
$sql_pwd = "password=password('$password1'),";
}
$duplicate = getdata("select * from users where username='$username' and user_id!=$user_id");
if(!empty($duplicate)) error_message('There is already an existing username like the one you entered.');
$sql = "UPDATE users SET username='$username',
$sql_pwd
name='$name',
access_id='$access_id'
WHERE user_id=$user_id ";
$result = mysql_query($sql);
if($result) header("Location: manage_user.php?msg=Updated");
else header("Location: manage_user.php?msg=Error Updating");
break;
case 'other_user':
if($oldpassword){
$testname = getdata("select * from users where password = PASSWORD('$oldpassword') and user_id='$user_id'");
if($testname){
if($password1!=$password2) error_message('New Password and Re-type Password were not the same.');
if(strlen($password1)<3 || strlen($password1)>16) error_message('New Password must be between 3 to 16 characters.');
$sql_password = ",password=password('$password1')";
}
else error_message('Invalid Old Password.Try again.');
}
$sql = "UPDATE users SET username='$valid_user'
$sql_password
WHERE user_id=$user_id ";
$result = mysql_query($sql);
echo mysql_error();
if($result){
header("Location: edit_password.php?user_id=$user_id&msg=Updated");
}
else{
header("Location: edit_password.php?user_id=$user_id&msg=Error in Update");
}
break;
case 'webjob':
$posting_date = format_to_sqldate($post_year,$post_month,$post_day);
$closing_date = format_to_sqldate($close_year,$close_month,$close_day);
$sql = "UPDATE webjobs SET
position='$position',
principal='$principal',
country='$country',
description='$description',
requirements='$requirements',
salary='$salary',
posting_date='$posting_date',
closing_date='$closing_date'
WHERE webjobid=$webjobid";
$result = mysql_query($sql);
echo mysql_error();
header("Location: manage_jobs.php");
break;
case 'announcement':
$posting_date = format_to_sqldate($post_year,$post_month,$post_day);
$closing_date = format_to_sqldate($close_year,$close_month,$close_day);
$sql = "UPDATE announcement SET
title='$title',announcement='$announcement',
posting_date='$posting_date',
closing_date='$closing_date'
WHERE event_id=$event_id";
$result = mysql_query($sql);
echo mysql_error();
header("Location: manage_announcement.php");
break;
case "config" :
$sql = "update config set
email_employer='$email_employer',
email_job='$email_job',
email_comment='$email_comment'
";
$result = mysql_query($sql);
echo mysql_error();
mysql_close();
if($result) header("Location: edit_config.php?statok=1");
break;
}
?>