473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem with this..Notice: Undefined index

Expand|Select|Wrap|Line Numbers
  1. <? ob_start();
  2. session_start();
  3. require('../includes/inc.php');
  4. require('../includes/settings.php');
  5. include("../includes/dbconnect.php");?>
  6.  
  7. <?php
  8.             // requires the class
  9.             require "../includes/class.datepicker.php";
  10.  
  11.             // instantiate the object
  12.             $db=new datepicker();
  13.  
  14.             $db->firstDayOfWeek = 1;
  15.  
  16.             // set the format in which the date to be returned
  17.             $db->dateFormat = "Y-n-j";
  18.         ?>
  19.  
  20. <link rel=stylesheet type="text/css" href="images/style.css">
  21. <body bgcolor="" bgproperties="fixed">
  22.  
  23.  
  24.  
  25. <table width="580" height="310" border="0" cellpadding="0" cellspacing="0" align="center">
  26.     <th bgcolor="#990099" align="left" valign="top" width="610" height="20"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#FFFFFF"> 
  27.       MAKLUMAT KURSUS BARU</font></th>
  28.       <tr>
  29.       <td bgcolor="#CC99FF" align="right" valign="top" width="580"><br>
  30.  
  31.  
  32.   <tr>
  33.       <td bgcolor="#CC99FF" align="left" valign="top" width="580"> 
  34.  
  35.       <form name="formupdate" action="kurs_baru.php" method="post">
  36.         <br><table width="580" border="0" cellpadding="5" cellspacing="3" align="center" dwcopytype="CopyTableRow">
  37.  
  38.             <tr>
  39.               <td class="content" width="150">Nama Kursus/Latihan</td>
  40.               <td class="content" width="445" colspan="3">
  41.             <input type="text" name='kurs_name' value="" size="67">
  42.             </td>
  43.           </tr>
  44.  
  45.           <tr>
  46.               <td class="content" width="150">Tempat Kursus/Latihan</td>
  47.               <td class="content" width="445" colspan="3">
  48.             <input type="text" name='kurs_tmpt' value="" size="67">
  49.             </td>
  50.           </tr>    
  51.            <tr>
  52.             <td class="content" width="140">Jenis Kursus </td>
  53.               <td class="content" width="445" colspan="3">    
  54.                <select name="kurs_jenis">
  55.                 <option value="-" selected>Pilih</option>
  56.                 <option value="Umum">Umum</option>
  57.                 <option value="Khusus">Khusus</option>
  58.                 <option value="Teknikal/IT">Teknikal/IT</option>
  59.               </select>    
  60.             </tr>    
  61.           <tr>
  62.               <td class="content" width="150">Tarikh Mula</td>
  63.             <td class="content" width="430" colspan="3">
  64.                 <input type="text" id="date" name="kurs_frst_date" value="">
  65.                 <input type="button" value="Pilih Tarikh" onClick="javascript:var cw = null; cw = window.open('../includes/includes/datepicker.php?preselectedDate=&month=&year=&controlName=date&dateFormat=Y-n-j&firstDayOfWeek=1&clearDateButton=1&language=english&template=default','datePicker','width=200,height=210,scrollbars=no,toolbar=no,menubar=no,location=no,alwaysraised=yes,modal=yes'); if (window.focus) { cw.focus() } return true">
  66.             </td>
  67.             </tr>
  68.           <tr>
  69.               <td class="content" width="150">Tarikh Tamat</td>
  70.             <td class="content" width="430" colspan="3"> 
  71.             <input type="text" id="date1" name="kurs_last_date" value=""> 
  72.               <input type="button" value="Pilih Tarikh" onClick="javascript:var cw = null; cw = window.open('../includes/includes/datepicker.php?preselectedDate=&month=&year=&controlName=date1&dateFormat=Y-n-j&firstDayOfWeek=1&clearDateButton=1&language=english&template=default','datePicker','width=200,height=210,scrollbars=no,toolbar=no,menubar=no,location=no,alwaysraised=yes,modal=yes'); if (window.focus) { cw.focus() } return true">
  73.             </td>
  74.             </tr>
  75.  
  76.  
  77.             <tr>
  78.               <td class="content" width="150">Penganjur</td>
  79.               <td class="content" width="445" colspan="3">
  80. <?
  81.         $querypenganjur = "SELECT * FROM penganjur ORDER BY anjur_name";        
  82.         $resultpenganjur = mysql_query($querypenganjur) or die (mysql_error());
  83. ?>            
  84.           <select name="anjur_name">
  85.                 <option value="-" selected>Pilih</option>
  86.             <? while($view2 = mysql_fetch_array($resultpenganjur)){?>
  87.                 <option value="<? echo $view2['anjur_id'];?>"><? echo $view2['anjur_name'];?></option>
  88.             <?     }?>
  89.                 </select>    
  90.             </tr>    
  91.  
  92.  
  93.  
  94.           <tr>
  95.             <td class="content" width="150"></td>
  96.             <td class="content" width="445" colspan="3">
  97.                 <input type="submit" name="Submit" value="Daftar">
  98.             </td>
  99.           </tr>
  100.  
  101.           </table><!-- end table form -->
  102.  
  103.  
  104.  
  105. </form>
  106.     <? if($_POST['Submit'] == "Daftar") { //submit info
  107.  
  108.  
  109.             $kurs_name            =    $_POST['kurs_name'];
  110.             $kurs_tmpt            =    $_POST['kurs_tmpt'];
  111.             $kurs_jenis            =    $_POST['kurs_jenis'];
  112.             $kurs_frst_date        =    $_POST['kurs_frst_date'];
  113.             $kurs_last_date        =    $_POST['kurs_last_date'];
  114.             $anjur_name            =    $_POST['anjur_name'];
  115.  
  116.             $add_staf="INSERT INTO kursus VALUES ('', '$kurs_name', '$kurs_tmpt', '$kurs_jenis', '$kurs_frst_date', '$kurs_last_date', '', '', '', 
  117.                             '$anjur_name')";            
  118.             $result_add = mysql_query($add_staf) or die (mysql_error());
  119.  
  120.             $querykur = "SELECT * FROM kursus ORDER BY kurs_id DESC limit 1";
  121.             $resultkur = mysql_query($querykur) or die (mysql_error());
  122.             $viewkur = mysql_fetch_array($resultkur);
  123.  
  124.             $kurs_id = $viewkur['kurs_id'];
  125.  
  126.             $add_kurs="INSERT INTO sk VALUES ('', '$s_id', '$kurs_id')";            
  127.             $result_kurs = mysql_query($add_kurs) or die (mysql_error());
  128.  
  129.  
  130.     ?>
  131.     <br><table width="580" border="0" cellpadding="5" cellspacing="3" align="center">
  132.            <tr>
  133.               <td bgcolor="" colspan="4" class="content" width="595">
  134.             <B>MAKLUMAT KURSUS TELAH DIDAFTAR.</B><br><br>
  135.             </td>
  136.           </tr>
  137.           <tr>    
  138.           <td class="content" width="150" bgcolor="#FFCC00">Nama Kursus/Latihan</td>
  139.               <td class="content" width="445" colspan="3" bgcolor="#FFFF99">
  140.             <? echo $kurs_name;?>
  141.             </td>
  142.           </tr>     
  143.           <tr>
  144.           <td class="content" width="150" bgcolor="#FFCC00">Tempat Kursus/Latihan</td>
  145.               <td class="content" width="445" colspan="3" bgcolor="#FFFF99">
  146.             <? echo $kurs_tmpt;?>
  147.             </td>
  148.           </tr>     
  149.           <tr> 
  150.           <td class="content" width="140" valign="top" bgcolor="#FFCC00">Jenis Kursus</td>
  151.               <td class="content" width="157.5" bgcolor="#FFFF99"><? echo $kurs_jenis;?></td>
  152.           </tr> 
  153.           <tr>
  154.               <td class="content" width="150" bgcolor="#FFCC00">Tarikh Masuk</td>
  155.             <td class="content" width="147.5" bgcolor="#FFFF99">
  156.                 <? echo $kurs_frst_date;?>
  157.             </td>
  158.             <td colspan="2" width="297.5">&nbsp;</td>
  159.             </tr>
  160.         <tr>
  161.               <td class="content" width="150" bgcolor="#FFCC00">Tarikh Tamat</td>
  162.             <td class="content" width="147.5" bgcolor="#FFFF99">
  163.                 <? echo $kurs_last_date;?>
  164.             </td>
  165.             <td colspan="2" width="297.5">&nbsp;</td>
  166.             </tr>
  167.             <tr>    
  168.           <td class="content" width="150" bgcolor="#FFCC00">Penganjur</td>
  169.  
  170.           <td class="content" width="445" colspan="3" bgcolor="#FFFF99"> 
  171.             <?
  172.         $querypenganjur = "SELECT * FROM penganjur WHERE anjur_id='$anjur_name'";        
  173.         $resultpenganjur = mysql_query($querypenganjur) or die (mysql_error());
  174.         $view7 = mysql_fetch_array($resultpenganjur);
  175. ?>
  176.             <? echo $view7['anjur_name'];?> </td>
  177.           </tr>
  178.          <tr> 
  179.           <td class="content" width="595" valign="top" align="right" bgcolor="" colspan="4"> 
  180.             <b>[</b><a href="javascript:history.go(-1)" class="a">Back</a><b>]</b> 
  181.  
  182.             <br>
  183.             <br> </td>
  184.         </tr>
  185.  
  186.         </table><!-- end table form -->
  187.  
  188.      <?
  189.     }//end elseif Tambah Staf?>
  190.     </td>
  191.  </tr>
  192. </table><!-- end table background -->
  193. </body>
  194.  

