-3

I'll try to be as specific as possible, but it is quite hard, since I don't have a clue on what going on. So when I insert values into my "input", and hit the submit button, my php pages goes to a php register page (since my input uses "post"), then sent back again with javascript:

<script> window.open("Addmovie.php?tittel=","_self") </script>

But when it gets sent back my pages goes to the same "URL" but it displayed a nearly blank page, with only the Norwegian word for "hi", my Input gets registered, but if I refresh the page, even with shift+f5 it still doesn't show anything. If I go to another page on my website, and then go back again, I can see that my Input got registered. I assume the "Hi" part comes from my provider when nothing shows seeing as I have encountered this message before in unrelated ways.

My input on the site/how it supposed to look

enter image description here

the page I get back to, after I hit submit

enter image description here

Where I really get confused, is that I have been able to input values to my database before, it is just now I get blank back. I could post my code, but I don't know what part to post.

The input file regarding the registerlooks like this:

<html>
<head>
</head>
<body>
  <h3>Add a movie</h3>
    <form action="movieregister.php" method="post" enctype="multipart/form-data">
    <p>
        <label>Title: </label><input type="text" name="tittel">
    </p>
    <p>
        <label>Year: </label><input type="text" name="aar">
    </p>
    <p>
        <label>Genre: </label><input type="text" name="genre">
    </p>
    <p>
        <label>Description: </label>
        <br><textarea rows="5" <input type="text" name="plot"></textarea>
    </p>
    <p>Select image to upload:
        <input type="file" name="fileToUpload" id="fileToUpload">
    </p>
    <input type="submit">
</form>
</body>
</html>

My register:

<?php
 else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)||$tittel==""||$aar==""||$genre==""||$plot=="") {
        $db=mysqli_connect("$host","$user","$database","$password","$port");
    $sql="INSERT INTO gruppe3_film (tittel, aar, genre, plot)  VALUES ('$tittel','$aar','$genre','$plot')";
    $result=mysqli_query($db,$sql);
    echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been    uploaded.";
   } else {
       echo "Sorry, there was an error uploading your file.";
   }
}
$db->close()
?>
 <script>
     window.open("Addmovie.php?tittel=","_self")
 </script>

Please ask away if you want/need some information. Thanks for any answers in advance.

Tomas Berger
  • 173
  • 1
  • 3
  • 15
  • so where do php and html come into the picture? and you speak of a database but no code to support the question. All I can say here is...... check for errors. – Funk Forty Niner May 19 '16 at 12:32
  • White screen of death anyone? http://stackoverflow.com/questions/1475297/phps-white-screen-of-death – CD001 May 19 '16 at 12:36

1 Answers1

0

I fixed the problem by removing

<script>
    window.open("Addmovie.php?tittel=","_self")
</script>

and instead I went to the top of the page and used a header

 header("Refresh:5; url=AddMovie.php?tittel=");

This fixed the problem, though I still don't know why the "script" caused it. or if it was the command it self

Tomas Berger
  • 173
  • 1
  • 3
  • 15