Mam problem z jednym z formularzy. Problem tkwi w tym że wysyła sie ona po kilka razy - do bazy danych dodaje się więcej rekordów niż powinno. Czasami po 2-3 a nie 1 jak powinno być.
Kod:
<?php require("connection.php"); connection(); $username = ($_POST['username']); $status = $_POST['status']; $url = $_POST['url']; $data = $_POST['data']; $zapytanie = "INSERT INTO `mproof` VALUES(' ','$username','$status','$url','$data')"; $dir = "./proof/"; //Change this to the correct dir RELATIVE TO WHERE THIS SCRIPT IS, or /full/path/ //MIME types to allow, Gif, jpeg, zip ::Edit this to your liking $types = array("image/png","image/x-png","image/gif","image/jpeg","image/pjpeg","image/jpg","image/bmp"); // Nothing to edit below here. //Function to do a directory listing function CPGscandir($dirstr) { } //Check to determine if the submit button has been pressed //Shorten Variables $tmp_name = $_FILES['upload']['tmp_name']; $new_name = $rand.$_FILES['upload']['name']; $path = $_POST['subdir']; $fullpath = "$dir$path/"; $clean_name = ereg_replace("[^a-z0-9._]", "", str_replace(" ", "_", str_replace("%20", "_", strtolower($new_name) ) ) ); // lets see if we are uploading a file or doing a dir listing scandir("$fullpath"); }else{ //Check MIME Type // create a sub-directory if required } //Move file from tmp dir to new location }else{ //Print Error Message echo "<small>File <strong><em>{$_FILES['upload']['name']}</em></strong> Was Not Uploaded - bad file type or file already exists</small><br />"; //Debug $name = $_FILES['upload']['name']; $type = $_FILES['upload']['type']; $size = $_FILES['upload']['size']; $tmp = $_FILES['upload']['name']; } } } else { } ?> <br /> <div id="TOS"> <form action="" method="post" enctype="multipart/form-data"> Please upload your payment proof it will help us to grow faster and make our website even more reliable.<br /><br /><br /> <input type="hidden" name="username" value="<?=$_SESSION['login']?>"/> <input type="hidden" name="status" value="Approved"/> <input type="hidden" name="url" value="Test"/> <input type="file" name="upload" /> <br /><br /> <input type="submit" name="submit" value="Upload" /> </form> </div>
Kolejnym problemem jest to że nie przesyła się informacja z pola username, zawsze używałem tej samej metody tzn.
i wszystko się pięknie przesyłało. Czy może mieć na to wpływ rodzaj formularza ?
<?=$_SESSION['login']?>