common.php (este fichero se incluye al formulario para acceder a la bbdd y contiene las funciones de la web)
Código PHP:
Ver original//insertamos los datos del form [$_POST]
$computer_capabilities = $_POST["computer_capabilities"];
$organization_capabilities = $_POST["organization_capabilities"];
$social_capabilities = $_POST["social_capabilities"];
$other_capabilities = $_POST["other_capabilities"];
$technical_capabilities = $_POST["technical_capabilities"];
$artistic_capabilities = $_POST["artistic_capabilities"];
$other_info = $_POST["other_info"];
//$cvi_cvitaeable_type = $_POST["cvi_cvitaeable_type"];
$education_title = $_POST["education_title"];
$center_name = $_POST["center_name"];
$education_capacities = $_POST["education_capacities"];
$education_starts_at = $_POST["education_starts_at"];
$education_ends_at = $_POST["education_ends_at"];
$center_type = $_POST["center_type"];
$company_sector = $_POST["company_sector"];
$company_address = $_POST["company_address"];
$functions = $_POST["functions"];
$position = $_POST["position"];
$starts_at = $_POST["starts_at"];
$ends_at = $_POST["ends_at"];
$company_name = $_POST["company_name"];
$course_center = $_POST["course_center"];
$course_hours = $_POST["course_hours"];
$course_year = $_POST["course_year"];
$course_capacities = $_POST["course_capacities"];
$course_name = $_POST["course_name"];
$language = $_POST["language"];
$speaking = $_POST["speaking"];
$reading = $_POST["reading"];
$talking = $_POST["talking"];
$writing = $_POST["writing"];
$listening = $_POST["listening"];
$hobby_name = $_POST["hobby_name"];
$user_id = $_POST["user_id"];
}
//Aqui incluyo los parametros para hacer la conexion con la BBDD
function CviCvitae($computer_capabilities,$organization_capabilities, $social_capabilities, $other_capabilities, $technical_capabilities, $artistic_capabilities, $other_info, $user_id){
$queryCviCvitae = mysql_query("SELECT * FROM CviCvitae WHERE user_id = '$user_id'"); $id_1 = $row_CviCvitae['id'];
//echo $row_CviCvitae['user_id'];
//printf("Registros actualizados: %d\n", mysql_affected_rows());
$ejecuCviCvitae = "UPDATE CviCvitae SET computer_capabilities = '$computer_capabilities', organization_capabilities = '$organization_capabilities', social_capabilities = '$social_capabilities', other_capabilities = '$other_capabilities', technical_capabilities = '$technical_capabilities', artistic_capabilities = '$artistic_capabilities', other_info = '$other_info' WHERE user_id = '$user_id' AND id = '$id_1'";
//printf("Registros actualizados: %d\n", mysql_affected_rows());
} else {
$ejecuCviCvitae = "INSERT INTO CviCvitae (computer_capabilities, organization_capabilities, social_capabilities, other_capabilities, technical_capabilities, artistic_capabilities, other_info, user_id) VALUES ('$computer_capabilities', '$organization_capabilities', '$social_capabilities', '$other_capabilities', '$technical_capabilities', '$artistic_capabilities', '$other_info', '$user_id')" ;
//printf("Registros actualizados: %d\n", mysql_affected_rows());
}
}
function CviEducation($education_title, $center_name, $education_capacities, $education_starts_at, $education_ends_at, $center_type, $user_id){
//ordenamos las fechas $education_starts_at - $education_ends_at
$arr = explode('-', $education_starts_at); $new_education_starts_at = $arr[2].'-'.$arr[1].'-'.$arr[0]; $brr = explode('-', $education_ends_at); $new_education_ends_at = $brr[2].'-'.$brr[1].'-'.$brr[0];
$queryCviEducation = mysql_query("SELECT * FROM CviEducation WHERE user_id = '$user_id'");
$id_2 = $row_CviEducation['id'];
$ejecuCviEducation = "UPDATE CviEducation SET education_title = '$education_title', center_name = '$center_name', education_capacities = '$education_capacities', education_starts_at = '$new_education_starts_at', education_ends_at = '$new_education_ends_at', center_type = '$center_type' WHERE user_id = '$user_id' AND id = '$id_2'";
} else {
$ejecuCviEducation = "INSERT INTO CviEducation (education_title, center_name, education_capacities, education_starts_at, education_ends_at, center_type, user_id) VALUES ('$education_title', '$center_name', '$education_capacities', '$new_education_starts_at', '$new_education_ends_at', '$center_type', '$user_id')";
}
}
function CviExperience($company_sector, $company_address, $starts_at, $functions, $position, $ends_at, $company_name, $user_id){
//ordenamos las fechas $starts_at - $ends_at
$crr = explode('-', $starts_at); $new_starts_at = $crr[2].'-'.$crr[1].'-'.$crr[0]; $urr = explode('-', $ends_at); $new_ends_at = $urr[2].'-'.$urr[1].'-'.$urr[0];
$queryCviExperience = mysql_query("SELECT * FROM CviExperience WHERE user_id = '$user_id'");
$id_3 = $row_CviExperience['id'];
$ejecuCviExperience = mysql_query("UPDATE CviExperience SET company_sector = '$company_sector', company_address = '$company_address', starts_at = '$new_starts_at', functions = '$functions', position = '$position', ends_at = '$new_ends_at', company_name = '$company_name' WHERE user_id = '$user_id' AND id = '$id_3'"); } else {
$ejecuCviExperience = mysql_query("INSERT INTO CviExperience (company_sector, company_address, starts_at, functions, position, ends_at, company_name, user_id) VALUES ('$company_sector', '$company_address', '$new_starts_at', '$functions', '$position', '$new_ends_at', '$company_name', '$user_id')"); }
}
function CviCourse($course_center, $course_hours, $course_year, $course_capacities, $course_name, $user_id){
$queryCviCourse = mysql_query("SELECT * FROM CviCourse WHERE user_id = '$user_id'");
$id_4 = $row_CviCourse['id'];
$ejecuCviCourse = mysql_query("UPDATE CviCourse SET course_center = '$course_center', course_hours = '$course_hours', course_year = '$course_year', course_capacities = '$course_capacities', course_name = '$course_name' WHERE user_id = '$user_id' AND id = '$id_4'"); } else {
$ejecuCviCourse = mysql_query("INSERT INTO CviCourse (course_center, course_hours, course_year, course_capacities, course_name, user_id) VALUES('$course_center','$course_hours','$course_year','$course_capacities','$course_name', '$user_id')"); }
}
function CviCvitaeLanguage($language, $speaking, $reading, $talking, $writing, $listening, $user_id){
$queryCviCvitaeLanguage = mysql_query("SELECT * FROM CviCvitaeLanguage WHERE user_id = '$user_id'");
$id_5 = $row_CviCvitaeLanguage['id'];
$ejecuCviCvitaeLanguage = mysql_query("UPDATE CviCvitaeLanguage SET language = '$language', speaking = '$speaking', reading = '$reading', talking= '$talking', writing = '$writing', listening = '$listening' WHERE user_id = '$user_id' AND id = '$id_5'"); } else {
$ejecuCviCvitaeLanguage = mysql_query("INSERT INTO CviCvitaeLanguage (language, speaking, reading, talking, writing, listening, user_id) VALUES ('$language', '$speaking', '$reading', '$talking', '$writing', '$listening', '$user_id')"); }
}
function CviHobby($hobby_name, $user_id){
$queryCviHobby = mysql_query("SELECT * FROM CviHobby WHERE user_id = '$user_id'");
$id_6 = $row_CviHobby['id'];
$ejecuCviHobby = mysql_query("UPDATE CviHobby SET hobby_name = '$hobby_name' WHERE user_id = '$user_id' AND id = '$id_6'"); } else {
$ejecuCviHobby = mysql_query("INSERT INTO CviHobby ( hobby_name, user_id) VALUES ('$hobby_name', '$user_id')"); }
}