473,802 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with this..Notice: Undefined index

3 New Member
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..b ut 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 10388
Markus
6,050 Recognized Expert Expert
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 Recognized Expert Expert
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 Recognized Expert Expert
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 "Unidentifi ed 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
gabosom
9 New Member
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 Recognized Expert Expert
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
shaielinna
3 New Member
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\VertrigoS erv\www\elatiha n\admin\kurs_ba ru.php on line 98

tq for the replying to all..
Sep 25 '08 #7
shaielinna
3 New Member
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 Recognized Expert Expert
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
1787
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
4967
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 index: abdatum in /zipcode.php on line 13 Notice: Undefined index: zimmer in /zipcode.php on line 14 Notice: Undefined index: city in /zipcode.php on line 39 Notice: Undefined index: state in /zipcode.php on line 41
7
2106
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 identify any questions they have missed out and print out a simple error message. It correctly identify which questions have not been filled in but returns the following error message too: . . .
3
3878
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 (empty($info)) { $info='noinfo'; } changeinfo($info); Hey everyone, I keep getting an error regarding the above code. These are the errors: Notice: Undefined index: channels in /home/forcefed/public_html/index.php on line 5
5
7369
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 : $http_ref= $HTTP_REFERER; $prog = $_COOKIE;
10
2389
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 ideas or suggestions im desperate to get this working, its part of my midterm project due tomorrow! Thank you so much $host="localhost"; // Host name $username="username"; // Mysql username $password="pass"; // Mysql password ...
22
3834
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 to hello.php file: <html> <head> <title>PHP Test</title>
5
1612
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: Undefined index: h1 in C:\AppServ\www\facebook\findpepoles.php on line 65 (marked as ------error #1) Notice: Undefined index: txtser in C:\AppServ\www\facebook\findpepoles.php on line 66 (marked as ------error #2)
4
2909
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. $dmg = ($_GET == 0 || $_GET == '22') ? $_GET : $_GET+$_GET;
2
4590
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 <b>E:\LightTPD\htdocs\go\go\form.php</b> on line <b>160</b> Here is the odd part. No matter what I do, no matter how many times I change the script, add lines, remove lines, the notice keeps referencing the same file and line number. Even when I comment out the line,...
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9559
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10529
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9107
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7596
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6835
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5620
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3788
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2964
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.