<?php session_start(); ?>
<?php
function showForm($name,$pnum,$pic,$error)
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<link rel="stylesheet" type="text/css" href="style2.css" />
<title>Phonebook</title>
</head>
<body>
<center>
<table class="maintable">
<tr>
<td>
<div class="innerbg">
<BR />
<h1 align="center">Phonebook</h1>
<BR />
</div>
<hr style="border:solid 1px #0FF;" />
<hr style="border:solid 1px #0FF;"/>
</table>
<br />
<table class="innerbg">
<tr>
<td>
<form action="" method="post" enctype="multipart/form-date">
<div>
<table>
<tr>
<td>
<strong>Name: </strong><td> <input type="text" name="name" value="<?php echo $name; ?>" />
<tr><td>
<strong>Number: </strong><td> <input type="text" name="pnum" value="<?php echo $pnum; ?>" />
<tr><td>
<input type="hidden" name="MAX_FILE_SIZE" value="512000" />
Picture:
<td><br/><br/> <input name="pic" type="file" value="<?php echo $pic; ?>" /><br>
<br/>
<input type="submit" name="submit" value="Submit">
<a href="index.php"><input type="button" value="Back to Home pg."></a>
</div>
</form>
</table>
<div class="infobox" style="position:fixed;top:200px;left:60px;width:180px;">
<?php
if ($error != '')
{
echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
}
?>
</table>
<br />
</center>
</body>
</html>
<?php
}
include('connectdb.php');
if (isset($_POST['submit']))
{
$pic = mysql_real_escape_string(htmlspecialchars($_POST['pic']));
$name = mysql_real_escape_string(htmlspecialchars($_POST['name']));
$pnum = mysql_real_escape_string(htmlspecialchars($_POST['pnum']));
$uploaddir = 'ufiles/';
$uploadfile = $uploaddir . basename($_FILES['pic']['name']);
echo "<p>";
move_uploaded_file($_FILES['pic']['tmp_name'], $uploadfile);
if ($name == '' || $pnum == '' || $pic =='')
{
// $error = 'ERROR: Please fill in all required fields!';
showForm($name, $pnum, $pic,$error);
}
else
{
mysql_query("INSERT phonebook SET pic='$pic',name='$name',pnum='$pnum'")
or die(mysql_error());
echo '<br><br><br><br><br><br><br><center>The Record has been successfully added</center>';
echo '<center><a href="index.php">Go back to Home page</a></center>';
}
}
else
{
showForm('','','','');
}
?>
<link rel="stylesheet" href="style2.css" />
My problem is after adding a new Record
it contains
Name:
Number:
Picture:
i successfully saved the image to my folder but the funny thing is
the name and the number + the picture 'location' is not saved to my Database and to my website View Record page or the Edit and so on where u can see the records that has been entered.

New Topic/Question
Reply




MultiQuote










|