We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,539 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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)
3
Contributors
8
Replies
9 Hours
Discussion Span
2 Years Ago
Last Updated
9
Views
Question
Answered
aynamohol
Newbie Poster
13 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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,450 posts since May 2008
Reputation Points: 167
Solved Threads: 241
Skill Endorsements: 1
$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,450 posts since May 2008
Reputation Points: 167
Solved Threads: 241
Skill Endorsements: 1

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
Skill Endorsements: 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
Skill Endorsements: 0

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
Skill Endorsements: 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
Skill Endorsements: 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
Skill Endorsements: 0

many many thanks, A+ to you.

aynamohol
Newbie Poster
13 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 2 Years Ago by rajarajan07 and trilithon

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0861 seconds using 2.74MB