1,105,286 Community Members

Need Help with form with database

Member Avatar
aynamohol
Newbie Poster
14 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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)
Member Avatar
rajarajan07
Nearly a Posting Virtuoso
1,448 posts since May 2008
Reputation Points: 123 [?]
Q&As Helped to Solve: 242 [?]
Skill Endorsements: 3 [?]
 
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?

Member Avatar
rajarajan07
Nearly a Posting Virtuoso
1,448 posts since May 2008
Reputation Points: 123 [?]
Q&As Helped to Solve: 242 [?]
Skill Endorsements: 3 [?]
 
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.

Member Avatar
aynamohol
Newbie Poster
14 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
trilithon
Light Poster
38 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 4 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
aynamohol
Newbie Poster
14 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
aynamohol
Newbie Poster
14 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
trilithon
Light Poster
38 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 4 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
aynamohol
Newbie Poster
14 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

many many thanks, A+ to you.

Question Answered as of 3 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: