Hey All,
Very new to php and I am trying to create a form with these features.
Name
Model #
Description
Image
When the admin submits that info it gets stored into a database.
Is there any kind of tutorial that will show me exactly how to do this? I tried it myself but I cannot get it to work.
Form Code
<form method="post" action="post.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Add Product</strong></td>
</tr>
<tr>
<td width="78">Equipment Name</td>
<td width="6">:</td>
<td width="294"><input name="name" type="text" id="name" style="width:250px;"></td>
</tr>
<tr>
<td>Model #</td>
<td>:</td>
<td><input name="model" type="text" id="model" style="width:250px;"></td>
</tr>
<tr>
<td>Description</td>
<td>:</td>
<td><input name="desc" type="text" id="desc" style="width:250px; height:100px;"></td>
</tr>
<tr>
<td>Upload Image</td>
<td>:</td>
<td><input type="hidden" name="MAX_FILE_SIZE" value="25000"> <input type="file" name="imgfile">
<font size="1">Click browse to upload a local file</font></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</td>
</form>
Post.php code
<?php
// Pick up the form data and assign it to variables
$name = $_POST['name'];
$model = $_POST['model'];
$desc = $_POST['desc'];
$image = $_POST['image'];
// contact to database
$connect = mysql_connect("localhost", "username", "password") or die ("Error , check your server connection.");
mysql_select_db("databasename");
//Get data in local variable
$v_name=$_POST['name'];
$v_model=$_POST['model'];
$v_desc=$_POST['desc'];
$v_image=$_POST['image'];
// check for null values
if ($v_name=="" or $v_model=="")
echo "All fields must be entered, hit back button and re-enter information";
else{
$query="insert into test(name, model, desc, image) values('$v_name','$v_model','$v_desc','$v_image'')";
mysql_query($query) or die(mysql_error());
}
// Redirect
header("Location: ../admin/Admin_AddListing.php");
?>
Any help would be greatly appreciated.