U
U
user12132018-03-29 04:57:40
PHP
user1213, 2018-03-29 04:57:40

How to make it so that when you click on the chrome back button, a page opens from which there was a transition to the page with the add form?

There is a form on the page with adding pictures and data. When you click on the send button, the picture and data are added, but when you click on the chrome back button, a page appears with the fields filled in according to the data sent, and so such fields appear in the sequence in which the pictures were added. How to do so that when you click on the chrome back button, the page opens from which there was a transition to the page with the add form, and why does this not happen? I work with Denver. If you make a separate file to add data to the database with redirection back to the file with the form, the same thing happens, but in firefox in this case it works as it should, but if everything is in one file, then it doesn’t work in firefox as it should.

<html>
<head>
<link rel="stylesheet" type="text/css" href="form.css">

</head>
<body>
<div class="menu">

<header>

<ul>
<li><a href="cod.php?category=tea"><p>tea</p></a>
<li><a href="cod.php?category=coffee"><p>coffe</p></a>
</ul>
</header>


</div>
<div class="wrap">
<form name="form1" method="post" action=""
enctype="multipart/form-data">
 <input type="text" name="given_name" size="12">
<p><select size="1"  name="category">
    
    <option value="tea">tea</option>
    <option  value="coffee">coffee</option>
   
   </select></p>
 <p><input type="file" name="file" />
   <input type="submit" value="Отправить"></p>
</form>
</div>
<?php
$host = 'localhost'; // адрес сервера 
$database = 'imagess'; // имя базы данных
$user = 'admin'; // имя пользователя
$password = '12345'; // пароль
$link = mysqli_connect($host, $user, $password, $database) 
    or die("Ошибка " . mysqli_error($link));
  
  
$given_name=$_POST[given_name];
$category=$_POST[category];

if(substr($_FILES['file']['type'], 0, 5)=='image')
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    
 
    if (file_exists('upload/'.$_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
     move_uploaded_file($_FILES["file"]["tmp_name"],
      'upload/'.basename($_FILES["file"]["name"]));
      $image=('upload/'.$_FILES["file"]["name"]);
    $imageProperties = getimageSize('upload/'.($_FILES["file"]["name"]));
      }
    }
  }



  

//...
// Используя ранее определенную функцию get_image присваиваем
// переменным содержимое файлов

$name=$_FILES["file"]["name"];
if ($image == ''){
  unset($image);
}
// ...
// 

if (isset($image)){
  
  
  $result = mysqli_query ($link,
    "Insert INTO imagess (img,imageType,category, name, showname) 
    VALUES ('".$image."','".$imageProperties['mime']."','".$category."','".$name."','".$given_name."') ");
    
  
  
   mysqli_error;
}
mysqli_close($link);
?>
</body>
</html>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sanovskiy, 2018-03-29
@Sanovskiy

One of the golden questions :)
header('Location: '.$_SERVER['HTTP_REFERER']);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question