Please help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shehan31
Forum Commoner
Posts: 59
Joined: Sun Aug 29, 2010 5:24 am

Please help

Post 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
Attachments
the database
the database
Untitled1.jpg (141.1 KiB) Viewed 2490 times
the error
the error
Untitled.jpg (100.27 KiB) Viewed 2490 times
Last edited by Benjamin on Sun Aug 29, 2010 4:55 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Please help

Post 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.
shehan31
Forum Commoner
Posts: 59
Joined: Sun Aug 29, 2010 5:24 am

Re: Please help

Post by shehan31 »

It worked . thank you very much for your help.
shehan31
Forum Commoner
Posts: 59
Joined: Sun Aug 29, 2010 5:24 am

Re: Please help

Post 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.
Post Reply