As a beginner, I designed a website using php, but unfortunately I found difficulty with 3 codes. I have already written them but am not sure why they didn't work . Please check it for me…
There are:
1-changing pending status to accept or reject from admin ,,,
<?php
session_start();
$_SESSION['UserName'] = $UserName;
$_SESSION['Password'] = $Password;
$sql="update product_customer SET Status ='$Status' where OID='$OID'";
$result = mysql_query($sql);
echo"<br><br><br><br><br><br><br><br><br><font size='6' face='Lucida Handwriting' color='#CCCCCC'>";
echo "<br><br>the admin has been decided ..<br><br>";
echo"</font>";
header("location:search.php");
//////////////////////////////
//this is accept code
<?php
session_start();
$_SESSION['UserName'] = $UserName;
$_SESSION['Password'] = $Password;
include ("connect.php");
$sql1 = "select * from product_customer where Status = 'Accept' and UserName ='$UserName' ";
$result1 = mysql_query($sql1);
echo "<table width=300 border=1 >
<tr>
<td width=100 bgcolor=#BCE954><b><font size=2 color=#000000 ><center>OID</font></b></td>
<td width=100 bgcolor=#BCE954><b><font size=2 color=#000000 ><center>PID</font></b></td>
<td width=100 bgcolor=#BCE954><b><font size=2 color=#000000><center>UserName</font></b></td>
<td width=100 bgcolor=#BCE954><b><font size=2 color=#000000><center>Status</font></b></td>
<tr>
<table>";
while ($row1=@mysql_fetch_array($result1))
{
$i++;
echo"
<table border=1 width=832 id=table1 >
<tr>
<td width=73 >".$row1['OID']."</td>
<td width=115 >".$row1['PID']."</td>
<td width=106 >".$row1['UserName']."</td>
<td width=113 >".$row1['Status']."</td>
<td width=50 ><a href=pay.php?OID=".$row1['OID']."&&PID=".$row1['PID'].">Pay</a></td>
</tr>
</table> ";
}
2-Adding product to the database and delete it. (phpMyAdmin) The problem is that the product is added to the list on the website(localhost), but not on the database(phpmyadmin)<?php
session_start();
$_SESSION['UserName'] = $UserName;
$_SESSION['Password'] = $Password;
//echo "<a href=logout.php>Logout</a> <br><br>Welcome $username";
include ("connect.php");
$sql= "insert into products values( '$PID',
'$Model',
'$manufacture',
'$PColor',
'$PPrice',
'$PQuantity',
'$PCategory')";
mysql_query($sql) or die ("Could not Insert the new record becouse of either Syntax error or a database problem");
header ('Location:admin_prod.php');
?>
3-editing product features such as delete or update product
<?
include ("top.php");
?>
<?php
//session_start();
$_SESSION['UserName'] = $UserName;
$_SESSION['Password'] = $Password;
include ("connect.php");
echo "<table>
<tr>
<td width = 200> <b><font size=3 color=ff0000 >$UserName </font></b></td>
<tr>
<table>
";
include ("connect.php");
$_GET['UserName'] = $UserName;
$_GET['Password'] = $Password ;
echo "Delete a product by clicking on the product ID..";
$sql = "SELECT * FROM products ";
$result = mysql_query($sql)or die ("could Not execute query $sql");
echo "<table width = 600 border=1 >
<tr>
<td width=100 bgcolor=#BCE954><b><font size=2 color=#000000> <center>PID</font></b></td>
<td width=100 bgcolor=#BCE954><b><font size=2 color=#000000> <center>Model</font></b></td>
<td width=100 bgcolor=#BCE954><b><font size=2 color=#000000> <center>PColor</font></b></td>
<td width=100 bgcolor=#BCE954><b><font size=2 color=#000000> <center>PPrice</font></b></td>
<td width=100 bgcolor=#BCE954><b><font size=2 color=#000000> <center>PQuantity</font></b></td>
<td width=100 bgcolor=#BCE954><b><font size=2 color=#000000> <center>PCategory</font></b></td>
<tr>
<table>";
WHILE($row=@mysql_fetch_array($result)) {
echo "<table width = 600 border=1 >
<tr>
<td width = 100> <a href=deletform.php?PID = ".$row["PID"]."> ".$row["PID"]."</a></td>
<td width = 100> ".$row["Model"]." </td>
<td width = 100> ".$row["PColor"]." </td>
<td width = 100> ".$row["PPrice"]." </td>
<td width = 100> ".$row["PQuantity"]." </td>
<td width = 100> ".$row["PCategory"]." </td>
<tr>
<table>";
}
?>
<?
include ("buttom.php");
///////
///this is deleteform.php
$sql = "DELETE FROM products where PID = '$PID'"or die ("ERROR: Cannot not find user!");
$result = mysql_query($sql) or die ("Error in query: $sql. ".mysql_error());