baza
Oct 31 2009, 08:14 AM
Hi!
I have successfully uploaded my php files and my database but I get this message "Notice: Undefined index:" for every $_POST and $_GET in my code.
Why is this happening and how do I solve this problem?
Thanx in advance.
baza
Oct 31 2009, 06:31 PM
It is okay now. I've added this line at the beginning of all php files:
error_reporting(E_ALL & ~E_NOTICE);
So now there is no annoying warnings from server
toteng
Nov 28 2009, 02:20 PM
i have the same problem with you..but my problem is the data that i enter in my php page must enter in my database but it's not working...in xampp it's works.can you help me?
here is my code..
require("connectionq.php");
?>
<?
$x=mysql_query("select Product_Brand from adapter");
$y=mysql_affected_rows();
echo "<form method=post><select name=prod>";
for($i=0;$i<$y;$i++)
{
$row=mysql_fetch_array($x);
$pnAME=$row['Product_Brand'];
echo "<option value=\"$pnAME\">$pnAME</option>";
}
echo "</select><input type=submit value=search></form>";
?>
<?
$q=mysql_query("Select * from adapter where Product_Brand='{$_POST['prod']}'");
$r=mysql_affected_rows();
for($i=0;$i<$r;$i++)
{
$row=mysql_fetch_array($q);
$id=$row['Product_ID'];
$pn=$row['Product_Brand'];
$pr=$row['Price'];
$st=$row['Stock'];
}
?>
<form method=post>
<table>
<tr>
<td>Product ID:</td>
<td><input type= text value= '<?=$id?>' name=Product_ID></td>
</tr>
<tr>
<td>Product Brand:</td>
<td><input type= text value= '<?=$pn?>' name=Product_Brand></td>
</tr>
<tr>
<td>Price:</td>
<td><input type=text value='<?=$pr?>' name=Price></td>
</tr>
<tr>
<td>Stocks:</td>
<td><input type=text value='<?=$st?>' name=Stock /></td>
</tr>
<tr>
<td><input type=submit value=delete name=del></td>
<td><input type=submit value=update name=upd>
<input type=submit value=Insert name=insert></td>
</tr>
</table>
</form>
<p>
<?
if(isset($_POST['upd']))
{
{if(empty($_POST['Price'])||empty($_POST['Stock']))
{?>
<script type="text/javascript">
alert("PLEASE INSERT A VALUE!");
</script>
<?
}
else if(!is_numeric($_POST['Price'])||!is_numeric($_POST['Stock']))
{?>
<script type="text/javascript">
alert("INVALID VALUE ENTERED!!!");
</script>
<?
}
else
{$upd=mysql_query("UPDATE adapter SET Price='{$_POST['Price']}', Stock='{$_POST['Stock']}' where Product_ID='{$_POST['Product_ID']}' and Product_Brand='{$_POST['Product_Brand']}'");
mysql_query("Insert into adapter values(select * from adapter where Product_ID=$id)");
mysql_query("Delete form adapter where Product_ID=$id");
?>
<script type="text/javascript">
alert("DATA HAS BEEN UPDATED!");
</script>
<?
}}}
if(isset($_POST['del']))
{$del=mysql_query("Delete from adapter where Product_ID='{$_POST['Product_ID']}'");
?>
<script type="text/javascript">
alert("DATA HAS BEEN DELETED!");
</script>
<?
}
if(isset ($_POST['insert']))
{
$id=$_POST['Product_ID'];
$pn=$_POST['Product_Brand'];
$pr=$_POST['Price'];
$st=$_POST['Stock'];
{if(empty($_POST['Product_ID'])||empty($_POST['Product_Brand'])||empty($_POST['Price'])||empty($_POST['Stock']))
{?>
<script type="text/javascript">
alert("PLEASE INSERT A VALUE!!!");
</script>
<?
}
else if(is_numeric($_POST['Product_Brand']))
{?>
<script type="text/javascript">
alert("INVALID PRODUCT BRAND!");
</script>
<?
}
else if(!is_numeric($_POST['Product_ID']) ||!is_numeric($_POST['Price']) ||!is_numeric($_POST['Stock']))
{?>
<script type="text/javascript">
alert("INVALID VALUE ENTERED!");
</script>
<?
}
else
{
$insert = ("Insert into adapter values(" . $id . ",'" . $pn . "'," . $pr . ", " .$st. ")");
mysql_query($insert);?>
<script type="text/javascript">
alert("NEW DATA ADDED!");
</script>
<?
}}
}?>