banner_manager.php
<?php
include ("includes/koneksi.php");
//$_REQUEST['simpan'] = isset($_POST['simpan']) ? $_POST['simpan'] : '';
//$_REQUEST['link'] = isset($_POST['link']) ? $_POST['link'] : '';
//$_REQUEST['gambar'] = isset($_POST['gambar']) ? $_POST['gambar'] : '';
//$_REQUEST['id'] = isset($_POST['id']) ? $_POST['id'] : '';
//SIMPAN DATA
if (isset($_REQUEST['simpan'])){
$id = $_REQUEST['id'];
$link = mysql_real_escape_string($_REQUEST['link']);
$gambar = $_REQUEST['gambar'];
}
//Cek apakah ada file yang diupload
if((!empty($_FILES['uploaded_file'])) && ($_FILES['uploaded_file']['error'] == 0)){
//$gambar = uploadPicture('uploaded_file');
$target_path = "Images/";
$target_path = $target_path . basename( $_FILES['uploaded_file']['name']);
$gambar = $target_path;
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploaded_file']['name']).
" has been uploaded";
// I add this to test insert data
//mysql_query("INSERT INTO banner(link, gambar) VALUES('".$link."','".$gambar."')");
} else{
echo "There was an error uploading the file, please try again!";
}
}
if (empty($id)){
$sqlstr = "INSERT INTO banner(link, gambar) VALUES('".$link."','".$gambar."')";
}else{
$sqlstr = "UPDATE banner SET link = '".$link."',gambar = '".$gambar."' WHERE id =".$id;
$result = mysql_query($sqlstr) or die(mysql_error());
$confirmation = ($result)? "Data telah tersimpan.":"Gagal menyimpan data.";
$gambar = "";
$link = "";
$id = "";
}
Notice: Undefined variable: link in C:\xampp\htdocs\php_template2\banner_manager.php on line 48
Notice: Undefined variable: gambar in C:\xampp\htdocs\php_template2\banner_manager.php on line 48
line 48 is: $sqlstr = "INSERT INTO banner(link, gambar) VALUES('".$link."','".$gambar."')";
Why the error appears?