can anyone help me where is the mistake?

the mail() function

Moderators: egami, macek, gesf

surajshrma12
New php-forum User
New php-forum User
Posts: 7
Joined: Mon Jun 27, 2016 4:00 am

Mon Jun 27, 2016 4:05 am

Code: Select all

</div>
							<div>
							
							<div id="form>">
							<form action="add_pro.php"method="post" enctype="multipart/form-data">
							<table align = "center" width= "80%" border="1" bgcolor="pink" cellpadding="8">
							<tr align="center">
							<td colspan="7"><h1>Add product</h2></td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Title:</B></td>
							<td><Input type="text" name="product_title" size= "60" required/> </td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Category:</B></td>
							<td>
								<select name="product_cat" required/>
								<option>select A catogory</option>
								
								<?php

									$get_cat ="SELECT * FROM `categories`";
	
									$run_cat = mysqli_query($con, $get_cat);
	
									while ($row_cat=mysqli_fetch_array($run_cat)){
		
									$cat_id = $row_cat['cat_id'];
									$cat_title =$row_cat['cat_title'];
		
									echo "<option value='$cat_id'>$cat_title</option>";
									}
									
								?>
								</select>
							</td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Brand:</B></td>
							<td> <select name="product_brand" / >
							<option>Select Any Brand</option>
							<?php
							$get_brand ="SELECT * FROM `brands`";
	
							$run_brand = mysqli_query($con, $get_brand);
	
							while ($row_brand=mysqli_fetch_array($run_brand)){
		
							$brand_id = $row_brand['brand_id'];
							
							$brand_title =$row_brand['brand_title'];
		
							echo "<option value='brand_id'>$brand_title</option>";
							}
							?>
							</tr>
							
							<tr>
							<td align="right"><b>Product Image:</B></td>
							<td> <Input type="file" name="product_image" size= "60"required/> </td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Price (Inr):</B></td>
							<td> <Input type="text" name="product_price" size= "60"/> </td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Descriptions:</B></td>
							<td> <textarea name="product_desc"cols="20" rows="10" /> </textarea> </td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Keyword:</B></td>
							<td> <Input type="text" name="product_keywords"/> </td>
							</tr>
							
							<tr><td align="center" colspan="7">
							<input type="submit" name ="insert_post" value= "add now"/></td>
	
				<?php
				if(isset($_post['insert_post'])){
					
					//getting the text details of the fields
					
				$product_title = $_post['product_title'];
				$product_cat = $_post['product_cat'];
				$product_brand = $_post['product_brand'];
				$product_price = $_post['product_price'];
				$product_desc = $_post['product_desc'];
				$product_keywords = $_post['product_keywords'];
					
				//getting the image
					$product_image = $_files['product_image']['name'];
					
					$product_image_tmp = $_files ['[product_image']['tmp_name'];
					
					move_uploaded_file($product_image_tmp,"product_images/$product_image");
					
		echo $add_pro = "insert into products
(product_cat,product_brand,product_title,product_price,product_desc,product_image,product_keywords)

values('$product_cat','$product_brand','$product_title','$product_price','$product_desc','$product_keywords','$product_image',)";

$add_pro = mysqli_query($con, $add_product);

if ($add_pro){
	
echo "<script>alert ('done')</script>";

				
				}
				
				}
				
				?>
				
				
:help: :help:

element121
php-forum Fan User
php-forum Fan User
Posts: 622
Joined: Sat Jun 06, 2015 11:46 am
Contact:

Mon Jun 27, 2016 8:45 am

I see this:

Code: Select all

<select name="product_brand" / >
Which should be:

Code: Select all

<select name="product_brand">
Are you getting any error messages?

element121
php-forum Fan User
php-forum Fan User
Posts: 622
Joined: Sat Jun 06, 2015 11:46 am
Contact:

Mon Jun 27, 2016 8:46 am

Also this:

Code: Select all

$product_image_tmp = $_files ['[product_image']['tmp_name'];
Should be:

Code: Select all

$product_image_tmp = $_files ['product_image']['tmp_name'];
In this snippet of code you provided, neither the table or form tags are closed.

surajshrma12
New php-forum User
New php-forum User
Posts: 7
Joined: Mon Jun 27, 2016 4:00 am

Mon Jun 27, 2016 9:07 pm

iam not getting any error message .
when i click the addnow button the page get refresed but there is no uary parse on my phpadmin or image folder.

i have successfully enabled all $con to my database i can read all table using same method but i could not post the quary?

