Im using ThickBox 3.1 and regretting it since it is no longer supported and Im new to programming so I could use all the help I can get.
Im almost done setting up several Thickboxes on my site but my last one requires a variable to be passed from the parent page to ThickBox and I just can't seem to pick it up in my php script. I have a parent page that is getting the variable from a currently selected drop down menu. When I hover over the link that will open the ThickBox Modal I see:
http://localhost/forms/modal_product.html?strUser=100&TB_iframe=true&height=300&width=590
which is great because I need the strUser variable. So the ThickBox opens I enter some information into a short form just like my other ThickBoxes but nothing happens. When I look under firebug to see the AJAX response it informs me that:
<b>Notice</b>: Undefined index: strUser in <b>C:\xampp\htdocs\forms\item_add.php</b> on line <b>3</b
Ive tried seeing what $_SERVER['QUERY_STRING']; comes up with and it is NULL.
I think my question is generic in that I just don't know where my _GET variable is going? Can anyone with experience with ThickBox help me out? Ive read my butt off and I realize in older versions of ThickBox it was harder to pass variables and it required hacks but I should be able to do this the way I have it. What am I doing wrong? Is there an easier way to pass variables or am I just missing something obvious?
Also when I go to my form page directly and not as a link through the parent window, if I manually put a GET variable into the URL it still gives me the same errors which leads me to believe I'm just missing something basic. Here is my php code.
<?php
include '../dbc.php';
$getman = ($_GET['strUser']);
$manid1 = mysql_query("SELECT manufacturer_id FROM manufacturers WHERE man_name='$getman'");
$manid11 = mysql_fetch_array($manid1);
$manid21 = $manid11[0];
if ($_POST) {
// Collect POST data from form
$item_num = stripslashes($_POST['item_num']);
$descript = stripslashes($_POST['descript']);
$quanti = stripslashes($_POST['quanti']);
$fdaa = stripslashes($_POST['fdaa']);
}
$params = $_SERVER['QUERY_STRING'];
$domain = $_SERVER['SCRIPT_NAME'];
$queryString = $_SERVER['REQUEST_URI'];
$stmnt2 = mysql_query("INSERT INTO products (product_id, item_number, description, quantity_per_unit, fda_approved, manufacturer_id) VALUES ('NULL', '" . $item_num . "', '" . $descript . "' ,'" . $quanti . "', '" . $fdaa . "' , '" . $manid21 . "')");
$resp['status'] = 'success';
if ($stmnt2) {
$resp['errmessage'] = "Item submitted. Submit another item or click close.";
} else {
$resp['errmessage'] = $params;
}
echo json_encode($resp);
?>
I worked it out. I had to pull the variable in Jquery from the URL, put it into a hidden field and then run my php script.