form with image upload and having info get stored into database

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
   
[/code]

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.

You have an error in your SQL syntax on the line:

[php]$query=“insert into test(name, model, desc, image) values(’$v_name’,’$v_model’,’$v_desc’,’$v_image’’)”;[/php]

There are two ’ symbols after the $v_image variable is used.

Sponsor our Newsletter | Privacy Policy | Terms of Service