954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Need Help with form with database

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)
aynamohol
Newbie Poster
13 posts since Jun 2010
Reputation Points: 10
Solved Threads: 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?

rajarajan07
Nearly a Posting Virtuoso
1,447 posts since May 2008
Reputation Points: 167
Solved Threads: 239
 
$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.

rajarajan07
Nearly a Posting Virtuoso
1,447 posts since May 2008
Reputation Points: 167
Solved Threads: 239
 

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

aynamohol
Newbie Poster
13 posts since Jun 2010
Reputation Points: 10
Solved Threads: 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

trilithon
Light Poster
38 posts since Jun 2010
Reputation Points: 10
Solved Threads: 4
 

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

aynamohol
Newbie Poster
13 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

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

aynamohol
Newbie Poster
13 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

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

trilithon
Light Poster
38 posts since Jun 2010
Reputation Points: 10
Solved Threads: 4
 

many many thanks, A+ to you.

aynamohol
Newbie Poster
13 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: