iomit Posted May 23, 2017 Share Posted May 23, 2017 here is my php code $conn=new PDO('mysql:host=xxx; dbname=xxx', 'xxxx', '') or die(mysql_error()); if(isset($_POST['submit'])!=""){ $title = $_POST['title'];// file title $date = $_POST['date'];// file date $ref = $_POST['ref'];// file ref $from_to = $_POST['from_to'];// person incharge $details = $_POST['details'];// details $location = $_POST['location'];// file location $status = $_POST['status'];// file status $name=$_FILES['photo']['name']; $size=$_FILES['photo']['size']; $type=$_FILES['photo']['type']; $temp=$_FILES['photo']['tmp_name']; move_uploaded_file($temp,"upload/".$name); $query=$conn->query("INSERT INTO upload(title, date, ref, from_to, details, location, status, name)VALUES('$title', '$date', '$ref', '$from_to', '$details', '$location', '$status', $name)"); if($query){ header("location:index.php"); } else{ die(mysqli_error()); } } ?> and here my html form. hope someone will help me. <form enctype="multipart/form-data" action="" name="form" method="post"> <table class="table table-bordered table-responsive"> <tr> <td><label class="control-label">Title</label></td> <td><input class="form-control" type="text" name="title" placeholder="Title" required /></td> </tr> <tr> <td><label class="control-label">Date</label></td> <td><input class="form-control" type="date" name="date" placeholder="Date" required /></td> </tr> <tr> <td><label class="control-label">Ref Num</label></td> <td><input class="form-control" type="text" name="ref" placeholder="Ref Num" required /></td> </tr> <tr> <td><label class="control-label">Person Incharge</label></td> <td><input class="form-control" type="text" name="from_to" placeholder="Person Incharge" required /></td> </tr> <td><label class="control-label">Details</label></td> <td><textarea class="form-control" name="details" placeholder="Details" required ></textarea> </td> </tr> <td><label class="control-label">Location</label></td> <td><p><select name="location" required > <option value="Local A">Local A</option> <option value="Local B">Local B</option> <option value="Local C">Local C</option> </select></p></td> </tr> <td><label class="control-label">Status</label></td> <td><p><select name="status" required > <option value="Active">Active</option> <option value="Semi-Active">Semi-Active</option> <option value="Inactive">Inactive</option> </select></p></td> </tr> <tr> <td colspan="2"> Select File <input type="file" name="photo" id="photo" required /> <input type="submit" name="submit" id="submit" value="Submit" /> </td> </tr> </table> </form> Link to comment Share on other sites More sharing options...
Jacques1 Posted May 23, 2017 Share Posted May 23, 2017 You're using three(!) incompatible database APIs at the same time, and none of them correctly. How could this possibly work? Choose one, preferrably PDO, and learn how to use it. Link to comment Share on other sites More sharing options...
benanamen Posted May 23, 2017 Share Posted May 23, 2017 Additionally, depending on the name of a button to be submitted will completely fail in certain circumstances. You need to check the REQUEST METHOD. if ($_SERVER['REQUEST_METHOD'] == 'POST') Don't create variables for nothing Stop outputting internal system errors to the user. That information is only good to hackers. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.