0

im using basic isset/form php filelike this:

if (isset($_POST['submitproduct']) ){ 
if (isset($_FILES['imageupload'])){  *some code* ..}

 <form method="POST" action="addproduct.php" enctype="multipart/form-data">
    <label>productname</label><br/>
    <input type="text" name="name"><br/>
    <input name="imageupload" type="file" id="image" placeholder="imageupload" />
    <input type="submit" name="submitproduct">
</form>

so i think this fairly normal routine, the form submits, it gets the data and adds it to sql database, no errors here, but after he is finished with the php script the browser for some reason doesnt skip isset($_POST['submitproduct'] like it was submited again for some reason, which obv throws error in the following code since no variables are set? I have coded similiar scripts like this base on if isset $_POST but this is the first time i got this error, only difference is, its my first time using encytpe. I tried to put header(location) to exit the script after it finish, but he just ignores it, im really clueless about this behavoiour , can anyone help?

Moorli
  • 29
  • 1
  • 5
  • What does the `logged()` function do? – Jorge Campos Jun 11 '17 at 20:53
  • Use session token to prevent CSRF attacks and multiple submit form. https://stackoverflow.com/questions/4614052/how-to-prevent-multiple-form-submission-on-multiple-clicks-in-php – MahdiY Jun 11 '17 at 20:58
  • @JorgeCampos I think it check control access for users – MahdiY Jun 11 '17 at 20:59
  • it just checks if a session variable isset, i did remove it to simplify the code – Moorli Jun 11 '17 at 20:59
  • i have several scripts who work on the same basis (login/register/addusers etc..) but this is the only one with a file upload. Can you confirm that the code as it is shouldnt trigger again after the first submit? – Moorli Jun 11 '17 at 21:02
  • this is addproduct.php ? could you post the whole code? – Shahaf Antwarg Jun 11 '17 at 21:17
  • i solved the problem, tried to access undefined variable inside the script which i forgot to delete... didnt defer him to succesfully finish the script for some reason, but made him do to rerun the script without post data again O_o – Moorli Jun 11 '17 at 21:25

1 Answers1

0

i solved the problem, tried to access undefined variable inside the script which i forgot to delete... didnt defer him to succesfully finish the script for some reason, but made him do to rerun the script without post data again O_o

Moorli
  • 29
  • 1
  • 5