Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 609467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:34:12+00:00 2026-05-13T17:34:12+00:00

I try to update the data making use of checkboxes. But when one or

  • 0

I try to update the data making use of checkboxes. But when one or more of the checkboxes is not checked, a notice is returned:

Notice: Undefined index: stats2 in E:\wamp\www\HOSPITAL\update.php on line 12

Notice: Undefined index: stats3 in E:\wamp\www\HOSPITAL\update.php on line 12

Notice: Undefined index: stats5 in E:\wamp\www\HOSPITAL\update.php on line 12

<?php
    $con = mysql_connect("localhost","root","");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }

    mysql_select_db("Hospital", $con);




       mysql_query("UPDATE t2 SET HOSPNUM ='$_POST[hnum]', ROOMNUM='$_POST[rnum]', ADDATE= '$_POST[ad8]', ADTIME='$_POST[adtym]', LASTNAME='$_POST[lname]', FIRSTNAME='$_POST[fname]', MIDNAME='$_POST[mname]', CSTAT='$_POST[cs]', AGE='$_POST[age]', BDAY='$_POST[bday]', ADDRESS='$_POST[ad]', SEX='$_POST[sex]', 
                                                                                                                                                                                                                                                                                                               STAT='$_POST[stats1]', STAT2='$_POST[stats2]', STAT3='$_POST[stats3]', STAT4='$_POST[stats4]', STAT5='$_POST[stats5]', STAT6='$_POST[stats6]', STAT7='$_POST[stats8]', STAT8='$_POST[stats8]', NURSE='$_POST[nurse]'              
        WHERE TELNUM ='$_POST[telnum]'");



    mysql_close($con)
    ?>

Could you help me, so that the notice would not show up?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:34:12+00:00Added an answer on May 13, 2026 at 5:34 pm

    This is the defined behavoir for checkboxes – only when set are they included in the form data.

    You should use isset() to determine if the checkbox is ticked.

    change it to

    STAT='".isset($_POST['stats1']).", 
    STAT2='".isset($_POST['stats2']).", 
    STAT3='".isset($_POST['stats3']).", 
    STAT4='".isset($_POST['stats4']).",  
    STAT5='".isset($_POST['stats5']).", 
    STAT6='".isset($_POST['stats6']).", 
    STAT7='".isset($_POST['stats8']).", 
    STAT8='".isset($_POST['stats8'])." 
    

    Another workaround which works is to add a hidden variable, with the same name, before the checkbox: e.g.

    <form action='t1.php' method='post'>
    <input type='hidden' name="cb1" value="0">
    <input type='checkbox' name="cb1" title='test'>
    <input type='submit'  >
    </form>
    <?php 
    print_r($_POST);
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to update a LINQ data source bound to a grid view,
I continually get these errors when I try to update tables based on another
I try to fetch a Wikipedia article with Python's urllib: f = urllib.urlopen(http://en.wikipedia.org/w/index.php?title=Albert_Einstein&printable=yes) s
I try to add an addons system to my Windows.Net application using Reflection; but
I try Request.Form.Set(k, v) but it's throwing exception Collection is read-only
I'm making a little game in C. I try to program in an object-oriented
I recently restructured some data in a game I'm working on by making the
I want to update data from my database using java. I have established my
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
try { ... } catch (SQLException sqle) { String theError = (sqle).getSQLState(); ... }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.