Skip to main content
Inspiring
November 15, 2012
Answered

Now the form works but data captured is not writing to the database table

  • November 15, 2012
  • 1 reply
  • 2883 views

Hi

I have a form that works but does not move from where it is after the submit button is clicked.

Please advice

This topic has been closed for replies.
Correct answer Web_Decisions

So the page is now being redirected to ReportbyAll.php, but the rows are not being inserted? How are you verifying that? Is this a local testing server, or remote server?


Hi

I am closing this post as I have solved this and resolved this thru discussions.

1 reply

Participating Frequently
November 15, 2012

Question regarding server side scripting and database belong in the app dev forum. There, you will need to provide more details about the problem - scripting language, database, and examples of your code.

Inspiring
November 15, 2012

<?php require_once('Connections/dbAttendance.php'); ?>

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

  if (PHP_VERSION < 6) {

    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {

    case "text":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;   

    case "long":

    case "int":

      $theValue = ($theValue != "") ? intval($theValue) : "NULL";

      break;

    case "double":

      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";

      break;

    case "date":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

    case "defined":

      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

      break;

  }

  return $theValue;

}

}

$editFormAction = $_SERVER['PHP_SELF'];

if (isset($_SERVER['QUERY_STRING'])) {

  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {

  $insertSQL = sprintf("INSERT INTO attendlist (Windowsid, title, firstname, surname, extension, mobile, jobrole, course, cpg, mgrname, room) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",

                       GetSQLValueString($_POST['Wid'], "text"),

                       GetSQLValueString($_POST['title'], "text"),

                       GetSQLValueString($_POST['firstname'], "text"),

                       GetSQLValueString($_POST['surname'], "text"),

                       GetSQLValueString($_POST['contactno'], "text"),

                       GetSQLValueString($_POST['mobile'], "text"),

                       GetSQLValueString($_POST['jobrole'], "text"),

                       GetSQLValueString($_POST['courses'], "text"),

                       GetSQLValueString($_POST['cpg2'], "text"),

                       GetSQLValueString($_POST['mgrname2'], "text"),

                       GetSQLValueString($_POST['troom'], "text"));

  mysql_select_db($database_attending, $attending);

  $Result1 = mysql_query($insertSQL, $attending) or die(mysql_error());

  $insertGoTo = "ReportbyAll.php";

  if (isset($_SERVER['QUERY_STRING'])) {

    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";

    $insertGoTo .= $_SERVER['QUERY_STRING'];

  }

  header(sprintf("Location: %s", $insertGoTo));

}

mysql_select_db($database_dbAttendance, $dbAttendance);

$query_rsattendance = "SELECT * FROM attendlist";

$rsattendance = mysql_query($query_rsattendance, $dbAttendance) or die(mysql_error());

$row_rsattendance = mysql_fetch_assoc($rsattendance);

$totalRows_rsattendance = mysql_num_rows($rsattendance);

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {

  $insertSQL = sprintf("INSERT INTO attendlist (title, firstname, surname, extension, mobile, jobrole, course, cpg, mgrname, room, Adate) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",

                       GetSQLValueString($_POST['title'], "text"),

                       GetSQLValueString($_POST['firstname'], "text"),

                       GetSQLValueString($_POST['surname'], "text"),

                       GetSQLValueString($_POST['contactno'], "text"),

                       GetSQLValueString($_POST['mobile'], "text"),

                       GetSQLValueString($_POST['jobrole'], "text"),

                       GetSQLValueString($_POST['courses'], "text"),

                       GetSQLValueString($_POST['cpg2'], "text"),

                       GetSQLValueString($_POST['mgrname2'], "text"),

                       GetSQLValueString($_POST['troom'], "text"),

                       GetSQLValueString($_POST['Adate2'], "date"));

  mysql_select_db($database_attending, $attending);

  $Result1 = mysql_query($insertSQL, $attending) or die(mysql_error());

  $insertGoTo = "Listing.php";

  if (isset($_SERVER['QUERY_STRING'])) {

    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";

    $insertGoTo .= $_SERVER['QUERY_STRING'];

  }

  header(sprintf("Location: %s", $insertGoTo));

} ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Register</title>

<style type="text/css">

body {

          font: 100%/0.8 Verdana, Arial, Helvetica, sans-serif;

          background-color: #4E5869;

          margin: 0;

          padding: 0;

          color: #000;

}

/* ~~ Element/tag selectors ~~ */

ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */

          padding: 0;

          margin: 0;

}

h1, h2, h3, h4, h5, h6, p {

          margin-top: 0;           /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */

          padding-right: 15px;

          padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */

}

a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */

          border: none;

}

/* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */

a:link {

          color:#414958;

          text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */

}

a:visited {

          color: #4E5869;

          text-decoration: underline;

}

a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */

          text-decoration: none;

}

/* ~~ this container surrounds all other divs giving them their percentage-based width ~~ */

.container {

          width: 80%;

          max-width: 960px;/* a max-width may be desirable to keep this layout from getting too wide on a large monitor. This keeps line length more readable. IE6 does not respect this declaration. */

          min-width: 780px;/* a min-width may be desirable to keep this layout from getting too narrow. This keeps line length more readable in the side columns. IE6 does not respect this declaration. */

          background-color: #FFF;

          margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout. It is not needed if you set the .container's width to 100%. */

}

/* ~~the header is not given a width. It will extend the full width of your layout. It contains an image placeholder that should be replaced with your own linked logo~~ */

.header {

          background-color: #6F7D94;

}

/* ~~ This is the layout information. ~~

1) Padding is only placed on the top and/or bottom of the div. The elements within this div have padding on their sides. This saves you from any "box model math". Keep in mind, if you add any side padding or border to the div itself, it will be added to the width you define to create the *total* width. You may also choose to remove the padding on the element in the div and place a second div within it with no width and the padding necessary for your design.

*/

.content {

          padding: 10px 0;

}

/* ~~ This grouped selector gives the lists in the .content area space ~~ */

.content ul, .content ol {

          padding: 0 15px 15px 40px; /* this padding mirrors the right padding in the headings and paragraph rule above. Padding was placed on the bottom for space between other elements on the lists and on the left to create the indention. These may be adjusted as you wish. */

}

/* ~~ The footer ~~ */

.footer {

          padding: 10px 0;

          background-color: #6F7D94;

}

/* ~~ miscellaneous float/clear classes ~~ */

.fltrt {  /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */

          float: right;

          margin-left: 8px;

}

.fltlft { /* this class can be used to float an element left in your page. The floated element must precede the element it should be next to on the page. */

          float: left;

          margin-right: 8px;

}

.clearfloat { /* this class can be placed on a or empty div as the final element following the last floated div (within the #container) if the #footer is removed or taken out of the #container */

          clear:both;

          height:0;

          font-size: 1px;

          line-height: 0px;

}

</style>

<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />

<link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />

<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>

<script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>

<script language='JavaScript' type='text/javascript' src='TSScript/yahoo.js'></script>

<script language='JavaScript' type='text/javascript' src='TSScript/event.js'></script>

<script language='JavaScript' type='text/javascript' src='TSScript/dom.js'></script>

<script language='JavaScript' type='text/javascript' src='TSScript/calendar.js'></script>

<link rel='stylesheet' type='text/css' href='TSScript/TSCalendar/calendar.css' />

<script language='JavaScript' type='text/javascript' src='TSScript/TSCalendar/TSCalendar.js'></script>

</head>

<body>

<div class="container">

  <div class="header">

  <img src="Cerner At Imperial2.jpg" width="960" height="150" alt="" />

  </div>

  <div class="content">

    <h3>Attendance Register: </h3>

          <p><?php echo "Date  ".date("d/m/Y");?></p>

    <form action="<?php echo $editFormAction;?>" id="form1" name="form1" method="post">

      <table width="780" border="0" cellspacing="10" summary="Cerner@Imperial">

        <tr>

          <td><div align="right">* User ID</div></td>

          <td colspan="2"><span id="sprytextfield1">

            <input name="Wid" type="text" id="Wid" tabindex="1" size="18" maxlength="10" />

          <span class="textfieldRequiredMsg"> a value is required.</span></span></td>

          <td> </td>

        </tr>

        <tr>

          <td><div align="right">* Title</div></td>

          <td colspan="2"><span id="spryselect1">

            <select name="title" id="title" tabindex="2">

              <option value="0">Select</option>

              <option value="Ms">Ms</option>

              <option value="Mrs">Mrs</option>

              <option value="Mdm">Mdm</option>

              <option value="Mr">Mr</option>

              <option value="Dr">Dr</option>

              <option value="Professor">Prof</option>

            </select>

<span class="selectRequiredMsg">    Please select an item.</span></span></td>

          <td> </td>

        </tr>

        <tr>

          <td><div align="right">* First name</div></td>

          <td colspan="2"><span id="sprytextfield2">

            <input name="firstname" type="text" id="firstname" tabindex="3" size="40" maxlength="30" />

          <span class="textfieldRequiredMsg"> a value is required.</span></span></td>

          <td> </td>

        </tr>

        <tr>

          <td><div align="right">* Surname</div></td>

          <td colspan="2"><span id="sprytextfield5">

            <input name="surname" type="text" id="surname" tabindex="4" size="40" maxlength="30" />

          <span class="textfieldRequiredMsg"> a value is required.</span></span></td>

          <td> </td>

        </tr>

        <tr>

          <td><div align="right">* Contact/ Bleep</div></td>

          <td colspan="2"><span id="sprytextfield3">

            <input name="contactno" type="text" id="contactno" tabindex="5" size="10" maxlength="6" />

          <span class="textfieldRequiredMsg">a value is required.</span></span></td>

          <td> </td>

        </tr>

        <tr>

          <td><div align="right">Mobile (optional)</div></td>

          <td colspan="2"><input name="mobile" type="text" id="mobile" tabindex="6" size="25" maxlength="18" />          <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></td>

          <td> </td>

        </tr>

        <tr>

          <td> </td>

          <td colspan="2"> </td>

          <td> </td>

        </tr>

        <tr>

          <td><div align="right">* Job role</div></td>

          <td colspan="2"><span id="spryselect2">

            <select name="jobrole" id="jobrole" tabindex="7">

              <option value="0">Select</option>

              <option value="Doctor">Doctor</option>

              <option value="CNS/NP">CNS/NP</option>

              <option value="Midwife">Midwife</option>

              <option value="Other Staff">Other Staff</option>

              <option value="Nurse IP HCA">Nurse IP & HCA</option>

              <option value="Nurse OP HCA">Nurse OP & HCA</option>

              <option value="IP Physician Assitant">IP Physician Assistant</option>

              <option value="OP Phlebotomist">OP Phlebotmist</option>

              <option value="Pharmacists">Pharmacists</option>

              <option value="Therapist AHP">Therapist & AHP</option>

              <option value="Medical Secretary">Medical Secretary</option>

              <option value="Bed Manager">Bed Manager</option>

              <option value="Medical Record Staff">Medical Records</option>

              <option value="Medical Records Manager">Medical Records Mgr</option>

              <option value="OP Booking Clerk">OP Booking Clerk</option>

              <option value="OP Receptionist">OP Receptionist</option>

              <option value="ED Admin">ED Admin</option>

              <option value="Ward Administrator">Ward Administrator</option>

              <option value="IP Wait List Clerk/Mgr">IP Wait List Clerk/Mgr</option>

              <option value="Antenatal Supervisor">Antenatal Supervisor</option>

              <option value="Clinical Coder">Clinical Coder</option>

              <option value="Clinical Coding Mgr">Clinical Coding Mgr</option>

              <option value="Pi Help Desk Backoffice">Pi Help Desk Analyst/Back Office</option>

            </select>

          <span class="selectInvalidMsg">Please select a valid item.</span></span></td>

          <td> </td>

        </tr>

        <tr>

          <td><div align="right">* Manager's Name</div></td>

          <td colspan="2"><span id="sprytextfield4">

          <input name="mgrname2" type="text" id="mgrname2" tabindex="8" size="40" maxlength="30" />

          <span class="textfieldRequiredMsg"> a value is required.</span></span></td>

          <td> </td>

        </tr>

        <tr>

      

          <td><div align="right"></div></td>

          <td colspan="2"> </td>

          <td> </td>

        </tr>

        <tr>

          <td> </td>

          <td colspan="2"> </td>

          <td> </td>

        </tr>

        <tr>

          <td><div align="right">* Course</div></td>

          <td colspan="2"><span id="spryselect3">

            <select name="courses" id="courses" tabindex="10" title="course">

              <option value="0">Select</option>

              <option value="Doctors">Doctors</option>

              <option value="Nurse IP">Nurse IP</option>

              <option value="Nurse OP">Nurse OP</option>

              <option value="Midwife">Midwife</option>

              <option value="HCA">HCA</option>

              <option value="Pharmacist">Pharmacist</option>

              <option value="Back Office Staff">Back Office Staff</option>

              <option value="AHP">AHP</option>

              <option value="Pi Help Desk Analyst">Pi Help Desk Analyst</option>

              <option value="Medical Secretary">Medical Secretary</option>

              <option value="OP Phlebotmist">OP Phlebotmist</option>

              <option value="Champion Users Doctors">Champion Users Doctors</option>

              <option value="Champion Users Nurse IP">Champion Users Nurse IP</option>

            </select>

          <span class="selectRequiredMsg">Please select an item.</span></span></td>

          <td> </td>

        </tr>

        <tr>

          <td><div align="right">* Training Location </div></td>

          <td><span id="spryselect4">

            <select name="troom" id="troom"  tabindex="11" title="location">

              <option value="0">Select</option>

              <option value="CXH">Charing Cross</option>

              <option value="HH">Hammersmith Hammersmith</option>

              <option value="QEH">Queen Charlottee Hospital</option>

              <option value="SMH">St Mary's Hospital</option>

              <option value="WEH">Western Eye Hospital</option>

              <option value="SCC">St Charles Community</option>

            </select>

          <span class="selectRequiredMsg">Please select an item.</span></span></td>

         

          <td> </td>

          <td> </td>

        </tr>

        <tr>

          <td><div align="right">* CPG</div></td>

          <td><span id="spryselect5">

            <select name="cpg2"  id="cpg2"  tabindex="12" title="cpg">

              <option value="0">Select</option>

              <option value="CPG 1 Medicine">CPG1 - Medicine</option>

              <option value="CPG 2 Surgery & Cancer">CPG2 - Surgery and Cancer</option>

              <option value="CPG3 Specialist Services">CPG3 - Specialist Services</option>

              <option value="CPG4 Circulatory Services and Renal Medicine">CPG4 - Circulatory Services and Renal Medicine</option>

              <option value="CPG5 Womens and Childrens">CPG5 - Womens and Childrens</option>

              <option value="CPG6 Clinical and Investigative Sciences">CPG6 - Clinical and Investigative Sciences</option>

              <option value="CP7 Private Patients">CPG7 - Private Patients</option>

              <option value="Others">Others</option>

            </select>

          <span class="selectRequiredMsg">Please select an item.</span></span></td>

          <td> </td>

          <td> </td>

        </tr>

        <tr>

          <td> </td>

          <td><input type="submit" name="submitbt" id="submitbt" value="Submit" /></td>

          <td> </td>

          <td> </td>

        </tr>

        <tr>

          <td> </td>

          <td colspan="2"> </td>

          <td> </td>

        </tr>

        <tr>

          <td><div align="center">* Mandatory Fields</div></td>

          <td colspan="2"> </td>

          <td> </td>

        </tr>

        <tr>

          <td> </td>

          <td colspan="2"> </td>

          <td> </td>

        </tr>

        <tr>

          <td> </td>

          <td colspan="2"> </td>

          <td> </td>

        </tr>

      </table>

      <input type="hidden" name="MM_insert" value="form1" />

    </form>

    <p> </p>

    <p> </p>

  <div class="footer">

<script type="text/javascript">

var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["blur", "change"]});

var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {validateOn:["blur", "change"]});

var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none", {validateOn:["blur", "change"]});

var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "none", {validateOn:["blur", "change"]});

var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "integer", {validateOn:["blur", "change"]});

var spryselect2 = new Spry.Widget.ValidationSelect("spryselect2", {invalidValue:"-1", isRequired:false, validateOn:["blur", "change"]});

var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "none", {validateOn:["blur"]});

var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "none", {validateOn:["blur", "change"]});

var spryselect3 = new Spry.Widget.ValidationSelect("spryselect3");

var spryselect4 = new Spry.Widget.ValidationSelect("spryselect4");

var spryselect5 = new Spry.Widget.ValidationSelect("spryselect5", {validateOn:["blur", "change"]});

</script>

</div>

</div>

<p>

    <a href="http://validator.w3.org/check?uri=referer"><img

      src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>

  </p>

  <P></P>

 

</div>

</body>

</html>

<?php

mysql_free_result($rsattendance);

?>

sudarshan.t
Inspiring
November 15, 2012

Moved thread to Developing server-side applications in DW for better responses.