0

Think of simple profile page. User must editing. So, I've created basic php page. But, it is doesn't upload image. Why is it not uploading? I don't understand.

<?php       

if((array_key_exists("degistir",$_GET) && $_GET['degistir'] == "dogru") && (array_key_exists('uyeId',$_GET) && $_GET['uyeId'] == md5(@$_SESSION['uyeGiris_skype'])))
{           
    if(isset($_POST['duzenlemeBitir']))
    {
        $uyeUrl_ = "inc/imj/uye/".$_SESSION['uyeGiris_skype'];
        if(!is_dir($uyeUrl_)){mkdir($uyeUrl_);
    $profilResim = $uyeUrl."/".$FILES['profilResim']['name'];
    move_uploaded_file($_FILES['profilResim']['tmp_name'],$profilResim) or die(mysql_error());
    $galeri = array();

    for($s=1; $s<9; $s++)
    {
        $uyeUrlLink = $uyeUrl_."/".$_FILES['galeri'.$s]['name'];
        $uyeUrlAdi = $_FILES['galeri'.$s]['name'];
        move_uploaded_file($_FILES['galeri'.$s]['tmp_name'],$uyeUrlLink) or die(mysql_error());
        $galeri[$s] = $uyeUrlLink;
    }

    if(!isset($_FILES['profilResim']['value']))
    {
        $_FILES['profilResim']['value'] = $uyeDetay['profilResim'];
    }
    if(!isset($_FILES['galeri1']['value']))
    {
        $_FILES['galeri1']['value'] = $uyeDetay['galeri1'];
    }
    if(!isset($_FILES['galeri2']['value']))
    {
        $_FILES['galeri2']['value'] = $uyeDetay['galeri2'];
    }
    if(!isset($_FILES['galeri3']['value']))
    {
        $_FILES['galeri3']['value'] = $uyeDetay['galeri3'];
    }
    if(!isset($_FILES['galeri4']['value']))
    {
        $_FILES['galeri4']['value'] = $uyeDetay['galeri4'];
    }
    if(!isset($_FILES['galeri5']['value']))
    { 
        $_FILES['galeri5']['value'] = $uyeDetay['galeri5'];
    }
    if(!isset($_FILES['galeri6']['value']))
    {
        $_FILES['galeri6']['value'] = $uyeDetay['galeri6'];
    }
    if(!isset($_FILES['galeri7']['value']))
    {
        $_FILES['galeri7']['value'] = $uyeDetay['galeri7'];
    }
    if(!isset($_FILES['galeri8']['value']))
    {
        $_FILES['galeri8']['value'] = $uyeDetay['galeri8'];
    }
    $ekle = mysql_query("UPDATE uye SET skype='".$_POST['skype']."', msn='".$_POST['msn']."', facebook='".$_POST['facebook']."', yas='".$_POST['yas']."', boy='".$_POST['boy']."', kilo='".$_POST['kilo']."', hakkinda='".$_POST['hakkinda']."', profil_resim='".$profilResim."', galeri_1='".$galeri[1]."', galeri_2='".$galeri[2]."', galeri_3='".$galeri[3]."', galeri_4='".$galeri[4]."', galeri_5='".$galeri[5]."', galeri_6='".$galeri[6]."', galeri_7='".$galeri[7]."', galeri_8='".$galeri[8]."' WHERE e_posta = '".$_SESSION['uyeGiris_ePosta']."' AND sifre='".$_SESSION['uyeGiris_sifre']."'") or die(mysql_error());

}
 }
?>

Notice: This codes have mysql_error() functions but I can't see error the simple profil editing page..

Thank you for your interest. Good works..

Sylca
  • 2,523
  • 4
  • 31
  • 51
fthmad9
  • 51
  • 1
  • 3
  • 12
  • 2
    I'm not even going to bother trying to read your code to work out where your problem is because it's a **mess**. Clean it up, and someone might be more inclined to help you – Bojangles Sep 07 '13 at 16:56
  • Agreed, clean it up and include the relevant HTML form. – Niklas Lindblad Sep 07 '13 at 16:57
  • 1
    **You are leaving yourself wide open to SQL injection attacks.** Also, any input data with single quotes in it, like a name of "O'Malley", will blow up your SQL query. Please learn about using parametrized queries, preferably with the PDO module, to protect your web app. http://bobby-tables.com/php has examples to get you started, and [this question](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) has many examples in detail. – Andy Lester Sep 07 '13 at 17:00
  • I dared to clean this code up and it took my 10 minutes. sigh! – Sahil Mittal Sep 07 '13 at 17:10
  • Just a guess
    Include enctype in your html form.
    – Mihai Sep 07 '13 at 17:18
  • I didn't actually understand the code either, but yes, you DO are prone to SQL injections to start with. What have you tried? are you sure your table fields have the right type? always remember that in most cases it's a good idea to store just your filepaths on your db and retrive the files with them when you need it, it will give you a better performance (not to mention the fact that it's a lot easier to code it) – Gonzalo Acosta Sep 07 '13 at 17:20
  • I added enctype, but don't work.. – fthmad9 Sep 07 '13 at 17:20
  • Now, I look at PDO object, analyzing.. – fthmad9 Sep 07 '13 at 17:31
  • Did you ever see a small new programmers? I don't understand that!! – fthmad9 Sep 07 '13 at 17:45

1 Answers1

0

Clerical error..

$uyeUrl = blabla..

if(!is_dir($uyeUrl_)){mkdir($uyeUrl_);} $profilResim = $uyeUrl_."/".$FILES['profilResim']['name'];

fthmad9
  • 51
  • 1
  • 3
  • 12