Hi there, I having problem with my dynamic webpages designed with PHP and MySQL. There is a undefined index notice of 'student_name'. The notice is from the highlighted line below.

My codes:

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "frmedituser")) {
$updateSQL = sprintf("UPDATE student SET student_name=%s, student_ic=%s, student_gender=%s, student_race=%s, student_religion=%s, student_address_c=%s, student_email=%s, `year`=%s, year_intake=%s, program=%s, student_contact=%s, student_address=%s, lect_id=%s, medical=%s, medical_name=%s, medical_relation=%s, medical_contact=%s, medical_address=%s, admin_id=%s, admin_update=%s WHERE student_id=%s",
                       GetSQLValueString($_POST['student_name'], "text"),
                       GetSQLValueString($_POST['student_ic'], "text"),
                       GetSQLValueString($_POST['student_gender'], "text"),

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmstuconfirm")) {
  $insertSQL = sprintf("INSERT INTO student (student_id, student_pass, student_update, student_name, `year`, year_intake, program, lect_id, admin_id, admin_update) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['student_id'], "int"),
                       GetSQLValueString($_POST['student_pass'], "text"),
                       GetSQLValueString($_POST['student_update'], "text"),
                       GetSQLValueString($_POST['student_name'], "text"),


<tr bgcolor="#FFFFCC">
<td width="118" height="22"><strong>&nbsp;&nbsp;&nbsp;Name</strong>
<input name="id" type="hidden" id="id" value="student" />
<input name="student" type="hidden" id="student" value="confirm" /></td>
<td width="12" height="22"><strong>:</strong></td>
<td width="420" height="22">
<strong id="sprytextfield47">
<label>
<input style="color: #009; font-family: Verdana, Geneva, sans-serif; font-size: 11px;" name="student_name" type="text" id="student_name" value="[B][COLOR="Red"]<?php echo $_REQUEST['student_name']; ?>[/COLOR][/B]" size="35" maxlength="100" />
</label>
</strong>
<strong style="color: #F00; font-size: 10px;">*</strong><strong class="style27 style25" style="color: #999; font-size: 10px"> eg: Rahmah Binti Abu Bakar</strong></td>
</tr> 

<tr bgcolor="#FFFFCC">
<td width="118" height="22"><strong>&nbsp;&nbsp;&nbsp;Name</strong></td>
<td width="12" height="22"><strong>:</strong></td>
<td width="420" height="22"><?php echo $student_name=$_REQUEST['student_name'];?></td>
</tr>
<tr bgcolor="#D6F5F5">
<td width="118" height="22"><strong>&nbsp;&nbsp;&nbsp;Year</strong></td>
<td width="12" height="22"><strong>:</strong></td>
<td width="420" height="22"><?php echo $year=$_REQUEST['year'];?></td>
</tr>

    You're assuming that $REQUEST['student_name'] always exists when this page is requested (and the same for all the other $REQUEST fields).

    If it doesn't exist (because it wasn't part of the request), you'll get this message as soon as you try to use it.

    In short, check first.

      Thanks. I solve that but another index notice shown up. It states my "program" is undefined. The line is highlighted below.

      Codes:

      <label>
      <select style="color: #009; font-family: Verdana, Geneva, sans-serif; font-size: 11px;" name="year" id="year">
      <option value="1" <?php if (!(strcmp(1, $REQUEST['year']))) {echo "selected=\"selected\"";} ?>>1</option>
      <option value="2" <?php if (!(strcmp(2, $
      REQUEST['year']))) {echo "selected=\"selected\"";} ?>>2</option>
      <option value="3" <?php if (!(strcmp(3, $REQUEST['year']))) {echo "selected=\"selected\"";} ?>>3</option>
      <option value="4" <?php if (!(strcmp(4, $
      REQUEST['year']))) {echo "selected=\"selected\"";} ?>>4</option>
      <option value="5" <?php if (!(strcmp(5, $REQUEST['year']))) {echo "selected=\"selected\"";} ?>>5</option>
      <option value="6" <?php if (!(strcmp(5, $
      REQUEST['year']))) {echo "selected=\"selected\"";} ?>>6</option>
      </select>
      </label>
      </strong>
      <strong style="color: #F00; font-size: 10px;">*</strong>
      </td>
      <tr bgcolor="#FFFFCC">
      <td width="118" height="22"><strong>&nbsp;&nbsp;&nbsp;Programme</strong></td>
      <td width="12" height="22"><strong>:</strong></td>
      <td width="420" height="22">
      <strong id="spryselect14">

      <label>
      <select style="color: #009; font-family: Verdana, Geneva, sans-serif; font-size: 11px;" name="program" id="program">
      <option value="Electronic and Computer Engineering" <?php if (!(strcmp("Electronic and Computer Engineering", $REQUEST['program']))) {echo "selected=\"selected\"";} ?>>Electronic and Computer Engineering</option>
      <option value="Electronic and Telecommunication Engineering" <?php if (!(strcmp("Electronic and Telecommunication Engineering", $
      REQUEST['program']))) {echo "selected=\"selected\"";} ?>>Electronic and Telecommunication Engineering</option>
      <option value="Civil Engineering" <?php if (!(strcmp("Civil Engineering", $REQUEST['program']))) {echo "selected=\"selected\"";} ?>>Civil Engineering</option>
      <option value="Mechanical Engineering" <?php if (!(strcmp("Mechanical Engineering", $
      REQUEST['program']))) {echo "selected=\"selected\"";} ?>>Mechanical Engineering</option>
      <option value="Chemical Engineering" <?php if (!(strcmp("Chemical Engineering", $_REQUEST['program']))) {echo "selected=\"selected\"";} ?>>Chemical Engineering</option>
      </select>

        3 months later

        Hi,

        I have written a code to generate a calendar in php. But my calendar isn't perfect enough as much as I am expected. It show current month, year but not the current day. I wish highlight the current day.

        Here is the code for the calendar:

        <?php
          $monthNames = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
        
        if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
        if (!isset($_REQUEST["year"]))  $_REQUEST["year"]  = date("Y");
        
          $cMonth = $_REQUEST["month"];
          $cYear  = $_REQUEST["year"];
        
          $prev_year = $cYear;
          $next_year = $cYear;
        
        
        $prev_month = $cMonth-1;
        $next_month = $cMonth+1;
        
        if ($prev_month == 0 ) {
        $prev_month = 12;
        $prev_year = $cYear - 1;
          }
         	if ($next_month == 13 ) {
            $next_month = 1;
            $next_year = $cYear + 1;
          }
        ?>
           <div id="calendar_div" name="calendar_div">
            <table width="200">
                <tr align="center">
                  <td bgcolor="#999999" style="color:#FFFFFF">
                    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td width="50%" align="left">&nbsp;&nbsp;<a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&year=" . $prev_year; ?>" style="color:#FFFFFF">Previous</a></td>
                              <td width="50%" align="right"><a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&year=" . $next_year; ?>" style="color:#FFFFFF">Next</a>&nbsp;&nbsp;</td>
                            </tr>
                      </table>
                  </td>
                </tr>
                <tr>
                    <td align="center">
                      <table width="100%" border="0" cellpadding="2" cellspacing="2">
                        <tr align="center">
                          <td colspan="7" bgcolor="#999999" style="color:#FFFFFF"><strong><?php echo $monthNames[$cMonth-1].' '.$cYear; ?></strong></td>
                        </tr>
                        <tr>
                          <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>S</strong></td>
                          <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>M</strong></td>
                          <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>T</strong></td>
                          <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>W</strong></td>
                          <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>T</strong></td>
                          <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>F</strong></td>
                          <td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>S</strong></td>
                        </tr>
        
                    <?php 
        
                    	$timestamp = mktime(0,0,0,$cMonth,1,$cYear);
                    	$maxday    = date("t",$timestamp);
                    	$thismonth = getdate ($timestamp);
        
        				$startday  = $thismonth['wday'];
        
                      for ($i=0; $i<($maxday+$startday); $i++) {
                        if(($i % 7) == 0 ) echo "<tr>\n";
                        if($i < $startday) echo "<td></td>\n";
                        else echo "<td align='center' valign='middle' height='20px'>". ($i - $startday + 1) . "</td>\n";
                        if(($i % 7) == 6 ) echo "</tr>\n";
                      }
        
                     ?>
        
                  </table>
                </td>
            </tr>
        </table>
        </div>

        How to make the current day being highlighted automatically as time day passed. I appreciate any help offered. Thanks in advance.

          Write a Reply...