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 636931
In Process

The Archive Base Latest Questions

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

What’s wrong with my code, Im just a beginner. The error said it was

  • 0

What’s wrong with my code, Im just a beginner. The error said it was an undefined index.
A record is added to mysql but its just 0’s. What’ s the proper way of doing this

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

mysql_select_db("Hospital", $con);


$hospnum = mysql_real_escape_string($_POST['HOSPNUM']);
$rnum =  mysql_real_escape_string($_POST['ROOMNUM']);
$adate = mysql_real_escape_string($_POST['ADATE']);

$adtime = mysql_real_escape_string($_POST['ADTIME']);
$lname = mysql_real_escape_string($_POST['LASTNAME']);
$fname = mysql_real_escape_string($_POST['FIRSTNAME']);
$mname = mysql_real_escape_string($_POST['MIDNAME']);

$cs = mysql_real_escape_string($_POST['CSTAT']);
$age = mysql_real_escape_string($_POST['AGE']);
$ad = mysql_real_escape_string($_POST['ADDRESS']);
$bday = mysql_real_escape_string($_POST['BDAY']);

$telnum = mysql_real_escape_string($_POST['TELNUM']);
$sex = mysql_real_escape_string($_POST['SEX']);
$stats1 = mysql_real_escape_string($_POST['STAT']);
$stats2 = mysql_real_escape_string($_POST['STAT2']);
$stats3 = mysql_real_escape_string($_POST['STAT3']);
$stats4 = mysql_real_escape_string($_POST['STAT4']);
$stats5 = mysql_real_escape_string($_POST['STAT5']);
$stats6 = mysql_real_escape_string($_POST['STAT6']);
$stats7 = mysql_real_escape_string($_POST['STAT7']);
$stats8 = mysql_real_escape_string($_POST['STAT8']);
$nurse = mysql_real_escape_string($_POST['NURSE']);




      $sqlque="INSERT INTO t2 (HOSPNUM, ROOMNUM, ADATE, ADTIME, LASTNAME, FIRSTNAME, MIDNAME, CSTAT, AGE, BDAY, ADDRESS, TELNUM, SEX, STAT, STAT2, STAT3, STAT4, STAT5, STAT6, STAT7, STAT8, NURSE)
      VALUES ('$hospnum', '$rnum' , '$adate' , '$adtime', '$lname',  '$fname', '$mname', '$cs', '$age', '$bday', '$ad', '$telnum', '$sex','$stats1', '$stats2', '$stats3', '$stats4', '$stats5', '$stats6', '$stats7', '$stats8', '$nurse')"; 




