Hey All,
Very new to php and I am trying to create a form with these features.
Name
Model #
Description
(dropdown to chose) New Equipment / Old Equipment
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
[code]
Add Product | ||
Equipment Name | : | |
Model # | : | |
Description | : | |
Upload Image | : | Click browse to upload a local file |
Post.php code
[php]<?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”);
?> [/php]
Any help would be greatly appreciated.