Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

insert image (jpeg) and update data at the same time

Codes here !

Moderators: macek, egami, gesf

insert image (jpeg) and update data at the same time

Postby syntaxerror286 » Thu Oct 11, 2012 8:07 pm

Hi. I want to upload image and update data at the same time. But the result show "No image selected/uploaded". Is my code have a problem? Below is my code. Thank you for your help...

Pengesahan.php

<?php
session_start();
include('connection.php');
//include('security_pemohon.php');
//include('session_pemohon1.php');

$no_kp_pemohon = $_SESSION['no_kp_pemohon'];

$query = "SELECT * FROM pra_diploma_data WHERE no_kp_pemohon = '$no_kp_pemohon'";
$result = mysql_query($query)or die(mysql_error());
$rows = mysql_fetch_array($result);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Semakan Permohonan</title>
<style type="text/css">
<!--
.style1 {font-family: Tahoma}
.style3 {font-family: Tahoma; font-size: 12px; }
.style4 {
font-family: Tahoma;
font-size: 18px;
}
-->
</style>
</head>

<body>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="pengesahan_update.php">
<table width="702" border="0" align="center">
<tr>
<td width="696"><div align="center"><img src="images/logo-uthm.jpg" width="148" height="149" /></div></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><div align="center" class="style4">PENGESAHAN PENERIMAAN TAWARAN</div></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><div align="center" class="style4"><strong>PERMOHONAN PROGRAM PERSEDIAAN DIPLOMA 2013</strong></div></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><table width="578" border="0" align="center">
<tr>
<td width="156"><span class="style3">Nama Penuh</span></td>
<td width="412"><span class="style3">: <?php echo $rows['nama_penuh']; ?></span></td>
</tr>
<tr>
<td><span class="style3">No. Kad Pengenalan</span></td>
<td><span class="style3">: <?php echo $rows['no_kp_pemohon']; ?></span></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><span class="style3">Pilihan Pakej</span></td>
<td><span class="style3">: <?php echo $rows['pakej_pengajian'];?></span></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><span class="style3">Muat naik Bukti Pembayaran</span></td>
<input type="hidden" name="MAX_FILE_SIZE" value="350000" />
<td bgcolor="#FFFFFF">:<input name="MAX_FILE_SIZE" value="102400" type="hidden">
<input name="image" accept="image/jpeg" type="file"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input name="button" type="submit" class="style3" id="button" value="HANTAR" /></td>
</tr>
</table></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
</form>
<p>&nbsp;</p>
</body>
</html>


pengesahan_update.php
<?php include('connection.php');

session_start();

$no_kp_pemohon = $_SESSION["no_kp_pemohon"];

if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) {

// Temporary file name stored on the server
$tmpName = $_FILES['image']['tmp_name'];

// Read the file
$fp = fopen($tmpName, 'r');
$data = fread($fp, filesize($tmpName));
$data = addslashes($data);
fclose($fp);

$query = "UPDATE pra_diploma_data SET image='$image' WHERE no_kp_pemohon = '$no_kp_pemohon'";
$result=mysql_query($query)or die(mysql_error());

// Print results
print "Thank you, your file has been uploaded.";

}
else {
print "No image selected/uploaded";
}


?>
syntaxerror286
New php-forum User
New php-forum User
 
Posts: 7
Joined: Wed Apr 11, 2012 11:50 pm

Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron