Hi I'm having trouble with this. A user uploads an image in page1.php. It's filename inserts to a database and the image goes to a folder named 'uploads' How do you get those images and show it to page2.php?
page 1
if(isset($_FILES['filename'])){
$errors = array();
$file_name = $_FILES['filename']['name'];
$file_size =$_FILES['filename']['size'];
$file_tmp =$_FILES['filename']['tmp_name'];
$file_type=$_FILES['filename']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['filename']['name'])));
$expensions= array("jpeg","jpg","png");
if(in_array($file_ext,$expensions)=== false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 2097152){
$errors[]='File size must be excately 2 MB';
}
//if no error...
if (empty($errors)==true) {
// upload the file...
move_uploaded_file($file_tmp,"uploads/".$file_name);
$servername = "localhost";
$username = "root";
$password = " ";
$dbname = "admin";
// create new record in the database
include ("dbinfo.php");
mysql_query("INSERT INTO payment_form (Tracking, date, ContactNo, totalsent, datesent, filename) VALUES ('$transactionNo', NOW(), '$contactNo', '$totalSent', '$dateSent', '$file_name')") ;
header('Location: paymentform_success.php');
}else{
print_r($errors);
}
}
page 2 has an update records table. I just want the image to show on a cell there. T__T I haven't researched anything that worked for me.Please help
You do the same thing as i have shown you here, you can either use
$_GET
or include a form in your table and use$_POST
. under your verify link you echo the id of each record<a href="verify.php?id=<?php echo $id; ?>">verify link</a>
on the next page you use
$GET
You can try something like this:
first you need to run mysql_query with "SELECT" query, then run a function like mysql_fetch_assoc to get each row and then output the information.
Also, your original code has a SQL injection vulnerability, you have to use mysql_real_escape_string for all values submitted by user, e.g.
UPD To get specific file by tracking id you can use something like this: