o - I AM A NEWBIE
OK, I am trying to get my form to work right. I can get it to pull from the database, but I can't get it to function like I want it to - CAN SOMEONE PLEASE HELP ME UNDERSTAND! I'm TERRIFIABLY EMBARRASED.
I see this question asked through the forum, but can't really follow it because it seems specific to the developer.
I want the user to select the "State" that they are in from the drop down menu, the next menu will dynamically populate from the first menu selection and let the user select available classes in that State. When they select the class, the next menu will populate the date and then display the times and course description below. They will be able to check mark the course and continue to the checkout page to pay.
Below is the code that I am working with . . . I have a HTTP.Request Wrapper and know that I have to modify it as well. My concern is that I'm sure I have to incorproate AJAX and PHP to GET from the MYSQL database.
HELP IF YOU CAN!
Here is the weblink: www.greps.org/coursereg.php
________________
<?php require_once('Connections/db_9g004oc.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;
}
}
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"] == "ocrform")) {
$insertSQL = sprintf("INSERT INTO attendance (First Name, Last Name, Email, Course, Day, Time) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($POST['fn_ocr2'], "text"),
GetSQLValueString($POST['ln_ocr3'], "text"),
GetSQLValueString($POST['email_ocr4'], "text"),
GetSQLValueString(isset($POST['course_cb']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($POST['dt_ocr7'], "text"),
GetSQLValueString($POST['tm_ocr8'], "text"));
mysql_select_db($database_db_9g004oc, $db_9g004oc);
$Result1 = mysql_query($insertSQL, $db_9g004oc) or die(mysql_error());
$insertGoTo = "confirmation.html";
if (isset($SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_db_9g004oc, $db_9g004oc);
$query_rs_attendance = "SELECT * FROM attendance";
$rs_attendance = mysql_query($query_rs_attendance, $db_9g004oc) or die(mysql_error());
$row_rs_attendance = mysql_fetch_assoc($rs_attendance);
$totalRows_rs_attendance = mysql_num_rows($rs_attendance);
$colname_rs_course = "-1";
if (isset($GET['Category'])) {
$colname_rs_course = $GET['Category'];
}
mysql_select_db($database_db_9g004oc, $db_9g004oc);
$query_rs_course = sprintf("SELECT * FROM courses WHERE State = %s ORDER BY State ASC", GetSQLValueString($colname_rs_course, "text"));
$rs_course = mysql_query($query_rs_course, $db_9g004oc) or die(mysql_error());
$row_rs_course = mysql_fetch_assoc($rs_course);
$totalRows_rs_course = mysql_num_rows($rs_course);
?>
<script src="ocrequest.js"></script>
<script src="ocrequest.js"></script>
<script>
function handleOnChange(dd1)
{
var idex=dd1.selectedIndex;
var val = dd1 (idx).text
var par = document.forms ["ocrform"];
var parelemts = par.elements;
var catsel = parelmts ["category"]
var category = val
if (state ! = "Select State")
{
var directory = " " + document.location;
director = directory.substr(0, directory.lastIndexOf ('.'));
http.get({
url: “./” + state + “.txt”,
callback: state
cache: Http.Cache.Get
}, {statesel}];
}
}
Function fillstate (xmlreply, stateelmt)
{
If (xmlreply.status == Http.Status.OK
{
Var stateresponse = xmlreply.responseText;
Var state = stateresponse.split (“||);
Stateelmt.length = 1;
Stateelmt.length = state.length,
For (o=1; o < state.length; o++)
}
}
Else
{
Alert (“Cannot handle the Ajax call.”),
}
)
</script>[/SIZE][/SIZE]