Cod: Selectaţi tot
<?php
//********************* valideaza campurile din formularul student
function valideaza_formular_foto($editare = false) {
$errors = array();
if(! $editare) {
if(img_existent_foto($_POST['img']))
{ $errors[] = 'IMG deja existent. Va rugam verificati';}
}
function valideaza_formular_video($editare = false) {
$errors = array();
if(! $editare) {
if(img_existent_video($_POST['img'])&& ($_POST['video']))
{ $errors[] = 'IMG deja existent. Va rugam verificati';}
}
//********* verifica numele sa fie in formatul corect
if(empty($_POST['img']))
{ $errors[] = 'campul img nu este completat corect';}
return $errors;
}
function img_existent_foto($img) {
global $connection;
$query = "SELECT img FROM foto_bd WHERE img = '$img'";
$result_set = run_query($query);
return(mysql_num_rows($result_set) >0) ? true: false;
}
//********* verifica numele sa fie in formatul corect
if(empty($_POST['img'])&& ($_POST['video']))
{ $errors[] = 'campul img si video nu este completat corect';}
return $errors;
}
function img_existent_video($img, $video) {
global $connection;
$query = "SELECT img, video FROM video_bd WHERE img = '$img'";
$result_set = run_query($query);
return(mysql_num_rows($result_set) >0) ? true: false;
}
?>
Cod: Selectaţi tot
<?php
function confirm_query($query) {
if(!$query) {
die("Eroare " . mysql_error());
}
}
function run_query($query) {
global $connection;
$result_set = mysql_query($query);
confirm_query($result_set);
return $result_set;
}
function mysql_prep($value) {
$magic_quotes_active = get_magic_quotes_gpc();
$new_enough_php = function_exists('mysql_real_escape_string');
if ($new_enough_php) {
if ($magic_quotes_active){
$value = stripslashes($value);
}
$value = mysql_real_escape_string($value);
}
else {
$value = addslashes($value);
}
return $value;
}
?>
Cod: Selectaţi tot
if(isset($_POST['submit'])) {
$errors = valideaza_formular_foto();
if(empty($errors)) {
//******* pregateste valorile sa fie bagate in BD
$img = mysql_prep($_POST['img']);
//******* baga in BD
$query = "INSERT INTO foto_bd (img) VALUES ('{$img}')";
$result_set = mysql_query($query);
confirm_query($result_set);...
Cod: Selectaţi tot
if(isset($_POST['submit'])) {
$errors = valideaza_formular_video();
if(empty($errors)) {
//******* pregateste valorile sa fie bagate in BD
$img = mysql_prep($_POST['img']);
$video = mysql_prep($_POST['video']);
//******* baga in BD
$query = "INSERT INTO video_bd (img, video) VALUES ('{$img}', '{$video}')";....
si nu stiu de ce nu merge si VIDEO.