if (!mysql_query($sqlque,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "<script>alert('Record successfully added in Table In-patient!')</script>";


mysql_close($con)


?>

Here’s the html form:

<html>
<head>
<script language="javascript" src="cal2.js">
/*
Xin's Popup calendar script-  Xin Yang (http://www.yxscripts.com/)
Script featured on/available at http://www.dynamicdrive.com/
This notice must stay intact for use
*/
</script>
<script language="javascript" src="cal_conf2.js"></script>
</head>
<body onLoad="show_clock()">
<style>
input { font-size: 16px;}
</style>
<?php include('header.php'); ?>
<div id="main_content">

</div>
<?php include('footer.php'); ?>
</head>
<table width="900" border="0" align="left" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="aisaction.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="16" style="background:#9ACD32; color:white; border:white 1px solid; text-align: center"><strong><font size="3">Add In-Patient</strong></td>
</tr>
<tr>

<td width="54"><font size="3">Hospital #</td>
<td width="3">:</td>
<td width="168"><input name="hnum" type="text" id="hospnum" maxlength="4"></td>

<td width="41"><font size="3">Room #</td>
<td width="3">:</td>
<td width="168"><input name="rnum" type="text" id="rnum" maxlength="4"></td>

<td width="67"><font size="3">Date</td>
<td width="3">:</td>
<td width="168"><input name="adate" type="text" id="adate" maxlength="15">







<td width="67"><font size="3">Time</td>
<td width="3">:</td>
<td width="168"><input name="adtime" type="text" id="adtime" maxlength="15">

</td>




</tr>
<tr>
<td><font size="3">Last Name</td>
<td>:</td>
<td><input name="lname" type="text" id="lname" maxlength="15"></td>
<td><font size="3">First Name</td>
<td>:</td>
<td><input name="fname" type="text" id="fname" maxlength="15"></td>
<td><font size="3">Middle Name</td>
<td>:</td>
<td><input name="mname" type="text" id="mname" maxlength="15"></td>
</tr>


<tr>
<td><font size="3">Civil Status</td>
<td>:</td>
<td>
    <select name="cs" id="cs">
        <option>Single</option>
        <option>Married</option>
        <option>Widowed</option>

    </select></td></td>
<td><font size="3">Age</td>
<td>:</td>
<td><input name="age" type="text" id="age" maxlength="3"></td>
<td><font size="3">Birthday</td>
<td>:</td>
<td><input name="bday" type="text" id="bday" maxlength="12">

</td>

</tr>

<tr>
<td><font size="3">Address</td>
<td>:</td>
<td><input name="ad" type="text" id="ad" maxlength="25"></td>
<td><font size="3">Telephone #</td>
<td>:</td>
<td><input name="telnum" type="text" id="telnum" maxlength="11"></td>

<td width="23"><font size="3">Sex</td>
<td width="3">:</td>
<td width="174"><input name="sex" type="text" id="sex" maxlength="1"></td>
</tr>

<tr>
<td><font size="3">Pls. Check</td>
<td>:</td>

<input type='hidden' name="stats1" value="0">
<td><input name="stats1" type="checkbox" id="SSS" value="SSS">SSS</td>
<td><font size="3"></td>
<td>:</td>
<input type='hidden' name="stats2" value="0">
<td><input name="stats2" type="checkbox" id="nonmed" value="NonMedicare">Non Medicare</td>

<td><font size="3"></td>
<td>:</td>
<input type='hidden' name="stats3" value="0">
<td><input name="stats3" type="checkbox" id="sh" value="stockholder">Stockholder</td>
</tr>


<tr>
<td><font size="3"></td>
<td></td>
<input type='hidden' name="stats4" value="0">
<td><input name="stats4" type="checkbox" id="gsis" value="GSIS">GSIS</td>
<td><font size="3"></td>
<td></td>
<input type='hidden' name="stats5" value="0">
<td><input name="stats5" type="checkbox" id="senior" value="seniorcitizen">Senior-Citizen</td>


<tr>
<td><font size="3"></td>
<td></td>
<input type='hidden' name="stats6" value="0">
<td><input name="stats6" type="checkbox" id="dep" value="dependent">Dependent</td>
<td><font size="3"></td>
<td></td>
<input type='hidden' name="stats7" value="0">
<td><input name="stats7" type="checkbox" id="emp" value="employee">Employee</td>
<td><font size="3"></td>
<td></td>
<input type='hidden' name="stats8" value="0">
<td><input name="stats8" type="text" id="" value="" maxlength="15">Others</td>

</tr>

<tr>
<td><font size="3">Admitting/Attending Nurse</td>
<td>:</td>
<td><input name="nurse" type="text" id="nurse" maxlength="15"></td>

</tr>






<tr>

<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Add"> <input type="reset" name="Reset" value="Reset"></td></td>

</form>



</tr>
</table>
</td>
</form>
</tr>
</table>
<table>
<tr><td>

</tr>
</table>


</html>

Here’s the error:

Notice: Undefined index: HOSPNUM in C:\wamp\www\backup\kamikorosutengenmyo510\aisaction.php on line 15

Notice: Undefined index: ROOMNUM in C:\wamp\www\backup\kamikorosutengenmyo510\aisaction.php on line 16

Notice: Undefined index: ADATE in C:\wamp\www\backup\kamikorosutengenmyo510\aisaction.php on line 17

Notice: Undefined index: ADTIME in C:\wamp\www\backup\kamikorosutengenmyo510\aisaction.php on line 19
  • 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-13T20:34:06+00:00Added an answer on May 13, 2026 at 8:34 pm

    I would say, that form names and then $_POST variables have to have same case – they are case sensitive.

    And you are having lowercase names in form and checking uppercase variables in $_POST

    As c0mrade pointed out, do

    var_dump($_POST);
    

    and it will tell you what variables are really going to your script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 446k
  • Answers 446k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You don't need the collect since you have the has-many-through… May 15, 2026 at 7:09 pm
  • Editorial Team
    Editorial Team added an answer Fraps is the archetypal example of doing this sort of… May 15, 2026 at 7:08 pm
  • Editorial Team
    Editorial Team added an answer The remote development server could be showing a working-copy. As… May 15, 2026 at 7:08 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.