i've got error message undefined index:Submit..but i still kt insert data in that form and when i submit,the data will save in table in database.but the error msg appear..so i dont get it..
Sep 24 '08 #1
8 10366
Markus
6,050 Expert 4TB
Welcome to the forums, Shai.

When posting code in the forums, you are to post them wrapped in code tags. Example: [code] code goes here ... [/code]. Please follow these rules as outline in the posting guidelines (which you are expected to have read already.)

Moderator
Sep 24 '08 #2
Markus
6,050 Expert 4TB
When you receive the said error, you are given a line number corresponding to the error. What is the line number? Help us help you.

Cheers.
Sep 24 '08 #3
Atli
5,058 Expert 4TB
Hi.

When you check whether your data has been submitted:
Expand|Select|Wrap|Line Numbers
  1. if($_POST['Submit'] == "Daftar")
  2.  
If it has been submitted, this will work fine, but when it hasn't been submitted the $_POST array won't contain an element named 'Submit'.
Which will produce a "Unidentified index" warning.

In your script it doesn't actually matter, because either way the if statement will evaluate FALSE, but to get rid of the warning, try checking if the index is set first using the isset function.
Sep 24 '08 #4
You can also try using the '@' before the statement so the warning doesn't show up =). But I would too use the isset function first.
Sep 24 '08 #5
Markus
6,050 Expert 4TB
You can also try using the '@' before the statement so the warning doesn't show up =). But I would too use the isset function first.
True, but bad programming. It's like women covering up their blemishes; it may look good on the night out, but that ugly programming will show in the morning.

Cheers,
Mark.
Sep 24 '08 #6
ok..i still new..n i will follow guideline after this...
erm the error show in line 98..
this program will have form..n i still can use the form..but there was error msg at the bottom..

Notice: Undefined index: Submit in C:\Program Files\VertrigoServ\www\elatihan\admin\kurs_baru.ph p on line 98

tq for the replying to all..
Sep 25 '08 #7
when i done this..it still running..the data that i post is save in the table on database..it just about the error msg appear at the bottom of the form..

tq for others tht reply n help me..
Sep 25 '08 #8
Markus
6,050 Expert 4TB
You get this error because PHP is checking for a $_POST['Submit'] when the form may not have been sent, therefore, the array will be empty.

As mentioned previously, you can append an @ symbol to surpress the error.

Expand|Select|Wrap|Line Numbers
  1. if ( @$_POST['Submit'] == 'Something' )
  2.  
Sep 25 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: Joe Blow | last post by:
Can anybody see a problem with this? Am I being stupid? if (!isset($_REQUEST) || "" == $_REQUEST) { throw new Exception("need query"); } else { echo "<p>Search words: $_REQUEST"; }
3
cassbiz
by: cassbiz | last post by:
Here are the errors that are coming up in my error_log Notice: Undefined index: andatum in /zipcode.php on line 11 Notice: Undefined index: andatum in /zipcode.php on line 12 Notice: Undefined...
7
by: javedna | last post by:
Hi guys Ive got a simple problem, im designing an online questionnaire and on submission the coding that I have used to validate whether a user has filled in all the questions is supposed to...
3
by: sickboy | last post by:
$channels=$_GET; if (empty($channels)) { $channels='blank'; } changechannels($channels); $theatre=$_GET; if (empty($theatre)) { $theatre='splash'; } changetheatre($theatre); $info=$_GET; if...
5
by: Pseudonyme | last post by:
Dear All : Ever had an httpd error_log bigger than the httpd access log ? We are using Linux-Apache-Fedora-Httpd 2006 configuration. The PHP lines code that lead too tons of errors are : ...
10
by: beam1985 | last post by:
So my problem lays in the $_POST if statement at the bottom operation, I keep getting Notice: Undefined index: delete and also Notice: Undefined index: checkbox. Please let me know if you have any...
22
by: V S Rawat | last post by:
(bringing the discussion here for php.general) I am on xpsp3, wampserver 2.0, having apache 2.2.8, php 5.2.6, MySQL 5.0.51b. http://localhost/ is E:\wamp\www\ I have put the first php script...
5
chelvan
by: chelvan | last post by:
Hi Forums When i doing following code, it do the query & show the result contain pages. but when i move to the next page that displays the error message. the error message is : Notice:...
4
by: complearn | last post by:
Do you know why I got these errors for status_bar.php in some webhost, but work perfectly on other webhost? Whats wrong? here are the codes from line 18, our webhost is running php5. ...
2
by: Smellydog | last post by:
I'm having a strange issue with PHP version 5.2.8 running on Windows Vista with Lighttpd. I receive a Notice that says the following: Notice</b>: Undefined index: name in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.