Page 1 of 1

Please help

Posted: Sun Aug 29, 2010 6:17 am
by shehan31

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. :banghead:
Thanking you
Shehan

Re: Please help

Posted: Sun Aug 29, 2010 1:45 pm
by Jonah Bron
Not sure, but it could be that you can't have spaces in the input name. Replace the space with an underscore in your form and in your PHP.

Also
Forum Rules wrote:1. Select the correct board for your query. Take some time to read the guidelines in the sticky topic.
2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
And always wrap code with [syntax] tags.

Re: Please help

Posted: Sun Sep 05, 2010 6:13 am
by shehan31
It worked . thank you very much for your help.

Re: Please help

Posted: Sun Sep 05, 2010 6:15 am
by shehan31
Jonah Bron wrote:Not sure, but it could be that you can't have spaces in the input name. Replace the space with an underscore in your form and in your PHP.
Thank you ver much. it works.
Also
Forum Rules wrote:1. Select the correct board for your query. Take some time to read the guidelines in the sticky topic.
2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
And always wrap code with [syntax] tags.