Click to See Complete Forum and Search --> : add member page and file upload on same page


william232
08-13-2006, 05:51 AM
am trying to create a script or part of a script where the admin user can enter in information and put a an image and what i want it so it displays the file name of the image in the database how can i do that another thing is when i go to add member stuff into the database it doesnt seem to add it in to the table members this is my code


<?php
$today=date("F j,Y,g:i a");
error_reporting(E_ALL);
?>
<body>
<fieldset>
<legend>Add Member</legend>
<table width="352" border="1">
<form name="" enctype="multipart/form-data" method="post" action="">
<tr>
<th width="118" scope="col">Full Name</th>
<th width="218" scope="col"><input type="text" name="fname"></th>
</tr>
<tr>
<th scope="row">Age</th>
<td><input type="text" name="age" maxlength="2"></td>
</tr>
<tr>
<th scope="row">address</th>
<td><input type="text" name="address" maxlength="250"></td>
</tr>
<tr>
<th scope="row">Home Phone Number </th>
<td><input type="text" name="phone" maxlength="16"></td>
</tr>
<tr>
<th scope="row">Payment type</th>
<td><select name="paymenttype" size="1">
<option value="Cash">Cash</option>
<option value="Credit Card">Credit Card</option>
<option value="Eftpos Card">Eftpos Card</option>
</select></td>
</tr>
<tr>
<th scope="row">signature</th>
<td><input type="file" name="signature"></td>
</tr>
<tr>
<th scope="row">photo of Member:</th>
<td><input type="file" name="memberphoto"></td>
</tr>
<tr>
<th scope="row">Card Number</th>
<td><input name="cardnumber" type="text" size="17" maxlength="17">
</td>
</tr>
<tr>
<th scope="row">Date of Last payment</th>
<td><?php echo $today; ?></td>
</tr>
<tr>
<th scope="row">Card Type</th>
<td><select name="Cardtype" size="1">
<option value="Choose one">Choose One</option>
<option value="Visa">Visa</option>
<option value="MasterCard">MasterCard</option>
<option value="AmericanExpress">American Express</option>
<option value="Eftpos:cirrus">Eftpos:cirrus</option>
<option value="Eftpos:Maestro">Eftpos:Maestro</option>
<option value="Eftpos">Eftpos</option>
</select></td>
</tr>
<tr>
<th scope="row">Payment Type</th>
<td><select name="Payment">
<option value="Choose one">Choose One</option>
<option value="Credit Card">Credit Card</option>
<option value="Eftpos">Eftpos</option>
<option value="Cash">Cash</option>
</select></td>
</tr>
<tr>
<th scope="row">Last Payment Date</th>
<td><?php echo $today; ?></td>
</tr>
<tr>
<th scope="row">Status of Person</th>
<th scope="row"><select name="memberstatus">
<option value="Choose one">Choose One</option>
<option value="member">Member</option>
<option value="Customer">Customer</option>
</select></th>
</tr>
<tr>
<th scope="row"><input type="submit" value="Add member" name="addmember"><input type="reset"name="Clear">
</table></form></th></tr>
</fieldset>
<?php
if($_POST['addmember'])
{
$fname=$_POST['fname'];
$age=$_POST['age'];
$address=$_POST['address'];
$phone=$_POST['phone'];
$paymenttype=$_POST['paymenttype'];
$signature=$_POST['signature'];
$memberphoto=$_POST['memberphoto'];
$memberstatus=$_POST['memberstatus'];
$cardnumber=$_POST['cardnumber'];
if($fname || $age || $address || $phone || $paymenttype ||$memberstatus)
{
$pQuery="INSERT INTO members Values('','$fname','$age','$address','$phone','$paymenttype','$signature','$memberphoto','$cardnumbe r','','$memberstatus')";
//$_FILES is a super global
if($_FILES['signature']['error'])
{
echo "<b>Error :</b><br />";
switch($_FILES['signature']['error'])
{
// if the file size exceeds php's maximum allowed size
case 1: echo "File Exceeds PHP's maximum upload size<br />";
break;
// if the file size exceeds the Form defined MAX_FILE_SIZE
case 2: echo "File Exceeds Maximum Upload size <br />";
break;
case 3: echo "Partially Uploaded<br />";
break;
case 4: echo "No file Uploaded< br />";
}
}
else
{
// setup the path and file name
$upfile="uploaded/".$_FILES['signature']['name'];
// test if the temporary file is received OK
if(is_uploaded_file($_FILES['signature']['tmp_name']))
{
// moving the temporary file to our desired location
if(move_uploaded_file($_FILES['signature']['tmp_name'],$upfile))
{
echo "File Uploaded Successfully";
}
else
{
echo "Problem moving temporay file to your specfied location";
}
}
else // if temporary file is not available or file not uploaded
{
echo "Problem: File not reached to server properly";
}
}
echo $pQuery;
echo "<br/>";
$result=mysqli_query($con,$pQuery);
if(!$result)
{
echo "Error:".mysqli_connect_errno();
}
else
{
echo "Member Scessfully added";
}
}
}
?>


How can i fix this it doesnt seem to add into the database even if i refresh the page straight away.