/home/mip/public_html_/old_mip/admin/sqladd.php
<?php
session_start();
require_once("common_msg.inc");
require_once("func_all.php");
$db = db_connect();


switch($what){

case 'user':  		 					
							//check_full("users",$max_users);
							
							$duplicate = getdata("select * from users where username='$username'");
							if(!empty($duplicate)) error_message('There is already an existing username like the one you entered.');
							
							if($password1!=$password2) error_message('Passwords entered were not the same.');
		 					else if((strlen($password1)<3) || (strlen($password1)>16)) error_message('Password must be between 3 and 16 characters. Try again.');							
							
							$sql = "INSERT INTO users(username,password,name,access_id) 
							        VALUES ('$username',password('$password1'),'$name','$access_id')"; 
                
      				$result = mysql_query($sql);  
							
							header("Location: manage_user.php");
							
      				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 = "INSERT INTO webjobs
			 	 (position,
			 	 	principal,
					country,
					description,
					requirements,
					salary,
					posting_date,
					closing_date)
					VALUES 
					('$position',
					'$principal',
					'$country',
					'$description',
					'$requirements',
					'$salary',
					'$posting_date',
					'$closing_date')";           									                 
  $result = mysql_query($sql);  
	echo mysql_error();
												
	header("Location: manage_jobs.php");
												
	break;	 



//announcement.
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 = "INSERT INTO announcement
			 	 (title,
			 	 	announcement,
					posting_date,
					closing_date)
					VALUES 
					('$title',
					'$announcement',
					'$posting_date',
					'$closing_date')";           									                 
  $result = mysql_query($sql);  
	echo mysql_error();
												
	header("Location: manage_announcement.php");
												
	break;	 

															
}	
?>