Click here to Skip to main content
15,887,405 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Notice: Undefined index: img in C:\wamp\www\Criminal Record System\officer_reg.php on line 16
/////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\
var_dump Information Bellow::

array
  'img' => string 'my passport.jpg' (length=15)

//////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
PHP
 16  $_FILES['img']['tmp_name'];
 17  move_uploaded_file($_FILES['img']['tmp_name'],"upload/".$_FILES['img']['name']);
 18  $img = $_FILES['img']['tmp_name'];
 19  
 20  $con = new PDO("mysql:host=localhost; dbname=crime;","root","");
 21  $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 22  $sql = "insert into imagetbl (img) 
 23  values(:img)";
 24  $stmt = $con->prepare($sql);
 25  $stmt->bindParam('img',$img);


What I have tried:

I'm trying to register user image into database stored the image on my folder call upload
Posted
Updated 9-Aug-20 23:52pm
v2
Comments
Richard MacCutchan 10-Aug-20 3:05am    
Where is line 16, and what is the value or values of the index in question?
Ibrahim Hassan 1234 10-Aug-20 3:48am    
this is line 16 sir, $_FILES['img']['tmp_name'];
this is line 17 sir, move_uploaded_file($_FILES['img']['tmp_name'],"upload/".$_FILES['img']['name']);
this is line 18 sir, $img = $_FILES['img']['tmp_name'];
because all the lines are indicated by compiler show 'undefined index'
thanks.
Richard MacCutchan 10-Aug-20 3:58am    
OK, so either img or tmp_name, or both, do not contain valid data. You need to find out why.
Ibrahim Hassan 1234 10-Aug-20 4:10am    
ok sir thank you so much for your concern is know that i found the reason why it show such error message and frankly spaeking its so funny.
I Forgot to put 'enctype="multipart/form-data"'
I'm Really appreciate for ur concern

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900