Code: Select all
<?php
echo "<h2> transaction description </h2>";
echo "<hr>";
$connect = mysql_connect ("localhost","root","") or die ("error");
mysql_select_db ("guestbook") or die ("eroor connecting Database");
$queryget = mysql_query ("select * from report") or die (" error with table");
echo "<hr>";
while ( $row = mysql_fetch_assoc ($queryget) ){
$Customername = $row ['Customer name'];
$Transaction_Number = $row ['Transaction Number'];
$Price = $row ['Price'];
$Weight = $row ['Weight'];
$date = $row ['Date'];
$time = $row ['Time'];
echo"
<table>
<tr>
<td>
<b> Customer Name : $Customername</b>
</td>
</tr>
<tr>
<td>
<b> Weight : $Weight</b>
</td>
</tr>
";
}
echo "<hr>";
if (isset($_POST['submit'])){
$Customername = $_POST['Customer name'];
$Transaction_Number = $_POST['Transaction Number'];
$Price = $_POST['Price'];
$Weight = $_POST['Weight'];
$date = date("Y-m-d");
$time = date("H:i:s");
if ($Customername&&$Transaction_Number&&$Price&&$Weight )
{
$querypost = mysql_query (" INSERT INTO * report VALUES ('$Customername' '$TransactionNumber' '$Price' '$Weight' '$date' '$time')" );
echo "Please wait... <meta http-equiv='refresh' content='20'";
}
else
echo " fill out all fileds";
}
echo"
<form action='guestbook.php' method='POST'>
<table width= '100 %'>
<tr>
<td>
Customer name
</td>
<td>
<input type='text' name='Customer name' maxlength='30'>
</td>
</tr>
<tr>
<td>
Transaction Number
</td>
<td>
<input type='text' name='Transaction Number' maxlength='25'>
</td>
</tr>
<tr>
<td>
Price
</td>
<td>
<input type='text' name='Price' maxlength='25'>
</td>
</tr>
<tr>
<td valign='top'>
Weight
<td>
<input type='int' name='Weight' maxlength='25'>
<p>
<input type='submit' name='submit' value='Confirm'>
</td>
</tr>
</table>
</form>
"
?>DEAR ALL:
I am very much new to PHP. I have tried to make a transaction report using php. I am having a notice like this:
Notice: Undefined index: Customer name in C:\wamp\www\guestbook\guestbook.php on line 33
Notice: Undefined index: Transaction Number in C:\wamp\www\guestbook\guestbook.php on line 34
please refer the attachments.
I have created six fields ( please refer the attachment) in mysql data base. it looks to me the problem is with the if statement.
If i omit the if statement it will work. The while loop is to grab the data from the table in the data base and the if statement is to store the data. Please refer my attachments.
Thanking you
Shehan