M
M
MrMim2020-05-24 16:03:38
PHP
MrMim, 2020-05-24 16:03:38

Error 500, what's wrong?

there is a code

<?php

include '../../rb/db.php';

if ($_SESSION['login'] == '') {
    header("Location: /");
    exit();
}

$login2 = $_SESSION['login'];
$sqlsearchusr = mysqli_query($link, "SELECT * FROM `users` WHERE `login` = '$login2'");
$usrdate = mysqli_fetch_array($sqlsearchusr);

?>

<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AMICI | Добавить Фотографию</title>
    <link rel="stylesheet" type="text/css" href="style.css">
  /* тут css стиль */
    
</head>
<body>
   <div class="body"> 
        <nav class="menu_a">
            <h1 class="menu_TEXT-a">AMICI</h1>
            <div class="dropdown aaa">
  <button class="dropbtn"><?php 

  $login1 = $_SESSION['login'];
  $sqk = mysqli_query($link, "SELECT * FROM `users` WHERE `login` = '$login1'");
  $sqkq = mysqli_fetch_array($sqk);
  $name1 = $sqkq['name'];

  echo $name1;

  ?></button><?php if($usrdate['photoavatar'] != ''){?><a href="/profile/addphoto/"><img src="../../imgprofile/<?php echo $usrdate['photoavatar'];?>" class="imglittle"></a><?php } else { ?><a href="/profile/addphoto/"><button class="addphoto" title="Добавить Фотографию">+</button></a> <?php }?> <div id="myDropdown" class="dropdown-content">
    <a href="" class="upright">Скоро</a>
    <center class="white"><hr class="dropdownq"></center>
    <a href="">Скоро</a>
    <center class="white"><hr class="dropdownq"></center>
    <a href="">Скоро</a>
    <center class="white"><hr class="dropdownq"></center>
    <a href="../../logout.php" class="downrad">Выйти</a>
  </div>
</div>
        </nav> 
            <aside class="menu-side">
                <a href="../../feed/"><li class="top"><!--Главная-->Скоро</li></a>
                <a href="../../profile/"><li>Профиль</li></a>
                <a href="../../im/"><li>Сообщения</li></a>
                <a href="..//"><li><!--Друзья-->Скоро</li></a>
                <a href="..//"><li class="bottom"><!--Группы-->Скоро</li></a>
            </aside> 
    </div>
    <center><div class="inputfoto">
        <h3><?php if($usrdate['photoavatar'] == ''){echo 'Загрузить';}else{echo 'Изменить';}?> фото профиля</h3>
        <?php if($usrdate['photoavatar'] != '') {?>
            <img src="../../imgprofile/<?php echo $usrdate['photoavatar'];?>" class="avatar-see">
        <?php }?>
        <form action="/profile/addphoto/" method="POST" enctype="multipart/form-data"><br><?php if($usrdate['photoavatar'] == ''){ ?>
            <input type="file" name="picture" class="inpfile"><br><br>
            <button name="sendphoto">Сохранить</button><br><br>
        <?php }?>
            <?php if($usrdate['photoavatar'] != '') {?>
            <button name="deleteimg">Удалить</button>
            <?}?>
        </form>
                <?php if (isset($_POST['sendphoto'])) {
 // Пути загрузки файлов
$path = '../../imgprofile/';
$tmp_path = '../../tmp/';
// Массив допустимых значений типа файла
$types = array('image/png', 'image/jpeg');
// Максимальный размер файла
$size = 1024000;
 
// Обработка запроса
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
 // Проверяем тип файла
 if (!in_array($_FILES['picture']['type'], $types))
 die('<p style="color:white; margin-bottom:0px;">Запрещённый тип файла. Попробуйте другой файл</p>');
 
 // Проверяем размер файла
 if ($_FILES['picture']['size'] > $size)
 die('<p style="color:white; margin-bottom:0px;">Слишком большой размер файла. Попробуйте другой файл</p>');
 
 // Загрузка файла и вывод сообщения
 if ([email protected]($_FILES['picture']['tmp_name'], $path . $_FILES['picture']['name']))
 $error = 'ошибка, извините, попробуйте позже';
 else
 $imgname = $path . $_FILES['picture']['name'];
 $login = $_SESSION['login'];
 mysqli_query($link, "UPDATE `users` SET `photoavatar` = '$imgname' WHERE `login` = '$login'");
 require_once 'refresh.php';
}
}?>

<?php if(isset($_POST['deleteimg'])){
            mysqli_query($link, "UPDATE `users` SET `photoavatar` = '' WHERE `login` = '$login1'");
            require_once 'refresh.php';
        }?>
    </div></center>
</body>
</html>


what could be?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
galaxy, 2020-05-24
@galaxy

what could be?

Anything. Please show me the logs.

T
ThunderCat, 2020-05-24
@ThunderCat

Firstly - a nightmarish mess of code and html.
Secondly - 500 error is a "general" error for everything that crashed fatally, but the settings do not allow displaying a specific error. That is - either look at the logs (which is more suitable for production), or set up error output and set the E_ALL level, then errors will fall out immediately into the browser and it will be clear what and where has fallen, and why.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question