element121
php-forum Fan User
php-forum Fan User
Posts: 622
Joined: Sat Jun 06, 2015 11:46 am
Contact:

Tue Jun 28, 2016 2:36 am

Have you fixed the mistakes I noted?

You should put your PHP code above the HTML code also.

surajshrma12
New php-forum User
New php-forum User
Posts: 7
Joined: Mon Jun 27, 2016 4:00 am

Thu Jun 30, 2016 3:16 am

Yes i have tried that but still the same problem

iam using xxamp
and having database table name : products
with rows

(product_cat,product_brand,product_title,product_price,product_desc,product_image,product_keywords

i am able to Get the data in table but not POST.

Code: Select all

<!DOCTYPE html>
<?php
include ("db.php");
?>
<html>
<head>

<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
  <script>tinymce.init({ selector:'textarea' });</script>
					<title>insert_product</title>
						</head>
					
		<body>				
						
						
							
							<form action="insert_product.php" method="post" enctype="multipart/form-data">
							<table align = "center" width= "80%" border="1" bgcolor="pink" cellpadding="8">
							<tr align="center">
							<td colspan="7"><h1>Add product</h2></td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Title:</B></td>
							<td><Input type="text" name="product_title" size= "60" required/> </td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Category:</B></td>
							<td>
								<select name="product_cat" required/>
								<option>select A catogory</option>
								
								<?php

									$get_cat ="SELECT * FROM `categories`";
	
									$run_cat = mysqli_query($con, $get_cat);
	
									while ($row_cat=mysqli_fetch_array($run_cat)){
		
									$cat_id = $row_cat['cat_id'];
									$cat_title =$row_cat['cat_title'];
		
									echo "<option value='$cat_id'>$cat_title</option>";
									}
									
								?>
								</select>
							</td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Brand:</B></td>
							<td> <select name="product_brand" / >
							<option>Select Any Brand</option>
							<?php
							$get_brand ="SELECT * FROM `brands`";
	
							$run_brand = mysqli_query($con, $get_brand);
	
							while ($row_brand=mysqli_fetch_array($run_brand)){
		
							$brand_id = $row_brand['brand_id'];
							
							$brand_title =$row_brand['brand_title'];
		
							echo "<option value='brand_id'>$brand_title</option>";
							}
							?>
							</tr>
							
							<tr>
							<td align="right"><b>Product Image:</B></td>
							<td> <Input type="file" name="product_image" size= "60"required/> </td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Price (Inr):</B></td>
							<td> <Input type="text" name="product_price" size= "60"/> </td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Descriptions:</B></td>
							<td> <textarea name="product_desc"cols="20" rows="10" /> </textarea> </td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Keyword:</B></td>
							<td> <Input type="text" name="product_keywords"/> </td>
							</tr>
							
							<tr align="center">
							<td colspan= "7"><input type= "submit" name ="insert_post" value= "insert product now"/></td>
	</form>
	
				
<?php
				if(isset($_post['insert_post'])){
					//getting the text details of the fields
					
				$product_title = $_post['product_title'];
				$product_cat = $_post['product_cat'];
				$product_brand = $_post['product_brand'];
				$product_price = $_post['product_price'];
				$product_desc = $_post['product_desc'];
				$product_keywords = $_post['product_keywords'];
					
				//getting the image
					$product_image = $_files['product_image']['name'];
					$product_image_tmp = $_files['[product_image']['tmp_name'];
					
move_uploaded_file($product_image_tmp,"product_images/$product.image");

echo $insert_product = "insert into products
(product_cat,product_brand,product_title,product_price,product_desc,product_image,product_keywords)

values($product_cat','$product_brand','$product_title','$product_price','$product_desc','$product_keywords','$product_image')";

$insert_pro = mysqli_query($con, $insert_product);

if (isset($_POST['insert_post']))
	
echo "<script>alert('done')</script>";
echo "<script>window.open('add_pro.php','_self')</script>";

				
				}
				
				?>
			</body>
	</html>

surajshrma12
New php-forum User
New php-forum User
Posts: 7
Joined: Mon Jun 27, 2016 4:00 am

Thu Jun 30, 2016 3:21 am

sorry its old code


here is the new code as you told

Code: Select all

<!DOCTYPE html>

<?php
$con = mysqli_connect("localhost","root","","myekarts");
// Check connection
if ($con->connect_error) {
    die("Connection failed: " . $con->connect_error);
} 
?>
<html>
<head>
<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
  <script>tinymce.init({ selector:'textarea' });</script>
					<title>insert_product</title>
						</head>
					
		<body>				
						
						
							
							<form action="insert_product.php" method="post" enctype="multipart/form-data">
							<table align = "center" width= "80%" border="1" bgcolor="pink" cellpadding="8">
							<tr align="center">
							<td colspan="7"><h1>Add product</h2></td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Title:</B></td>
							<td><Input type="text" name="product_title" size= "60" /> </td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Category:</B></td>
							<td>
								<select name="product_cat" >
								<option>select A catogory</option>
								
								<?php

									$get_cat ="SELECT * FROM `categories`";
	
									$run_cat = mysqli_query($con, $get_cat);
	
									while ($row_cat=mysqli_fetch_array($run_cat)){
		
									$cat_id = $row_cat['cat_id'];
									$cat_title =$row_cat['cat_title'];
		
									echo "<option value='$cat_id'>$cat_title</option>";
									}
									
								?>
								</select>
							</td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Brand:</B></td>
							<td> <select name="product_brand" / >
							<option>Select Any Brand</option>
							<?php
							$get_brand ="SELECT * FROM `brands`";
	
							$run_brand = mysqli_query($con, $get_brand);
	
							while ($row_brand=mysqli_fetch_array($run_brand)){
		
							$brand_id = $row_brand['brand_id'];
							
							$brand_title =$row_brand['brand_title'];
		
							echo "<option value='$brand_id'>$brand_title</option>";
							}
							?>
							</tr>
							
							<tr>
							<td align="right"><b>Product Image:</B></td>
							<td> <Input type="file" name="product_image"/></td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Price (Inr):</B></td>
							<td> <Input type="text" name="product_price" size= "60"/> </td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Descriptions:</B></td>
							<td> <textarea name="product_desc" 	cols="20" rows="10" > </textarea> </td>
							</tr>
							
							<tr>
							<td align="right"><b>Product Keyword:</B></td>
							<td> <Input type="text" name="product_keywords"/> </td>
							</tr>
							
							<tr align="center">
							<td colspan= "7"><input	type= "submit" name ="insert_post" value= "insert product now"/></td>
							</tr>
							</table>
	</form>
	</body>
	</html>
				
<?php
				if(isset($_POST['insert_post'])){
					//getting the text details of the fields
					
				$product_title = $_POST['product_title'];
				$product_cat = $_POST['product_cat'];
				$product_brand = $_POST['product_brand'];
				$product_price = $_POST['product_price'];
				$product_desc = $_POST['product_desc'];
				$product_keywords = $_POST['product_keywords'];
					
				//getting the image
					$product_image = $_FILES['product_image']['name'];
					$product_image_tmp = $_FILES['product_image']['tmp_name'];
					
					move_uploaded_file($product_image_tmp,"product_images/$product_image");


$insert_product = "INSERT INTO `products'
(`product_id`, `product_cat`, `product_brand`, `product_title`, `product_price`, `product_desc`, `product_image`, `product_keywords`)

VALUES([$product_cat],[$product_brand],[$product_title],[$product_price],[$product_desc],[$product_image],[$product_keywords])";

			$insert_product= mysqli_query($con, $insert_product);

				
echo "<script>alert('done')</script>";
echo "<script>window.open('insert_product.php','_self')</script>";	
	}
				
?>

surajshrma12
New php-forum User
New php-forum User
Posts: 7
Joined: Mon Jun 27, 2016 4:00 am

Thu Jun 30, 2016 3:22 am

iam getting the succes message
and also getting the image on specific folder.

partizan
New php-forum User
New php-forum User
Posts: 10
Joined: Sun Mar 25, 2018 10:11 am

Sun Mar 25, 2018 10:17 am

1.png
db
1.png (124.94 KiB) Viewed 764 times
Hello forum!

People i'm having similar issues with this code. Nothing happens when i press submit button. No error messages, expecting an echo.

thank you very much



Code: Select all

<!DOCTYPE html>
<?php
include ("includes/db.php");



?>


<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>insert_product</title>

</head>
<body>
    <form action="insert_product.php" method="post" enctype="multipart/form-data">
</form>

<table align="center" >

<tr align="center">
    <td><h2>Insert new post</h2></td>

</tr>

<tr>
    <td>jewellery type</td>
    <td>
        <select name="j_type" >
<option >Select jewellery type</option>
<?php
$get_cats="select * from product";
$run_cats=mysqli_query($con, $get_cats);

while($row_cats=mysqli_fetch_array($run_cats)){

    $cat_id=$row_cats['product_id'];
    $cat_type=$row_cats['j_type'];
    echo"<option value'$cat_id>$cat_type</option>";
}


?>
        </select>
    </td>
</tr>
<tr>
    <td>stone name</td>
    <td><input type="text" name="stone_name"/></td>
</tr>
<tr>
    <td>stone price</td>
    <td><input type="text" name="stone_price"/></td>
</tr>
<tr>
    <td>product image</td>
    <td><input type="file" name="product_image"/></td>
</tr>
<tr>
    <td>stone color</td>
    <td><input type="text" name="stone_color"/></td>
</tr>

    
    <td ><input type="submit" name="insert_post" value="Insert now"/></td>
</tr>


</table>
    
</body>
</html>

<?php 



// // Create connection
// $conn = new mysqli();
// // Check connection
// if ($conn->connect_error) {
//    die("Connection failed: " . $conn->connect_error);
// }
//   echo "Connected successfully";


if(isset($_POST['insert_post'])){

$j_type=$_POST['j_type'];
$stone_name=$_POST['stone_name'];
$stone_price=$_POST['stone_price'];
$stone_color=$_POST['stone_color'];

$product_image=$_FILES['product_image']['name'];
$product_image_tmp=$_FILES['product_image']['tmp_name'];


echo $insert_product="insert into product (j_type,stone_name,stone_price,stone_color,product_image) values ('$j_type','$stone_name','$stone_price','$stone_color','$product_image')";

// $insert_product = "insert into product
// (j_type,stone_name,stone_price,stone_color,product_image)

// VALUES('$j_type,'$stone_name',$stone_price','$stone_color','$product_image')";
		
				
}	




?> 

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 693
Joined: Mon Feb 22, 2016 5:52 pm

Sun Mar 25, 2018 10:37 am

Have you set errors to display?

Is that the code for two files?

Have you checked the resultant html code (the one that is displayed in your browser)?

Have you written all of this code or is it a copy, paste and hope?

partizan
New php-forum User
New php-forum User
Posts: 10
Joined: Sun Mar 25, 2018 10:11 am

Sun Mar 25, 2018 10:58 am

hyper wrote:
Sun Mar 25, 2018 10:37 am
Have you set errors to display?

Is that the code for two files?

Have you checked the resultant html code (the one that is displayed in your browser)?

Have you written all of this code or is it a copy, paste and hope?
1. I did change php.ini file by adding E_ALL in error reporting sentence.No errors

2. At the beginning of the code there is a link to other file that contains this line

Code: Select all

 <?php
    $con= mysqli_connect("localhost","root","","ecommerce");
?>
3. i just did check the resultant html code. What should i be looking for?

4. I'm following tutorial..the teacher had same problem...but he resolved it by removing "required" attribute for the fields, which i never inserted on first place.

hope. i do hope.

Ready to pay a reasonable rate for tutoring me towards a good looking website.

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 693
Joined: Mon Feb 22, 2016 5:52 pm

Sun Mar 25, 2018 12:31 pm

1. I did change php.ini file by adding E_ALL in error reporting sentence.No errors
That sets what is reported, not what I asked: have you set it to display errors? If this is a public web site then you must set it to log errors and read the log file, location can be obtained from phpinfo()
2. At the beginning of the code there is a link to other file that contains this line
Again, not what I asked; the code that you put in your post: is that for two files or is it just one?

if one file, what is it called, if it's two files what are they called?
3. i just did check the resultant html code. What should i be looking for?
Correctly formed html that is exactly what you thought it would be
4. I'm following tutorial..the teacher had same problem...but he resolved it by removing "required" attribute for the fields, which i never inserted on first place.
:help: Find another tutorial, forget anything it did, if you paid for this, ask for your money back - I've heard it all now

When learning coding: Learn to read what is written, question it, read again, question more; repeat, rinse and repeat.

:?

partizan
New php-forum User
New php-forum User
Posts: 10
Joined: Sun Mar 25, 2018 10:11 am

Sun Mar 25, 2018 1:53 pm

1. Seems like display is on. Refer to images attached on one of the screenshots. On other screenshot error is on purpose ,just to see that the error display is showing
2.png
2.png (123.52 KiB) Viewed 745 times
2. This code is used in insert_page.php file only. 1file.

3. I'm not sure if html formed correctly.Shows up ok.

Code: Select all

<!DOCTYPE html>
<?php
include("functions/functions.php");
?>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Ecommerce</title>
    <link rel="stylesheet" href="styles/styles.css" media="all"/>
</head>
<body>
 <div class="main_wrapper">

 <div class="header"></div>
 <div class="menu">
     
     <ul id="stones">

     <?php getCats() ?>
         <!-- <li><a href="#">Agate</a></li>
         <li><a href="#">Agate</a></li>
         <li><a href="#">Agate</a></li>
         <li><a href="#">Agate</a></li>
         <li><a href="#">Agate</a></li>
         <li><a href="#">Agate</a></li>
         <li><a href="#">Agate</a></li>
         <li><a href="#">Agate</a></li>
         <li><a href="#">Agate</a></li>
         <li><a href="#">Agate</a></li>
         <li><a href="#">Agate</a></li>
         <li><a href="#">Agate</a></li>
         <li><a href="#">Agate</a></li>
         <li><a href="#">Agate</a></li>
         <li><a href="#">Agate</a></li>
         <li><a href="#">Agate</a></li> -->

    </ul> 
     
 </div>
 

 <div class="footer">footer</div>

 </div>
</body>
</html>
4. Please help and dont get angry.

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 693
Joined: Mon Feb 22, 2016 5:52 pm

Sun Mar 25, 2018 3:10 pm

Well done for jumping the gun and proving error reporting is working :)

If the first listing (you posted) is producing the second listing, you have serious problems.

Are you typing "localhost/insert_page.php" into the address bar of your browser?
and
is that the code from the first code you posted?
and
(finally) is that file in your web root directory (the same place as oops.php)

Where did you get the second listing from?

I'm not getting angry, I'm laughing :D

partizan
New php-forum User
New php-forum User
Posts: 10
Joined: Sun Mar 25, 2018 10:11 am

Sun Mar 25, 2018 5:24 pm

1. By listing you mean this code?

Code: Select all

echo $insert_product="insert into product (j_type,stone_price,product_image,stone_name,stone_color) values ('$j_type','$stone_price','$product_image','$stone_name','$stone_color')";

2.Are you typing "localhost/insert_page.php" into the address bar of your browser?
yes

3.is that the code from the first code you posted?
i posted only one php code. I compared it to original code by surajshrma12
and din't dind major differences except in this line

Code: Select all

echo $insert_product="insert into product (j_type,stone_price,product_image,stone_name,stone_color) values ('$j_type','$stone_price','$product_image','$stone_name','$stone_color')";

Code: Select all

VALUES([$product_cat],[$product_brand],[$product_title],[$product_price],[$product_desc],[$product_image],[$product_keywords])";

			$insert_product= mysqli_query($con, $insert_product);
is that file in your web root directory (the same place as oops.php)
4.
3.png
3.png (69.14 KiB) Viewed 725 times

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 693
Joined: Mon Feb 22, 2016 5:52 pm

Mon Mar 26, 2018 7:24 am

This first listing:

Code: Select all

<!DOCTYPE html>
<?php
include ("includes/db.php");
?>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>insert_product</title>

</head>
<body>
    <form action="insert_product.php" method="post" enctype="multipart/form-data">
</form>
....
Is not the same as the second listing you gave:

Code: Select all

<!DOCTYPE html>
<?php
include("functions/functions.php");
?>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Ecommerce</title>
    <link rel="stylesheet" href="styles/styles.css" media="all"/>
</head>
<body>
 <div class="main_wrapper">
 ....
 
Can you post a screenshot of when you type the address in your browser to execute the script.

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 693
Joined: Mon Feb 22, 2016 5:52 pm

Mon Mar 26, 2018 7:26 am

And can you also post a screenshot of the script in your editor (just what's on the screen will do; make sure that there isn't any sensitive information on the screen.

partizan
New php-forum User
New php-forum User
Posts: 10
Joined: Sun Mar 25, 2018 10:11 am

Mon Mar 26, 2018 2:31 pm

You are right it's not the same.Sorry for confusion.
1st listing insert_product.php listing, the 2nd listing is index.php file which is irrelevant in a problem i'm having.I provided it in attempt to your comment.
Have you checked the resultant html code (the one that is displayed in your browser)?
Can you post a screenshot of when you type the address in your browser to execute the script.
4.png
4.png (33.86 KiB) Viewed 668 times
And can you also post a screenshot of the script in your editor (just what's on the screen will do; make sure that there isn't any sensitive information on the screen.
5.png
5.png (168.37 KiB) Viewed 668 times

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 693
Joined: Mon Feb 22, 2016 5:52 pm

Mon Mar 26, 2018 4:36 pm

When processing forms using the same script, it's usual to put the checks at the top, put this bit at the top of your file and see what happens

Code: Select all

if(isset($_POST['insert_post'])){

$j_type=$_POST['j_type'];
$stone_name=$_POST['stone_name'];
$stone_price=$_POST['stone_price'];
$stone_color=$_POST['stone_color'];

$product_image=$_FILES['product_image']['name'];
$product_image_tmp=$_FILES['product_image']['tmp_name'];

echo $insert_product="insert into product (j_type,stone_name,stone_price,stone_color,product_image) values ('$j_type','$stone_name','$stone_price','$stone_color','$product_image')";

exit('<br>The button was pressed');
}

partizan
New php-forum User
New php-forum User
Posts: 10
Joined: Sun Mar 25, 2018 10:11 am

Mon Mar 26, 2018 4:56 pm

No luck
Take a look in code maybe i didn't understand you

Code: Select all

<!DOCTYPE html>
<?php
include ("includes/db.php");
if(isset($_POST['insert_post'])){

    $j_type=$_POST['j_type'];
    $stone_name=$_POST['stone_name'];
    $stone_price=$_POST['stone_price'];
    $stone_color=$_POST['stone_color'];
    
    $product_image=$_FILES['product_image']['name'];
    $product_image_tmp=$_FILES['product_image']['tmp_name'];
    
    echo $insert_product="insert into product (j_type,stone_name,stone_price,stone_color,product_image) values ('$j_type','$stone_name','$stone_price','$stone_color','$product_image')";
    
    exit('<br>The button was pressed');
    }
    



?>


<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>insert_product</title>

</head>
<body>
    <form action="insert_product.php" method="post" enctype="multipart/form-data">
</form>

<table align="center" >

<tr align="center">
    <td><h2>Insert new post</h2></td>

</tr>

<tr>
    <td>jewellery type</td>
    <td>
        <select name="j_type" >
<option >Select jewellery type</option>
<?php
$get_cats="select * from product";
$run_cats=mysqli_query($con, $get_cats);

while($row_cats=mysqli_fetch_array($run_cats)){

    $cat_id=$row_cats['product_id'];
    $cat_type=$row_cats['j_type'];
    echo"<option value='$cat_id'>$cat_type</option>";
}


?>
        </select>
    </td>
</tr>
<tr>
    <td>stone name</td>
    <td><input type="text" name="stone_name"/></td>
</tr>
<tr>
    <td>stone price</td>
    <td><input type="text" name="stone_price"/></td>
</tr>
<tr>
    <td>product image</td>
    <td><input type="file" name="product_image"/></td>
</tr>
<tr>
    <td>stone color</td>
    <td><input type="text" name="stone_color"/></td>
</tr>

    
    <td ><input type="submit" name="insert_post" value="Insert now"/></td>
</tr>


</table>
    
</body>
</html>



User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 693
Joined: Mon Feb 22, 2016 5:52 pm

Tue Mar 27, 2018 7:27 am

And you have entered data into the form and clicked the button?

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 693
Joined: Mon Feb 22, 2016 5:52 pm

Tue Mar 27, 2018 7:38 am

ok, take the </form> from here:

Code: Select all

</head>
<body>
    <form action="insert_product.php" method="post" enctype="multipart/form-data">
</form>
and put it here (at the end of the table), like so:

Code: Select all

    <td ><input type="submit" name="insert_post" value="Insert now"/></td>
</tr>


</table>
</form>

partizan
New php-forum User
New php-forum User
Posts: 10
Joined: Sun Mar 25, 2018 10:11 am

Tue Mar 27, 2018 5:13 pm

Un f***** believable. I was able to submit form and modify data. Thank you!!!

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 693
Joined: Mon Feb 22, 2016 5:52 pm

Wed Mar 28, 2018 7:44 am

I'm not sure that I've done you any favours, but I have been resisting telling you to learn from a proper, correct, recent and up to date tutorial.

If you are happy though :)

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 693
Joined: Mon Feb 22, 2016 5:52 pm

Wed Mar 28, 2018 7:46 am

hyper wrote:
Sun Mar 25, 2018 12:31 pm
:help: Find another tutorial, forget anything it did, if you paid for this, ask for your money back - I've heard it all now
:oops: maybe I didn't entirely :oops:

Post Reply