1.11M Members

Need Help with form with database

 
0
 

Hi Advanced Devs,
I am very new to php. This is my learning moment. So, Help me.
I have added a zip folder with my files. I also have expoted my database as zipped folder.

Please help me with this topics. Please.
Samrat

Attachments own.zip (1.83KB)
 
0
 

I dont know how to extract your database file to the sql. But your problem seems to be simple, what is the problem you facing?

 
0
 
$sql = "INSERT INTO productinput(name, address, phone, email)
VALUES('$brand', '$model', '$image', '$desc', '$price')";

The above query may be wrong, you passed five values to four fields.

 
0
 

There sir,
I have edited, but still is not working. You can import the table of db "own".
Just go to phpmyadmin. click on import. browse the own.sql.

Please help me.
Thanks buddy
sam

 
0
 

The name of Desription column causes the problem chached the name now it works.

productinput.php

<html>
<head>
<title>Product Input</title>
</head>
<body>
<form action="submit.php" method="post" enctype="multipart/form-data" name="form1">
  <table width="500" border="0" align="center">
    <tr>
      <td colspan="2">Input Your Product Details Here-</td>
    </tr>
    <tr>
      <td width="245">Brand</td>
      <td width="245"><label>
        <input type="text" name="brand" id="brand">
      </label></td>
    </tr>
    <tr>
      <td>Model</td>
      <td><label>
        <input type="text" name="model" id="model">
      </label></td>
    </tr>
    <tr>
      <td>Image</td>
      <td><label>
        <input type="file" name="image" id="image">
      </label></td>
    </tr>
    <tr>
      <td>Description</td>
      <td><label>
        <textarea name="descr" id="descr" cols="45" rows="5"></textarea>
      </label></td>
    </tr>
    <tr>
      <td>Price</td>
      <td><label>
        <input type="text" name="price" id="price">
      </label></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><label>
        <input type="submit" name="button" id="button" value="Submit">
      </label></td>
    </tr>
  </table>
</form>
</body>
</html>

cont.php

<html>
<head>
<title>Connection Page</title>
</head>
<body>
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("own") or die(mysql_error());
?>

</body>
</html>

submit.php

<html>
<head>
</head>
<body>
<?php
include('cont.php');

$brand = $_POST['brand'];
$model = $_POST['model'];
$image = ($_FILES['image']['image']);
$descr = $_POST['descr'];
$price = $_POST['price'];

$sql = "INSERT INTO productinput(brand, model, image, descr, price)
VALUES('$brand', '$model', '$image', '$descr', '$price')";
$result = mysql_query($sql);

if (!$result)
{
die (mysql_error());
}
else
{
echo "You have submitted information Successfully";
}
?>

</body>
</html>

hope this helps

 
0
 

Thanks Man, I am checking. If any help. I will disturb you again. Dont mind.

 
0
 

Notice: Undefined index: image in G:\wamp\www\own\submit.php on line 10
Unknown column 'descr' in 'field list'

 
0
 

change the field in your data base from "desc" to "descr"

 
0
 

many many thanks, A+ to you.

Question Answered as of 4 Years Ago by rajarajan07 and trilithon
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: