Having a problem that when I want to submit a form, I don't get the values from the input fields (with $_POST).
I use fetcher.js to load the PHP page with the form into a DIV
Code for fetcher.js is below
function loadContent(url, divID)
{
var xmlRequest = null;
if(window.XMLHttpRequest)
xmlRequest = new XMLHttpRequest();
else if (window.ActiveXObject)
xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
xmlRequest.onreadystatechange = function()
{
if(xmlRequest.readyState == 4)
{
if(xmlRequest.status == 200)
document.getElementById(divID).innerHTML = xmlRequest.responseText;
else
alert("Error: " + xmlRequest.status);
}
}
xmlRequest.open("POST", url, true);
xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlRequest.send(null);
}
then I have the page which is loaded into cpanel.php (DIV ID cpanel) called portfolio_edit.php
//DO UPDATE QUERY
if (isset($_POST['sub_update_x'])) {
$q_editportfolio = "UPDATE portfolio SET p_name='" . $_POST['fld_name'] . "', p_client='" . $_POST['fld_client'] . "', p_techniques='" . $_POST['fld_techniques'] . "', p_url='" . $_POST['fld_url'] . "', p_cms='" . $_POST['fld_cms'] . "', p_isonline='" . $_POST['fld_isonline'] . "', p_desc='" . $_POST['fld_desc'] . "', p_datelastupdate='" . $unixtimestamp . "' WHERE p_id = '" . $_GET['id'] . "'";
$r_editportfolio = mysql_query($q_editportfolio) or die(mysql_error());
}
//SHOW FORM
<form method="post" action="" id="frmEdit">
<table width="500" border="0" cellpadding="0" cellspacing="0">
<?php
echo '
<tr>
<td width="100" height="30" align="center" valign="middle" class="txt_12px_bold">
Project :
</td>
<td width="400" height="30" align="left" valign="middle">
<input name="fld_name" id="fld_name" value="' . $obj_portfolio->p_name . '" type="text" class="inputbox_admincp_400px" maxlength="100" onfocus="this.style.background=\'#f8f8f7\'" onblur="this.style.background=\'#fafafa\'">
</td>
<tr>
<tr>
<td width="100" height="30" align="center" valign="middle" class="txt_12px_bold">
Client :
</td>
<td width="400" height="30" align="left" valign="middle">
<input name="fld_client" id="fld_client" value="' . $obj_portfolio->p_client . '" type="text" class="inputbox_admincp_400px" maxlength="100" onfocus="this.style.background=\'#f8f8f7\'" onblur="this.style.background=\'#fafafa\'">
</td>
<tr>
<tr>
<td width="100" height="30" align="center" valign="middle" class="txt_12px_bold">
Technieken :
</td>
<td width="400" height="30" align="left" valign="middle">
<input name="fld_techniques" id="fld_techniques" value="' . $obj_portfolio->p_techniques . '" type="text" class="inputbox_admincp_400px" maxlength="100" onfocus="this.style.background=\'#f8f8f7\'" onblur="this.style.background=\'#fafafa\'">
</td>
<tr>
<tr>
<td width="100" height="30" align="center" valign="middle" class="txt_12px_bold">
URL :
</td>
<td width="400" height="30" align="left" valign="middle">
<input name="fld_url" id="fld_url" value="' . $obj_portfolio->p_url . '" type="text" class="inputbox_admincp_400px" maxlength="100" onfocus="this.style.background=\'#f8f8f7\'" onblur="this.style.background=\'#fafafa\'">
</td>
<tr>
<tr>
<td width="100" height="30" align="center" valign="middle" class="txt_12px_bold">
CMS :
</td>
<td width="400" height="30" align="left" valign="middle">
<select name="fld_cms" id="fld_cms" class="dropdownbox_admincp_100px">
<option value="1">Ja</option>
<option value="2">Nee</option>
</select>
</td>
<tr>
<tr>
<td width="100" height="30" align="center" valign="middle" class="txt_12px_bold">
Is online? :
</td>
<td width="400" height="30" align="left" valign="middle">
<select name="fld_isonline" id="fld_isonline" class="dropdownbox_admincp_100px">
<option value="1">Ja</option>
<option value="2">Nee</option>
</select>
</td>
<tr>
<tr>
<td colspan=2 width="500" height="30" align="left" valign="middle">
</td>
<tr>
<tr>
<td colspan=2 width="500" align="left" valign="middle">
<textarea name="fld_desc" id="fld_desc" rows="10" class="inputbox_500px">' . $obj_portfolio->p_desc . '</textarea>
</td>
<tr>
<tr>
<td colspan=2 width="500" height="50" align="center" valign="bottom">
<input type="hidden" id="HDid" value="' . $_GET['id'] . '" />
<input type="image" src="../images/sub_update.gif" border="0" name="sub_update" id="sub_update" title="Update" alt="Update" class="image_noborder">
</td>
<tr>
';
?>
</table>
</form>
But for some reason I don't get the $POST values or even better the "if (isset($POST['sub_update_x'])) {" does not even get triggered
Anyone an idea ?