PHP - Dom Input Value Not Changing.
Hi, I'm having a problem with a hidden input value not changing on the browser after a request. I can change the value and alert or console log the new value but it won't change the DOM. Here's the section I'm having problems with:
xhr.onload = function() { if (xhr.status === 200) { var data = JSON.parse(this.responseText); $(".token").attr('value', data.token); alert($(".token").val()); } else { console.log('Something went terribly wrong...'); } }; Edited by Millertime1, 16 August 2014 - 03:34 PM. Similar TutorialsCan be those <input ...> types with values changed from a script ?. Imagine it like we have an admin and we want to change some input values with a generated form on that page instead of going source and changing 1 by 1 ? Hi, at the beginning i would like to apologize for my English if there will be some mistakes . I heve proble with changing standard <select> code with <options> to normal input with check box( it's very annoying when you need to press ctrl to select more then one options, that's why i wish to have check box This is original code with <select> <?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); /** * Paramater search for phpShop * @author Zdenek Dvorak (zdenek.dvorak@seznam.cz) * * @version $Id: shop.parameter_search_form.php 1452 2008-07-08 17:21:42Z soeren_nb $ * @package VirtueMart * @subpackage html * @copyright Copyright (C) 2004-2008 soeren - All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details. * * http://virtuemart.net */ $q = "SELECT * FROM #__{vm}_product_type "; $q .= "WHERE product_type_id='$product_type_id' "; $q .= "AND product_type_publish='Y'"; $db->query($q); $browsepage = $db->f("product_type_browsepage"); $vm_mainframe->setPageTitle( $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH') ); $pathway[] = $vm_mainframe->vmPathwayItem( $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH') ); $vm_mainframe->vmAppendPathway($pathway); echo "<h2>".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH')."</h2>"; if (!$db->next_record()) { // There is no published Product Type echo $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_BAD_PRODUCT_TYPE'); } else { echo "<table width=\"100%\" border=\"0\">\n<tr><td width=\"40%\">"; echo $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IN_CATEGORY').": ".$db->f("product_type_name"); // Reset form echo "</td><td align=\"center\">"; echo "<form action=\"".$sess->url( $mm_action_url.basename($_SERVER['PHP_SELF']). "?page=shop.parameter_search_form&product_type_id=". $product_type_id ). "\" method=\"get\" name=\"reset\">\n"; echo "<input type=\"submit\" class=\"button\" name=\"reset\" value=\""; echo $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_RESET_FORM') ."\">\n</form>"; echo "</td><td width=\"40%\"> </td></tr></table>\n"; ?> <form action="<?php echo URL ?>index.php" method="get" name="attr_search"> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="page" value="shop.browse" /> <input type="hidden" name="product_type_id" value="<?php echo $product_type_id ?>" /> <input type="hidden" name="Itemid" value="<?php echo $sess->getShopItemid() ?>" /> <br /> <?php $q = "SELECT * FROM #__{vm}_product_type_parameter "; $q .= "WHERE product_type_id=$product_type_id "; $q .= "ORDER BY parameter_list_order"; $db->query($q); echo "dupa1\n"; ?> <table width="100%" border="0" cellpadding="2" cellspacing="0"> <?php /******************************************************** ** BrowsePage - You can use your tepmlate for searching: ** 1) write file with html table (without tags <table> and </table>) and ** take its name into variable browsepage in Product Type ** 2) You can use this page from tag <!-- Default list of parameters - BEGIN --> to ** tag <!-- Default list of parameters - END --> and changed it. ** 3) tag {product_type_<product_type_id>_<parameter_name>} will be replaced input field, or select field ** tag {product_type_<product_type_id>_<parameter_name>_comp} will be replaced comparison ** for this parameter. It is important for correct SQL question. ** tag {product_type_<product_type_id>_<parameter_name>_value} will be replaced value for this ** parameter (when you click on button "Change Parametes" in Browse page). ********************************************************/ if (!empty($browsepage)) { // show browsepage /** * Read the template file into a String variable. * * function read_file( $file, $defaultfile='') ***/ $template = read_file( PAGEPATH."templates/".$browsepage.".php"); echo "dupa2\n"; //$template = str_replace( "{product_type_id}", $product_type_id, $template ); // If you need this, use it... while ($db->next_record()) { $item_name = "product_type_$product_type_id"."_".$db->f("parameter_name"); $parameter_values=$db->f("parameter_values"); $get_item_value = vmGet($_REQUEST, $item_name, ""); $get_item_value_comp = vmGet($_REQUEST, $item_name."_comp", ""); $parameter_type = $db->f("parameter_type"); // Replace parameter value $template = str_replace( "{".$item_name."_value}", $get_item_value, $template ); // comparison if (!empty($parameter_values) && $db->f("parameter_multiselect")=="Y") { if ($parameter_type == "V") { // type: Multiple Values // Multiple section List of values - comparison FIND_IN_SET $comp = "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; $comp .= "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; $comp .= "<option value=\"find_in_set_all\"".(($get_item_value_comp=="find_in_set_all")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FIND_IN_SET_ALL')."</option>\n"; $comp .= "<option value=\"find_in_set_any\"".(($get_item_value_comp=="find_in_set_any")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FIND_IN_SET_ANY')."</option>\n"; $comp .= "</select></td>"; } else { // type: all other // Multiple section List of values - no comparison $comp = "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"in\" />\n</td>\n"; } } else { switch( $parameter_type ) { case "C": // Char if (!empty($parameter_values)) { // List of values - no comparison $comp = "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"eq\" />\n"; break; } case "I": // Integer case "F": // Float case "D": // Date & Time case "A": // Date case "M": // Time $comp = "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; $comp .= "<option value=\"lt\"".(($get_item_value_comp=="lt")?" selected":"")."><</option>\n"; $comp .= "<option value=\"le\"".(($get_item_value_comp=="le")?" selected":"")."><=</option>\n"; $comp .= "<option value=\"eq\"".(($get_item_value_comp=="eq")?" selected":"").">=</option>\n"; $comp .= "<option value=\"ge\"".((empty($get_item_value_comp)||$get_item_value_comp=="ge")?" selected":"").">>=</option>\n"; $comp .= "<option value=\"gt\"".(($get_item_value_comp=="gt")?" selected":"").">></option>\n"; $comp .= "<option value=\"ne\"".(($get_item_value_comp=="ne")?" selected":"")."><></option>\n"; $comp .= "</select>\n"; break; case "T": // Text if (!empty($parameter_values)) { // List of values - no comparison $comp = "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"texteq\" />\n"; break; } $comp = "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; $comp .= "<option value=\"like\"".(($get_item_value_comp=="like")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."</option>\n"; $comp .= "<option value=\"notlike\"".(($get_item_value_comp=="notlike")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."</option>\n"; $comp .= "<option value=\"fulltext\"".(($get_item_value_comp=="fulltext")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FULLTEXT')."</option>\n"; $comp .= "</select>"; break; case "S": // Short Text default: // Default type Short Text if (!empty($parameter_values)) { // List of values - no comparison $comp = "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"texteq\" />\n"; break; } $comp = "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; $comp .= "<option value=\"like\"".(($get_item_value_comp=="like")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."</option>\n"; $comp .= "<option value=\"notlike\"".(($get_item_value_comp=="notlike")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."</option>\n"; $comp .= "</select></td>"; } } // Relace parameter comparison $template = str_replace( "{".$item_name."_comp}", $comp, $template ); // Parameter field if (!empty($parameter_values)) { // List of values $fields=explode(";",$parameter_values); $attr = "<select class=\"inputbox\" name=\"$item_name"; if ($db->f("parameter_multiselect")=="Y") { $size = min(count($fields),6); $attr .= "[]\" multiple size=\"$size\">\n"; $selected_value = array(); $get_item_value = vmGet($_REQUEST, $item_name, array()); foreach($get_item_value as $value) { $selected_value[$value] = 1; } foreach($fields as $field) { $attr .= "<option value=\"$field\"".(($selected_value[$field]==1) ? " selected>" : ">"). $field."</option>\n"; } } else { $attr .= "\">\n"; $attr .= "<option value=\"\">".$VM_LANG->_('PHPSHOP_SELECT')."</option>\n"; foreach($fields as $field) { $attr .= "<option value=\"$field\"".(($get_item_value==$field) ? " selected>" : ">"). $field."</option>\n"; } } $attr .= "</select>"; } else { // Input field switch( $parameter_type ) { case "I": // Integer case "F": // Float case "D": // Date & Time case "A": // Date case "M": // Time $attr = "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"20\" />"; break; case "T": // Text $attr = "<textarea class=\"inputbox\" name=\"$item_name\" cols=\"35\" rows=\"6\" >$get_item_value</textarea>"; break; case "C": // Char $attr = "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"5\" />"; break; case "S": // Short Text default: // Default type Short Text $attr = "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"50\" />"; } } // Relace parameter $template = str_replace( "{".$item_name."}", $attr, $template ); } echo $template; } else { // show default list of parameters echo "\ndupa3\n<!-- Default list of parameters - BEGIN -->\n"; while ($db->next_record()) { $parameter_type = $db->f("parameter_type"); if ($parameter_type!="B") { echo "<tr>\n <td width=\"35%\" height=\"2\" valign=\"top\"><div align=\"right\"><strong>"; echo $db->f("parameter_label"); if ($db->f("parameter_description")) { echo " "; echo mm_ToolTip($db->f("parameter_description"),$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_DESCRIPTION')); } echo " :</strong></div>\n </td>\n"; $parameter_values=$db->f("parameter_values"); $item_name = "product_type_$product_type_id"."_".$db->f("parameter_name"); $get_item_value = vmGet($_REQUEST, $item_name, ""); $get_item_value_comp = vmGet($_REQUEST, $item_name."_comp", ""); // comparison if (!empty($parameter_values) && $db->f("parameter_multiselect")=="Y") { if ($parameter_type == "V") { // type: Multiple Values // Multiple section List of values - comparison FIND_IN_SET echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; echo "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; echo "<option value=\"find_in_set_all\"".(($get_item_value_comp=="find_in_set_all")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FIND_IN_SET_ALL')."</option>\n"; echo "<option value=\"find_in_set_any\"".(($get_item_value_comp=="find_in_set_any")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FIND_IN_SET_ANY')."</option>\n"; echo "</select></td>"; } else { // type: all other // Multiple section List of values - no comparison echo "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"in\" />\n</td>\n"; } } else { switch( $parameter_type ) { case "C": // Char if (!empty($parameter_values)) { // List of values - no comparison echo "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"eq\" />\n</td>\n"; break; } case "I": // Integer case "F": // Float case "D": // Date & Time case "A": // Date case "M": // Time echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; echo "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; echo "<option value=\"lt\"".(($get_item_value_comp=="lt")?" selected":"")."><</option>\n"; echo "<option value=\"le\"".(($get_item_value_comp=="le")?" selected":"")."><=</option>\n"; echo "<option value=\"eq\"".(($get_item_value_comp=="eq")?" selected":"").">=</option>\n"; echo "<option value=\"ge\"".((empty($get_item_value_comp)||$get_item_value_comp=="ge")?" selected":"").">>=</option>\n"; echo "<option value=\"gt\"".(($get_item_value_comp=="gt")?" selected":"").">></option>\n"; echo "<option value=\"ne\"".(($get_item_value_comp=="ne")?" selected":"")."><></option>\n"; echo "</select></td>"; break; case "T": // Text if (!empty($parameter_values)) { // List of values - no comparison echo "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"texteq\" />\n</td>\n"; break; } echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; echo "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; echo "<option value=\"like\"".(($get_item_value_comp=="like")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."</option>\n"; echo "<option value=\"notlike\"".(($get_item_value_comp=="notlike")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."</option>\n"; echo "<option value=\"fulltext\"".(($get_item_value_comp=="fulltext")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FULLTEXT')."</option>\n"; echo "</select></td>"; break; case "V": // Multiple Value echo "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"find_in_set\" />\n</td>\n"; break; case "S": // Short Text default: // Default type Short Text if (!empty($parameter_values)) { // List of values - no comparison echo "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"texteq\" />\n</td>\n"; break; } echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; echo "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; echo "<option value=\"like\"".(($get_item_value_comp=="like")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."</option>\n"; echo "<option value=\"notlike\"".(($get_item_value_comp=="notlike")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."</option>\n"; echo "</select></td>"; } } if (!empty($parameter_values)) { // List of values $fields=explode(";",$parameter_values); echo "<td width=\"55%\" height=\"2\" valign=\"top\">\n"; echo "<select class=\"inputbox\" name=\"$item_name"; if ($db->f("parameter_multiselect")=="Y") { $size = min(count($fields),6); echo "[]\" multiple size=\"$size\">\n"; $selected_value = array(); $get_item_value = vmGet($_REQUEST, $item_name, array()); foreach($get_item_value as $value) { $selected_value[$value] = 1; } foreach($fields as $field) { echo "<option value=\"$field\"".(($selected_value[$field]==1) ? " selected>" : ">"). $field."</option>\n"; } } else { echo "\">\n"; echo "<option value=\"\">".$VM_LANG->_('PHPSHOP_SELECT')."</option>\n"; foreach($fields as $field) { echo "<option value=\"$field\"".(($get_item_value==$field) ? " selected>" : ">"). $field."</option>\n"; } } echo "</select>"; } else { // Input field echo "<td width=\"55%\" height=\"2\">\n"; switch( $parameter_type ) { case "I": // Integer case "F": // Float case "D": // Date & Time case "A": // Date case "M": // Time echo "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"20\" />"; break; case "T": // Text echo "<textarea class=\"inputbox\" name=\"$item_name\" cols=\"35\" rows=\"6\" >$get_item_value</textarea>"; break; case "C": // Char echo "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"5\" />"; break; case "S": // Short Text default: // Default type Short Text echo "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"50\" />"; } } echo " ".$db->f("parameter_unit"); switch( $parameter_type ) { case "D": // Date & Time echo " (".$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_DATE_FORMAT')." "; echo $VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_TIME_FORMAT').")"; break; case "A": // Date echo " (".$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_DATE_FORMAT').")"; break; case "M": // Time echo " (".$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_TIME_FORMAT').")"; break; } } else { // Break line (type == "B") echo "<tr>\n <td colspan=\"3\" height=\"2\" ><hr>"; } echo " </td>\n</tr>"; } echo "\n<!-- Default list of parameters - END -->\n\n"; } // Add search according to price: $item_name = "price"; $get_item_value = vmGet($_REQUEST, $item_name, ""); $item_name = "price_from"; $get_item_value_from = vmGet($_REQUEST, $item_name, ""); $item_name = "price_to"; $get_item_value_to = vmGet($_REQUEST, $item_name, ""); $get_item_value_comp = vmGet($_REQUEST, $item_name."_comp", ""); echo "<tr>\n <td width=\"35%\" height=\"2\" valign=\"top\"><div align=\"right\"><strong>"; echo $VM_LANG->_('PHPSHOP_CART_PRICE')." :</strong></div>\n </td>\n"; // input text echo "<td> <input type=\"text\" class=\"inputbox\" name=\"price_from\" value=\"$get_item_value_from\" size=\"20\" />"; echo "<td> <input type=\"text\" class=\"inputbox\" name=\"price_to\" value=\"$get_item_value_to\" size=\"20\" /></td>\n</tr>"; // Search Button ?> <tr><td colspan="3" height="2" > </td></tr> <tr><td colspan="3" height="2" ><div align="center"> <input type="submit" class="button" name="search" value="<?php echo $VM_LANG->_('PHPSHOP_SEARCH_TITLE') ?>"> </div></td> </tr> </table> <?php } // end - There is a published Product Type /** Changed Product Type - End */ ?> </form> and this is what i made ( i need to say that i'm note the coder i just try to change it myself) to make <input> chceckbox <?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); /** * Paramater search for phpShop * @author Zdenek Dvorak (zdenek.dvorak@seznam.cz) * * @version $Id: shop.parameter_search_form.php 1452 2008-07-08 17:21:42Z soeren_nb $ * @package VirtueMart * @subpackage html * @copyright Copyright (C) 2004-2008 soeren - All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details. * * http://virtuemart.net */ $q = "SELECT * FROM #__{vm}_product_type "; $q .= "WHERE product_type_id='$product_type_id' "; $q .= "AND product_type_publish='Y'"; $db->query($q); $browsepage = $db->f("product_type_browsepage"); $vm_mainframe->setPageTitle( $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH') ); $pathway[] = $vm_mainframe->vmPathwayItem( $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH') ); $vm_mainframe->vmAppendPathway($pathway); echo "<h2>".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH')."</h2>"; if (!$db->next_record()) { // There is no published Product Type echo $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_BAD_PRODUCT_TYPE'); } else { echo "<table width=\"100%\" border=\"0\">\n<tr><td width=\"40%\">"; echo $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IN_CATEGORY').": ".$db->f("product_type_name"); // Reset form echo "</td><td align=\"center\">"; echo "<form action=\"".$sess->url( $mm_action_url.basename($_SERVER['PHP_SELF']). "?page=shop.parameter_search_form&product_type_id=". $product_type_id ). "\" method=\"get\" name=\"reset\">\n"; echo "<input type=\"submit\" class=\"button\" name=\"reset\" value=\""; echo $VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_RESET_FORM') ."\">\n</form>"; echo "</td><td width=\"40%\"> </td></tr></table>\n"; ?> <form action="<?php echo URL ?>index.php" method="get" name="attr_search"> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="page" value="shop.browse" /> <input type="hidden" name="product_type_id" value="<?php echo $product_type_id ?>" /> <input type="hidden" name="Itemid" value="<?php echo $sess->getShopItemid() ?>" /> <br /> <?php $q = "SELECT * FROM #__{vm}_product_type_parameter "; $q .= "WHERE product_type_id=$product_type_id "; $q .= "ORDER BY parameter_list_order"; $db->query($q); echo "dupa1\n"; ?> <table width="100%" border="0" cellpadding="2" cellspacing="0"> <?php /******************************************************** ** BrowsePage - You can use your tepmlate for searching: ** 1) write file with html table (without tags <table> and </table>) and ** take its name into variable browsepage in Product Type ** 2) You can use this page from tag <!-- Default list of parameters - BEGIN --> to ** tag <!-- Default list of parameters - END --> and changed it. ** 3) tag {product_type_<product_type_id>_<parameter_name>} will be replaced input field, or select field ** tag {product_type_<product_type_id>_<parameter_name>_comp} will be replaced comparison ** for this parameter. It is important for correct SQL question. ** tag {product_type_<product_type_id>_<parameter_name>_value} will be replaced value for this ** parameter (when you click on button "Change Parametes" in Browse page). ********************************************************/ if (!empty($browsepage)) { // show browsepage /** * Read the template file into a String variable. * * function read_file( $file, $defaultfile='') ***/ $template = read_file( PAGEPATH."templates/".$browsepage.".php"); echo "dupa2\n"; //$template = str_replace( "{product_type_id}", $product_type_id, $template ); // If you need this, use it... while ($db->next_record()) { $item_name = "product_type_$product_type_id"."_".$db->f("parameter_name"); $parameter_values=$db->f("parameter_values"); $get_item_value = vmGet($_REQUEST, $item_name, ""); $get_item_value_comp = vmGet($_REQUEST, $item_name."_comp", ""); $parameter_type = $db->f("parameter_type"); // Replace parameter value $template = str_replace( "{".$item_name."_value}", $get_item_value, $template ); // comparison if (!empty($parameter_values) && $db->f("parameter_multiselect")=="Y") { if ($parameter_type == "V") { // type: Multiple Values // Multiple section List of values - comparison FIND_IN_SET $comp = "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; $comp .= "<form action=\"".$item_name."_comp\">\n"; $comp .= "<input type=\"checkbox\" value=\"find_in_set_all\"".(($get_item_value_comp=="find_in_set_all")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FIND_IN_SET_ALL')."\n"; $comp .= "<input type=\"checkbox\" value=\"find_in_set_any\"".(($get_item_value_comp=="find_in_set_any")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FIND_IN_SET_ANY')."\n"; $comp .= "</td>"; } else { // type: all other // Multiple section List of values - no comparison $comp = "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"in\" />\n</td>\n"; } } else { switch( $parameter_type ) { case "C": // Char if (!empty($parameter_values)) { // List of values - no comparison $comp = "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"eq\" />\n"; break; } case "I": // Integer case "F": // Float case "D": // Date & Time case "A": // Date case "M": // Time $comp = "<form action=\"".$item_name."_comp\" method=\"post\">\n"; $comp .= "<input type=\"checkbox\" value=\"lt\"".(($get_item_value_comp=="lt")?" selected":"").">\n"; $comp .= "<input type=\"checkbox\" value=\"le\"".(($get_item_value_comp=="le")?" selected":"").">\n"; $comp .= "<input type=\"checkbox\" value=\"eq\"".(($get_item_value_comp=="eq")?" selected":"").">\n"; $comp .= "<input type=\"checkbox\" value=\"ge\"".((empty($get_item_value_comp)||$get_item_value_comp=="ge")?" selected":"").">\n"; $comp .= "<input type=\"checkbox\" value=\"gt\"".(($get_item_value_comp=="gt")?" selected":"").">\n"; $comp .= "<input type=\"checkbox\" value=\"ne\"".(($get_item_value_comp=="ne")?" selected":"").">\n"; break; case "T": // Text if (!empty($parameter_values)) { // List of values - no comparison $comp = "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"texteq\" />\n"; break; } $comp = "<form action=\"".$item_name."_comp\">\n"; $comp .= "<input type=\"checkbox\" value=\"like\"".(($get_item_value_comp=="like")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."\n"; $comp .= "<input type=\"checkbox\" value=\"notlike\"".(($get_item_value_comp=="notlike")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."\n"; $comp .= "<input type=\"checkbox\" value=\"fulltext\"".(($get_item_value_comp=="fulltext")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FULLTEXT')."\n"; break; case "S": // Short Text default: // Default type Short Text if (!empty($parameter_values)) { // List of values - no comparison $comp = "<input type=\"hidden\" name=\"".$item_name."_comp\" value=\"texteq\" />\n"; break; } $comp = "<form actio=\"".$item_name."_comp\">\n"; $comp .= "<input type=\"checkbox\" value=\"like\"".(($get_item_value_comp=="like")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."\n"; $comp .= "<input type=\"checkbox\" value=\"notlike\"".(($get_item_value_comp=="notlike")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."\n"; $comp .= "</td>"; } } // Relace parameter comparison $template = str_replace( "{".$item_name."_comp}", $comp, $template ); // Parameter field if (!empty($parameter_values)) { // List of values $fields=explode(";",$parameter_values); $attr = "<select class=\"inputbox\" name=\"$item_name"; if ($db->f("parameter_multiselect")=="Y") { $size = min(count($fields),6); $attr .= "[]\" multiple size=\"$size\">\n"; $selected_value = array(); $get_item_value = vmGet($_REQUEST, $item_name, array()); foreach($get_item_value as $value) { $selected_value[$value] = 1; } foreach($fields as $field) { $attr .= "<option value=\"$field\"".(($selected_value[$field]==1) ? " selected>" : ">"). $field."</option>\n"; } } else { $attr .= "\">\n"; $attr .= "<option value=\"\">".$VM_LANG->_('PHPSHOP_SELECT')."</option>\n"; foreach($fields as $field) { $attr .= "<option value=\"$field\"".(($get_item_value==$field) ? " selected>" : ">"). $field."</option>\n"; } } $attr .= "</select>"; } else { // Input field switch( $parameter_type ) { case "I": // Integer case "F": // Float case "D": // Date & Time case "A": // Date case "M": // Time $attr = "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"20\" />"; break; case "T": // Text $attr = "<textarea class=\"inputbox\" name=\"$item_name\" cols=\"35\" rows=\"6\" >$get_item_value</textarea>"; break; case "C": // Char $attr = "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"5\" />"; break; case "S": // Short Text default: // Default type Short Text $attr = "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"50\" />"; } } // Relace parameter $template = str_replace( "{".$item_name."}", $attr, $template ); } echo $template; } else { // show default list of parameters echo "\ndupa3\n<!-- Default list of parameters - BEGIN -->\n"; while ($db->next_record()) { $parameter_type = $db->f("parameter_type"); if ($parameter_type!="B") { echo "<tr>\n <td width=\"35%\" height=\"2\" valign=\"top\"><div align=\"right\"><strong>"; echo $db->f("parameter_label"); if ($db->f("parameter_description")) { echo " "; echo mm_ToolTip($db->f("parameter_description"),$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_DESCRIPTION')); } echo " :</strong></div>\n </td>\n"; $parameter_values=$db->f("parameter_values"); $item_name = "product_type_$product_type_id"."_".$db->f("parameter_name"); $get_item_value = vmGet($_REQUEST, $item_name, ""); $get_item_value_comp = vmGet($_REQUEST, $item_name."_comp", ""); // comparison if (!empty($parameter_values) && $db->f("parameter_multiselect")=="Y") { if ($parameter_type == "V") { // type: Multiple Values // Multiple section List of values - comparison FIND_IN_SET echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; echo "<form action=\"/joomla/index.php\" method=\"post\">\n"; echo "<input type=\"checkbox\" value=\"find_in_set_all\"".(($get_item_value_comp=="find_in_set_all")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FIND_IN_SET_ALL')."\n"; echo "<input type=\"checkbox\" value=\"find_in_set_any\"".(($get_item_value_comp=="find_in_set_any")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FIND_IN_SET_ANY')."\n"; echo "</form></td>"; } else { // type: all other // Multiple section List of values - no comparison echo "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"in\" >\n</td>\n"; } } else { switch( $parameter_type ) { case "C": // Char if (!empty($parameter_values)) { // List of values - no comparison echo "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"eq\" />\n</td>\n"; break; } case "I": // Integer case "F": // Float case "D": // Date & Time case "A": // Date case "M": // Time echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; echo "<form action=\"/joomla/index.php\" method=\"post\">\n"; echo "<input type=\"checkbox\" value=\"lt\"".(($get_item_value_comp=="lt")?" selected":"")."><\n"; echo "<input type=\"checkbox\" value=\"le\"".(($get_item_value_comp=="le")?" selected":"")."><=\n"; echo "<input type=\"checkbox\" value=\"eq\"".(($get_item_value_comp=="eq")?" selected":"").">=\n"; echo "<input type=\"checkbox\" value=\"ge\"".((empty($get_item_value_comp)||$get_item_value_comp=="ge")?" selected":"").">>=\n"; echo "<input type=\"checkbox\" value=\"gt\"".(($get_item_value_comp=="gt")?" selected":"").">>\n"; echo "<input type=\"checkbox\" value=\"ne\"".(($get_item_value_comp=="ne")?" selected":"")."><>\n"; echo "</form></td>"; break; case "T": // Text if (!empty($parameter_values)) { // List of values - no comparison echo "<td><input type=\"hidden\" name=\"".$item_name."_comp\" value=\"texteq\" />\n</td>\n"; break; } echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; echo "<form action=\"/joomla/index.php\" method=\"post\">\n"; //echo "<select class=\"inputbox\" name=\"".$item_name."_comp\">\n"; echo "<input type=\"checkbox\" value=\"like\"".(($get_item_value_comp=="like")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."</option>\n"; echo "<input type=\"checkbox\" value=\"notlike\"".(($get_item_value_comp=="notlike")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."</option>\n"; echo "<input type=\"checkbox\" value=\"fulltext\"".(($get_item_value_comp=="fulltext")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_FULLTEXT')."</option>\n"; echo "</form></td>"; break; case "V": // Multiple Value echo "<td><input type=\"hidden\" value=\"find_in_set\" >\n</td>\n"; break; case "S": // Short Text default: // Default type Short Text if (!empty($parameter_values)) { // List of values - no comparison echo "<td><input type=\"hidden\" value=\"texteq\" />\n</td>\n"; break; } echo "<td width=\"10%\" height=\"2\" valign=\"top\" align=\"center\">\n"; echo "<form action=\"/joomla/index.php\" method=\"post\">\n"; echo "<input type=\"checkbox\" value=\"like\"".(($get_item_value_comp=="like")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_LIKE')."\n"; echo "<input type=\"checkbox\" value=\"notlike\"".(($get_item_value_comp=="notlike")?" selected":"").">".$VM_LANG->_('PHPSHOP_PARAMETER_SEARCH_IS_NOT_LIKE')."\n"; echo "</select></td>"; } } if (!empty($parameter_values)) { // List of values $fields=explode(";",$parameter_values); echo "<td width=\"55%\" height=\"2\" valign=\"top\">\n"; echo "<form action=\"/joomla/index.php\" method=\"post\" name=\"$item_name\"; >\n"; if ($db->f("parameter_multiselect")=="Y") { $size = min(count($fields),6); //echo "[]\" multiple size=\"$size\">\n"; $selected_value = array(); $get_item_value = vmGet($_REQUEST, $item_name, array()); foreach($get_item_value as $value) { $selected_value[$value] = 1; } foreach($fields as $field) { echo "<input type=\"checkbox\" value=\"$field\"".(($selected_value[$field]==1) ? " selected>" : ">"). $field."\n"; } } else { echo "\">\n"; echo "<input type=\"checkbox\" value=\"\">".$VM_LANG->_('PHPSHOP_SELECT')."\n"; foreach($fields as $field) { echo "<input type=\"checkbox\" value=\"$field\"".(($get_item_value==$field) ? " selected>" : ">"). $field."\n"; } } echo "</select>"; } else { // Input field echo "<td width=\"55%\" height=\"2\">\n"; switch( $parameter_type ) { case "I": // Integer case "F": // Float case "D": // Date & Time case "A": // Date case "M": // Time echo "<input type=\"checkbox\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"20\" />"; break; case "T": // Text echo "<textarea class=\"inputbox\" name=\"$item_name\" cols=\"35\" rows=\"6\" >$get_item_value</textarea>"; break; case "C": // Char echo "<input type=\"checkbox\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"5\" />"; break; case "S": // Short Text default: // Default type Short Text echo "<input type=\"text\" class=\"inputbox\" name=\"$item_name\" value=\"$get_item_value\" size=\"50\" />"; } } echo " ".$db->f("parameter_unit"); switch( $parameter_type ) { case "D": // Date & Time echo " (".$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_DATE_FORMAT')." "; echo $VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_TIME_FORMAT').")"; break; case "A": // Date echo " (".$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_DATE_FORMAT').")"; break; case "M": // Time echo " (".$VM_LANG->_('PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_TYPE_TIME_FORMAT').")"; break; } } else { // Break line (type == "B") echo "<tr>\n <td colspan=\"3\" height=\"2\" ><hr>"; } echo " </td>\n</tr>"; } echo "\n<!-- Default list of parameters - END -->\n\n"; } // Add search according to price: $item_name = "price"; $get_item_value = vmGet($_REQUEST, $item_name, ""); $item_name = "price_from"; $get_item_value_from = vmGet($_REQUEST, $item_name, ""); $item_name = "price_to"; $get_item_value_to = vmGet($_REQUEST, $item_name, ""); $get_item_value_comp = vmGet($_REQUEST, $item_name."_comp", ""); echo "<tr>\n <td width=\"35%\" height=\"2\" valign=\"top\"><div align=\"right\"><strong>"; echo $VM_LANG->_('PHPSHOP_CART_PRICE')." :</strong></div>\n </td>\n"; // input text echo "<td> <input type=\"text\" class=\"inputbox\" name=\"price_from\" value=\"$get_item_value_from\" size=\"20\" />"; echo "<td> <input type=\"text\" class=\"inputbox\" name=\"price_to\" value=\"$get_item_value_to\" size=\"20\" /></td>\n</tr>"; // Search Button ?> <tr><td colspan="3" height="2" > </td></tr> <tr><td colspan="3" height="2" ><div align="center"> <input type="submit" class="button" name="search" value="<?php echo $VM_LANG->_('PHPSHOP_SEARCH_TITLE') ?>"> </div></td> </tr> </table> <?php } // end - There is a published Product Type /** Changed Product Type - End */ ?> </form> Is ther anybody can help me with This. I will be very thankful for any Help. I hope I can explain what is happening. I have created two forms in PHP. The first 'almost' works, i.e. it shows the data. But I have two problems - 1) the second pulldown menu is always empty and 2) $value from the first pulldown menu ALWAYS equals the last entry thus the last 'if' in the function subdomains ($domains) is always called (but still empty). The code may explain this better than me:
<!DOCTYPE html> <html> <body> <!-- processDomains.php is this file - it calls itself (for testing purposes so I can see what is happening) --> <form action="processDomains.php" method="post"> <?php // create the domains array (there are actually several entries in the array but I cut it down for testing) $domains = array (1 => 'Decommission', 'Migration'); echo "Select Domain:"; echo "<br>"; // Make the domain pull-down menu - this displays correctly echo '<select name="domain">'; foreach ($domains as $key => $value) { echo "<option value=\"$key\">$value</option>\n"; } echo '</select>'; // input doesn't matter what is 'submitted', always goes to last $value echo '<input type="submit" name="submit" value="Submit">'; // call function subdomains subdomains ($value); function subdomains ($domains) { // define values for each array - each array contains available choices for the subdomain pulldown menu $migration = array (1 => 'Application Migration', 'Application Patch', 'Application Upgrade'); $decommission = array (1 => 'Applications', 'Servers', 'Storage'); if ($domains === 'Migration') { echo "Select subdomain:"; echo "<br>"; // Make the Migration pull-down menu echo '<select name="migration">'; foreach ($migration as $key => $value) { echo "<option value=\"$key\">$value</option>\n"; } echo '</select>'; } else if ($domains === 'Decommission') { /* === * since 'Decommission' is the last entry in the 'Domains' pulldown list, $value ALWAYS equals * 'Decommission' and $domains equals $value. So this menu SHOULD work but is always * empty. Thus, two problems - the pulldown menu is always empty and $value isn't based * upon user input. */ echo "Select subdomain:"; // this prints so I know I'm in 'Decommission (I eliminated the echo "$domain" to show I'm always coming here)' echo "<br>"; // Make the 'Decommission' pull-down menu echo '<select name="decommission">'; foreach ($decommission as $key => $value) { echo "<option value=\"$key\">$value</option>\n"; } echo '</select>'; echo '<input type="submit" name="submit" value="Submit">' ) // end of 'if-else' } // end of function 'subdomain' ?> </form> </body> </html>Let me say thank you in advance and I appreciate the help! I know I'm doing something (or more than one thing) wrong and I hope someone can tell me what it is. Best Regards! Edited by mac_gyver, 19 January 2015 - 09:37 PM. code tags around posted code please I am writing a script that will parse my PHP classes and check for things like coupling, visualize my objects and connections, dependencies, check for convention usage, etc.
So, I have a simple file upload. I'm never saving the files, just get contents and dump the file and work with the string version.
I'm writing it for me, but I figure I might want to open it for others to use in the future, so I may as well write it that way to begin with -- so I need to validate user input. Problem is, the user input is supposed to be valid PHP code. I'm thinking that, as long as I'm careful, I shouldn't be executing any code contained in strings, but I'm no security expert and I want a warm fuzzy that my thought on this is correct. What kinds of things do I need to look out for? Is it possible to inject when working with strings?
My initial thought is to regex the entire file and replace key portions with known replacements. So ( and ) would become !* and !^ or $ would become @~ (combinations that -- I think -- don't make sense to php?) But that may be completely unnecessary processing time if I'm not in any danger, here. Thanks ahead of time for any help.
PS - as a side question -- what's the best way to verify a file is a php file? I know of getimagesize for images, but should I just check for <? to verify it's php? That seems like it would be too easy to fool -- then again, it might not matter much.
-Adam
I have a calendar select date function for my form that returns the date in the calendar format for USA: 02/16/2012. I need to have this appear as is for the form and in the db for the 'record_date' column, but I need to format this date in mysql DATE format (2012-02-16) and submit it at the same time with another column name 'new_date' in the database in a hidden input field. Is there a way to do this possibly with a temporary table or something? Any ideas would be welcome. Doug Hi people, I really hope you guys can help me out today. I'm just a newbe at php and i'm having real trouble. Bassically all I want to do is have a user type in a company name in a html form. If what the user types in the form matches the company name in my php script i want the user to be sent to another page on my site. If what the user types in the form doesnt match the company name in my php script i want the user to be sent to a differnt page like an error page for example. this is my html form: Code: [Select] <form id="form1" name="form1" method="post" action="form_test.php"> <p>company name: <input type="text" name="company_name" id="company_name" /> </p> <p> <input type="submit" name="button" id="button" value="Submit" /> </p> </form> And this is the php code I'm trying to process the information on: Code: [Select] <?php $comp_name = abc; if(isset ($_POST["company_name"])){ if($_POST["company_name"] == $comp_name){ header("Location: http://www.hotmail.com"); exit(); } else{ header("Location: http://www.yahoo.com"); exit(); } } ?> The thing is i'm getting this error when i test it: Warning: Cannot modify header information - headers already sent by (output started at D:\Sites\killerphp.com\form_test.php:10) in D:\Sites\killerphp.com\form_test.php on line 17 Please can some one help me out, i'm sure this is just basic stuff but i just cant get it to work Cheers. As I am VERY new to PDO, can someone help me in converting the below 2 codes so that I can setup the testing site knowing at least this part works. Below is the old SQL that I need to convert but don't have to foggiest on where to start. If I can get some help with this I can slowly work through the rest of my site with a bit more ease. LOGIN CODE: <?php if($_POST['submit']){ $Username = protect($_POST['Username']); $Password = protect(sha1($_POST['Password'])); if(!$Username || !$Password){ echo "<center>Please enter your <b>Username</b> and <b>Password</b>!</center>"; }else{ $res = mysql_query("SELECT * FROM `eusers` WHERE `Username` = '".$Username."'"); $num = mysql_num_rows($res); if($num == 0){ echo "<center>The <b>Username</b> or <b>Password</b> you supplied is incorrect!</center>"; }else{ $res = mysql_query("SELECT * FROM `eusers` WHERE `Username` = '".$Username."' AND Password = '".$Password."'"); $num = mysql_num_rows($res); if($num == 0){ echo "<center>The <b>Password</b> you supplied is incorrect!</center>"; }else{ $row = mysql_fetch_assoc($res); if($row['Active'] != 1){ echo "<center>Your login has been <b>deactivated</b>, Please contact your Manager for assistance.</center>"; }else{ header('Location: secure.php'); $time = date('U')+7200; //2 Hours mysql_query("UPDATE `eusers` SET `Online` = '".$time."' WHERE `id` = '".$_SESSION['uid']."'"); $_SESSION['uid'] = $row['id']; }}}}} ?> ACCESS GRANTED (Each Page): <?php if(strcmp($_SESSION['uid'],"") == 0){ printf("<script>location.href='index.php'</script>"); }else{ $time = date('U')+7200; //2 Hours $update = mysql_query("UPDATE `eusers` SET `Online` = '".$time."' WHERE `id` = '".$_SESSION['uid']."'"); } ?>
Hi, I am changing my ISP and need to import my databases.
Do I I have to create a new datarbase or can I change my database name to import?
My new host has a different database prefix ie: -web147xxxxxxxx
My old one was arewene1_wor1.
Many thanks.
Hi guys, i have a system and was asked to develop the site with the current system. These are sometimes a pain but it is an old system and i'm trying to change the url's which is seems to be hard to do with this kind of code. set_time_limit(60); include 'includes/config.php'; include 'includes/logfile.php'; include 'includes/databasefile.php'; include 'includes/templatefile.php'; $log = new cLog; $db = new cDatabase; //first run ssl check if necessary if ($_SERVER['SERVER_PORT'] == "80" && $sslredirect == 1) { header ("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . "?" . $_SERVER['QUERY_STRING']); exit(0); } //first, determine page requested list ($junk, $request) = split ("\?/", $_SERVER['REQUEST_URI']); list ($uri, $data) = split ("!", $request); $uriarray = split ("/", $uri); //check for login/logout request list ($junk, $request) = split ("\?", $_SERVER['REQUEST_URI']); if ($request == 'login') { header ("Location: login.php"); exit(0); } else if ($request == 'logout') { header ("Location: logout.php"); exit(0); } if ($data != "") { //parse internal variables $dataarray = split ("&", $data); foreach ($dataarray as $line) { list ($cmd, $val) = split ("=", $line); $arr_cmds[$cmd] = urldecode ($val); } } $pagename = $db->escape($uriarray[count($uriarray)-2]); $sectionname = $db->escape($uriarray[count($uriarray)-3]); if ($pagename == "") { $pagename = "home"; } if ($sectionname == "") { $sectionname = "home"; } $urlpagename = $pagename; $urlsectionname1 = $sectionname; $urlsectionname2 = $db->escape($uriarray[count($uriarray)-4]); //handle any commands, then redirect back to page $cmd = $_REQUEST['cmd']; if ($cmd == "-displayelement") { $elementid = $db->escape($_REQUEST['elementid']); if ($_REQUEST['surpresshtml'] == "") { echo "<html><head><link href='templates/css.css' rel='stylesheet' type='text/css'></head>\n"; } if ($_REQUEST['global'] == "1") { $query = $db->query("select ComponentName, Data from table_globalelements where (ElementID = '$elementid')"); } else { $query = $db->query("select ComponentName, Data from table_elements where (ElementID = '$elementid')"); } $r = $db->fetch_array($query); $currentcomponentname = $r['ComponentName']; $data = stripslashes($r['Data']); //find matching component and launch display function $dir_handle = opendir("com/components/"); while ($file = readdir($dir_handle)) { $filenoext = str_replace (".php", "", $file); if ($filenoext == $currentcomponentname) { include "com/components/" . $file; echo call_user_func(array($currentcomponentname, 'display'), $data); break; } } if ($_REQUEST['surpresshtml'] == "") { echo "</body></html>\n"; } exit (0); } else if ($cmd == '-editelement') { $elementid = $db->escape($_REQUEST['elementid']); if (isset($_SESSION['UserID'])) { $query = $db->query("select UserID, AdminFlag from table_users where (UserID = '" . $_SESSION['UserID'] . "')"); $r = $db->fetch_array($query); $userid = $r['UserID']; $adminflag = $r['AdminFlag']; if ($adminflag != "1") { $query = $db->query ("select ComponentName, Data, PageID from table_elements where (ElementID = '$elementid' and UserID = '$userid')"); } else { $query = $db->query ("select ComponentName, Data, PageID from table_elements where (ElementID = '$elementid')"); } $r = $db->fetch_array($query); $currentcomponentname = $r['ComponentName']; $data = stripslashes($r['Data']); $pageid = $r['PageID']; //handle request $cmd = $_REQUEST['greyboxcmd']; if ($cmd == 'save') { $elementid = $db->escape($_REQUEST['ElementID']); $data = $db->escape($_REQUEST['Data']); //find matching component and launch save function $dir_handle = opendir("com/components/"); while ($file = readdir($dir_handle)) { $filenoext = str_replace (".php", "", $file); if ($filenoext == $currentcomponentname) {; include "com/components/" . $file; $data = call_user_func(array($currentcomponentname, 'save')); if ($adminflag != "1") { $query = $db->query("update table_elements set Data = '$data' where (ElementID = '$elementid' and UserID = '$userid')"); } else { $query = $db->query("update table_elements set Data = '$data' where (ElementID = '$elementid')"); } echo "<script type='text/javascript'>parent.location.reload(true); parent.GB_hide();</script>\n"; exit(0); } } echo "Error: component not found..."; } //find matching component and launch edit function echo "<html><head><link href='templates/css.css' rel='stylesheet' type='text/css'><script type='text/javascript' src='templates/openwysiwyg/wysiwyg.js'></script></head>\n"; echo "<body style='text-align: center;'><form name='Form0' enctype='multipart/form-data' method='post' action='" . $_SERVER['REQUEST_URI'] . "'>\n"; $dir_handle = opendir("com/components/"); while ($file = readdir($dir_handle)) { $filenoext = str_replace (".php", "", $file); if ($filenoext == $currentcomponentname) {; include "com/components/" . $file; echo call_user_func(array($currentcomponentname, 'edit'), $data); break; } } echo "<input type='hidden' name='ElementID' value='$elementid'><input type='submit' name='Save' value='Save' class='smallbutton'>\n"; echo "<input type='button' name='Cancel' value='Cancel' onclick='parent.GB_hide();' class='smallbutton'>\n"; echo "<input type='hidden' name='greyboxcmd' value='save'></form></body></html>\n"; exit (0); } else { echo "<script type='text/javascript'>parent.GB_hide();</script>\n"; exit (0); } } else if ($cmd == '-editglobalelement') { $elementid = $db->escape($_REQUEST['elementid']); if (isset($_SESSION['UserID'])) { $query = $db->query("select UserID, AdminFlag from table_users where (UserID = '" . $_SESSION['UserID'] . "')"); $r = $db->fetch_array($query); $userid = $r['UserID']; $adminflag = $r['AdminFlag']; if ($adminflag != "1") { echo "Security - Out of bounds"; exit(0); } $query = $db->query ("select ComponentName, Data from table_globalelements where (ElementID = '$elementid')"); $r = $db->fetch_array($query); $currentcomponentname = $r['ComponentName']; $data = stripslashes($r['Data']); //handle request $cmd = $_REQUEST['greyboxcmd']; if ($cmd == 'save') { $elementid = $db->escape($_REQUEST['ElementID']); $data = $db->escape($_REQUEST['Data']); //find matching component and launch save function $dir_handle = opendir("com/components/"); while ($file = readdir($dir_handle)) { $filenoext = str_replace (".php", "", $file); if ($filenoext == $currentcomponentname) {; include "com/components/" . $file; $data = call_user_func(array($currentcomponentname, 'save')); $query = $db->query("update table_globalelements set Data = '$data' where (ElementID = '$elementid')"); echo "<script type='text/javascript'>parent.location.reload(true); parent.GB_hide();</script>\n"; exit(0); } } echo "Error: component not found..."; } //find matching component and launch edit function echo "<html><head><link href='templates/css.css' rel='stylesheet' type='text/css'><script type='text/javascript' src='templates/openwysiwyg/wysiwyg.js'></script></head>\n"; echo "<body style='text-align: center;'><form name='Form0' enctype='multipart/form-data' method='post' action='" . $_SERVER['REQUEST_URI'] . "'>\n"; $dir_handle = opendir("com/components/"); while ($file = readdir($dir_handle)) { $filenoext = str_replace (".php", "", $file); if ($filenoext == $currentcomponentname) {; include "com/components/" . $file; echo call_user_func(array($currentcomponentname, 'edit'), $data); break; } } echo "<input type='hidden' name='ElementID' value='$elementid'><input type='submit' name='Save' value='Save' class='smallbutton'>\n"; echo "<input type='button' name='Cancel' value='Cancel' onclick='parent.GB_hide();' class='smallbutton'>\n"; echo "<input type='hidden' name='greyboxcmd' value='save'></form></body></html>\n"; exit (0); } else { echo "<script type='text/javascript'>parent.GB_hide();</script>\n"; exit (0); } } //lookup page details $query = $db->query("select p.PageID, p.PageTitle, p.SectionID, p.TemplateID, p.UserID, p.LastUpdate, p.SectionName, s.SectionTitle, s.GroupID, s.Protected, p.Keywords, p.PageName from table_pages as p left join table_sections as s on s.SectionName = p.SectionName where (p.PageName = '$pagename' and s.SectionName = '$sectionname') limit 1"); if (!$pagedetails = $db->fetch_array($query)) { echo "404"; exit(0); } //check for privileges section if ($pagedetails[8] != "" && $pagedetails[8] != "0") { $sectionname = stripslashes($pagedetails[6]); if (!isset($_SESSION['Username']) && !isset($_REQUEST['Username'])) { echo "This is a restricted area. Please login.<br/><br/>"; echo "<form action='index.php' method='get'>Username: <input type='text' name='Username'><br/>\n"; echo "Password: <input type='password' name='Password'><br/>\n"; echo "<input type='submit' name='Login' value='Login'></form><br/>\n"; exit; } else { $username = $db->escape ($_REQUEST['Username']); $password = $db->escape ($_REQUEST['Password']); if ($username == "") { $username = $db->escape ($_SESSION['Username']); } if ($password == "") { $password = $db->escape ($_SESSION['Password']); } $query = $db->query("select UserID, Password, RealName, Email, GroupID, AdminFlag from table_users where (Username = '$username')"); $r = $db->fetch_array($query); $dbpassword = $r['Password']; if ($password == $dbpassword) { $_SESSION['Username'] = $username; $_SESSION['UserID'] = $r['UserID']; $_SESSION['RealName'] = $r['RealName']; $_SESSION['Email'] = $r['Email']; $_SESSION['GroupID'] = $r['GroupID']; } } if ($_SESSION['GroupID'] != $pagedetails[8]) { echo "This is a restricted area. Please login.<br/><br/>"; echo "<form action='index.php' method='get'>Username: <input type='text' name='Username'><br/>\n"; echo "Password: <input type='password' name='Password'><br/>\n"; echo "<input type='submit' name='Login' value='Login'></form><br/>\n"; exit; } } else { //check login details if user appears to be already logged in if (isset($_SESSION['Username'])) { $username = $db->escape ($_SESSION['Username']); $password = $db->escape ($_SESSION['Password']); $query = $db->query("select UserID, Password, RealName, Email, GroupID, AdminFlag from table_users where (Username = '$username')"); $r = $db->fetch_array($query); $dbpassword = $r['Password']; if ($password == $dbpassword) { $_SESSION['Username'] = $username; $_SESSION['UserID'] = $r['UserID']; $_SESSION['RealName'] = $r['RealName']; $_SESSION['Email'] = $r['Email']; $_SESSION['GroupID'] = $r['GroupID']; } } } //load template $tplate = new cTemplate($pagedetails['TemplateID'], $pagedetails['PageID']); $tplate->loadtemplate(); //add logout button if (isset($_SESSION['UserID'])) { echo "<div align='center'><small><a href='index.php?logout'>logout</a></small></div>\n"; } //log request if (getenv(HTTP_X_FORWARDED_FOR)) { $ip = getenv(HTTP_X_FORWARDED_FOR); } else { $ip = getenv(REMOTE_ADDR); } $log->writelog("/$sectionname/$pagename", "Access"); In the includes/templatefile.php file the code is like: function parsetemplate($templatefile) { global $db, $pageid, $pagedetails, $fullbaseurl, $adminemail; //first, find internal metacodes $pagetitle = stripslashes($pagedetails[1]); $lastupdate = date('l dS \of F Y h:i:s A', $pagedetails[5]); $sectiontitle = stripslashes($pagedetails[7]); $sectionname = stripslashes($pagedetails[6]); $templatefile = str_replace ("!PAGETITLE!", $pagetitle, $templatefile); $templatefile = str_replace ("!ADMINEMAIL!", $adminemail, $templatefile); $templatefile = str_replace ("!REQUEST_DOCUMENTID!", $_REQUEST['DocumentID'], $templatefile); $templatefile = str_replace ("!SECTIONTITLE!", $sectiontitle, $templatefile); $templatefile = str_replace ("!LASTUPDATE!", $lastupdate, $templatefile); $templatefile = str_replace ("!URL!", $_SERVER['REQUEST_URI'], $templatefile); $templatefile = str_replace ("!FULLBASEURL!", $fullbaseurl, $templatefile); $templatefile = str_replace ("!KEYWORDS!", $pagedetails[10], $templatefile); if ($_SESSION['UserID'] != "") { $templatefile = str_replace ("!LOGINDETAILS!", "- You are logged in as " . $_SESSION['Username'], $templatefile); } else { $templatefile = str_replace ("!LOGINDETAILS!", "", $templatefile); } $templatefile = str_replace ("!SECTIONLINK!", $fullbaseurl . "?/" . $sectionname . "/Home/", $templatefile); What i am getting via the links a Code: [Select] http://www.mydomain.com/?/Shop/Home/ How do i get rid of the "?" mark and the "/Home/". The /Home/ is also stored in the Database. I have tried a number of solutions by getting rid of the "?" and "/Home/" but i get the 404 error as the code shows. Can you please help with this? Hi all I have a string called $voucher_code which is a value used to deduct or add value to a shopping cart. If the value is a minus I need it to show the minus sign, or if it's a plus value, it needs to show a plus sign. Here's my code: <strong>£ -".number_format(($voucher_code),2)."</strong> How do I modify the above code to show + instead of -- which it does at the moment? Many thanks for your help Pete Hi, I'm using the following code: <td>$row[color]</td> and the possible values for this field are 1, 2 and 3. But I want the return to be red for 1, blue for 2, and green for 3. How do I write it so that instead of getting a row of 1's, 2's and 3's, I change those numbers to their corresponding colors? Thanks! okay i need help with this part of code i need to set time 00:00 to 24:00 Code: [Select] $vrijeme_otvoreno = "$rv_od_h:$rv_od_min"; $vrijeme_zatvoreno = "$rv_do_h:$rv_do_min"; if ($vrijeme_otvoreno =="00:00" && $vrijeme_zatvoreno == "00:00") { $vrijme_zatvoreno = "24:00"; echo $vrijeme_zatvoreno; } echo "$vrijeme_otvoreno - $vrijeme_zatvoreno <br>"; i get echo 00:00 - 00:00 and i need it to be 00:00 - 24:00 Hi I'm using a form that uses number_format. It works fine until the number in question gets into the thousands. I can enter "3000", click Calculate and it comes back as "3,000.00" which is perfect. But if I click Calculate again, it changes to "3.00". How can I get it to remain "3,000.00"? Here's the code: Code: [Select] <form action="test.php" method="POST" > <?php if (empty($_POST['data1'])) { $number = ''; } else { str_replace(",","",$_POST['data1']); $number = number_format((double)$_POST['data1'],2); } ?> <input type="text" style="40" name="data1" value="<?php echo $number; ?>"> <input type="submit" name="submitCalc" value="Calculate" /><br /> <a href="test.php">Reset Form</a> </form> Hi Guys, I have a list of branches in a database table with the following collumns, Ter BranchName BranchAddress BranchTel BranchEmail BranchLink Ter = Terriotory ID However every time i update a branch using the edit.php code it always sets the Ter as 1 again! Rather than leaving it the same. The actual field is read-only to prevent that from happening. It then always comes up with the error Duplicate entry '1' for key 1 but thats because there is already a branch with Ter=1 include('config.php'); if (isset($_GET['Ter']) ) { $ter = (int) $_GET['Ter']; if (isset($_POST['submitted'])) { foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); } $sql = "UPDATE `ter` SET `Ter` = `BranchName` = '{$_POST['BranchName']}' , `BranchAddress` = '{$_POST['BranchAddress']}' , `BranchTel` = '{$_POST['BranchTel']}' , `BranchEmail` = '{$_POST['BranchEmail']}' , `BranchLink` = '{$_POST['BranchLink']}' WHERE `Ter` = '$ter' "; mysql_query($sql) or die(mysql_error()); echo (mysql_affected_rows()) ? "Edited Branch.<br />" : "Nothing changed. <br />"; } $row = mysql_fetch_array ( mysql_query("SELECT * FROM `ter` WHERE `Ter` = '$ter' ")); <form action='' method='POST'> <p><b>Territory:</b><br /><input name='Ter' type='text' value='<?= stripslashes($row['Ter']) ?>' size="3" readonly="readonly" /> <p><b>Branch Name:</b><br /><input name='BranchName' type='text' value='<?= stripslashes($row['BranchName']) ?>' size="50" /> <p><b>Address:</b><br /> <textarea name="BranchAddress" cols="40" rows="5"><?= stripslashes($row['BranchAddress']) ?></textarea> <p><b>Telephone:</b><br /><input name='BranchTel' type='text' value='<?= stripslashes($row['BranchTel']) ?>' size="15" /> <p><b>Email:</b><br /><input name='BranchEmail' type='text' value='<?= stripslashes($row['BranchEmail']) ?>' size="50" /> <p><b>Link:</b><br /><input name='BranchLink' type='text' value='<?= stripslashes($row['BranchLink']) ?>' size="50" /> <p><input type='submit' value='Save' /><input type='hidden' value='1' name='submitted' /> </form> <? } ?> Any Ideas? Cheers, S // SESSION TEST if ($_SESSION['username']) { require_once("../mysql.php"); // Find Username from Session ID // Find Username from ID $finduser="SELECT username FROM users WHERE id='$_SESSION[username];'"; $finduserquery=mysql_query($finduser)or die(mysql_error()); $userfetch = mysql_fetch_array($finduserquery); // Set Username Variable $userfromid = $userfetch['username']; echo "lol" . ucwords($userfromid); } else { } Everytime I load this page more than once when logged in, it seems to turn the variable blank. Therefore making the user not be able to view other pages that use a session. Help? Thanks Hey folks, I have made a cart. My output of the cart ( when I receive a mail of the order ) is like this "3,2,4,2" ,, the numbers are the id's of the items, but instread of the id's of the items, I would like to have the names of the items as an output in mail.php, column in sql table is also 'name' what should I do ?? the cart http://fhcs.be/cart-demo4/ thanks in advance index.php <?php // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); // Include functions require_once('inc/functions.inc.php'); // Start the session require_once('mail.php'); session_start(); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>PHP Shopping Cart Demo &#0183; Bookshop</title> <link rel="stylesheet" href="css/styles.css" /> </head> <body> <div id="shoppingcart"> <h1>Welkom, plaats uw order</h1> </div> <div id="booklist"> <h1>Warme dranken</h1> <?php $sql = 'SELECT * FROM products WHERE cat=2'; $result1 = $db->query($sql); $output1[] = '<ul>'; while ($row = $result1->fetch()) { $output1[] = '<li>'.$row['name'].': €'.$row['price'].'<br /><a href="cart.php?action=add&id='.$row['id'].'">Add to cart</a></li>'; } $output1[] = '</ul>'; echo join('',$output1); ?> <h1>Cocktails</h1> <?php $sql = 'SELECT * FROM products WHERE cat=3'; $result2 = $db->query($sql); $output2[] = '<ul>'; while ($row = $result2->fetch()) { $output2[] = '<li>'.$row['name'].': €'.$row['price'].'<br /><a href="cart.php?action=add&id='.$row['id'].'">Add to cart</a></li>'; } $output2[] = '</ul>'; echo join('',$output2); ?> </div> </body> </html> mail.php <?php // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); session_start(); if($_POST['sendemail'] == 'Email') { $info =($_POST['cart']); $headers = 'From: Sender <from@fhcs.be>'; mail('to@fhcs.be', 'Subject', $info, $headers); echo $_POST["cart"]; echo 'Your mail has been sent'; } else { echo 'Your mail was not sent'; } ?> cart.php <?php function writeShoppingCart() { $cart = $_SESSION['cart']; if (!$cart) { return '<p>You have no items in your shopping cart</p>'; } else { // Parse the cart session variable $items = explode(',',$cart); $s = (count($items) > 1) ? 's':''; return '<p>You have <a href="cart.php">'.count($items).' item'.$s.' in your shopping cart</a></p>'; } } function showCart() { global $db; $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $output[] = '<form action="cart.php?action=update" method="post" id="cart">'; $output[] = '<table>'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM products WHERE id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $output[] = '<tr>'; $output[] = '<td><a href="cart.php?action=delete&id='.$id.'" class="r">Remove</a></td>'; $output[] = '<td>'.$name.'</td>'; $output[] = '<td>€'.$price.'</td>'; $output[] = '<td><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>'; $output[] = '<td>€'.($price * $qty).'</td>'; $total += $price * $qty; $output[] = '</tr>'; } $output[] = '</table>'; $output[] = '<p>Grand total: <strong>€'.$total.'</strong></p>'; $output[] = '<div><button type="submit">Update cart</button></div>'; $output[] = '</form>'; } else { $output[] = '<p>You shopping cart is empty.</p>'; } return join('',$output); } ?> functions.php <?php function writeShoppingCart() { $cart = $_SESSION['cart']; if (!$cart) { return '<p>You have no items in your shopping cart</p>'; } else { // Parse the cart session variable $items = explode(',',$cart); $s = (count($items) > 1) ? 's':''; return '<p>You have <a href="cart.php">'.count($items).' item'.$s.' in your shopping cart</a></p>'; } } function showCart() { global $db; $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $output[] = '<form action="cart.php?action=update" method="post" id="cart">'; $output[] = '<table>'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM products WHERE id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $output[] = '<tr>'; $output[] = '<td><a href="cart.php?action=delete&id='.$id.'" class="r">Remove</a></td>'; $output[] = '<td>'.$name.'</td>'; $output[] = '<td>€'.$price.'</td>'; $output[] = '<td><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>'; $output[] = '<td>€'.($price * $qty).'</td>'; $total += $price * $qty; $output[] = '</tr>'; } $output[] = '</table>'; $output[] = '<p>Grand total: <strong>€'.$total.'</strong></p>'; $output[] = '<div><button type="submit">Update cart</button></div>'; $output[] = '</form>'; } else { $output[] = '<p>You shopping cart is empty.</p>'; } return join('',$output); } ?> Salting passwords... How can you update the salting without getting all the users to change their password? Is the salting set in stone once created? hello guys i have a project with Georgian calendar but when i contact to the developer they tell me we not support any other calendar so you must do this alone or get help from local developer. as manager i need to have basic knowledge from what is under my control. so please guide me to how change Georgian to Persian (jalali) calendar. i done translating from en to per but the most problem is the calendar. project address: https://drive.google.com/open?id=1eKestInuUiUJHotYltNuVsqRGnq4ujNN thank you for your attention and your kind best regards Hi, I've got the follow array: Query: Code: [Select] SELECT concat(monthname(gl_date),", ",year(gl_date)) as "monthYear", concat(DATE_FORMAT(gl_date,"%d-%m-%Y"),", ",gl_venue) as "dateVenue", DATE_FORMAT(gl_date,"%d-%m-%Y")as "date", gl_venue as "venue", gl_city as "city", gl_postcode as "postcode", gl_text as "description", concat(DAYOFMONTH(gl_date), MONTHNAME(gl_date),".png") AS "imageName" FROM tg_gig_list where gl_date >= curdate() and gl_publish = 1 order by gl_date Array: Code: [Select] $array = array(); $array['gigs'] = array(); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $array['gigs'][] =$row; } $output = json_encode($array); This returns JSON like this: - Code: [Select] { "gigs": [ { "monthYear": "May, 2011", "dateVenue": "14-05-2011, Queen Victoria hall", "date": "14-05-2011", "venue": "Queen Victoria hall", "city": "Oundle", "postcode": "PE8 4EJ", "description": "", "imageName": "14May.png" }, { "monthYear": "May, 2011", "dateVenue": "19-05-2011, O'Neill's", "date": "19-05-2011", "venue": "O'Neill's", "city": "Peterborough", "postcode": "PE1 1SQ", "description": "This one is another outing for Jason and Darren's acoustic duo, the pair will be playing a selection of their favourite songs as well as some tunes from the guards set.<br \/>\r\n<br \/>\r\n19:00 to 21:00", "imageName": "19May.png" }, {.......next record I'd like the data to be arranged by the 'monthYear' field....something like this... Code: [Select] { "gigs": [ "monthYear": "May, 2011" { "monthYear": "May, 2011", "dateVenue": "14-05-2011, Queen Victoria hall", "date": "14-05-2011", "venue": "Queen Victoria hall", "city": "Oundle", "postcode": "PE8 4EJ", "description": "", "imageName": "14May.png" }, {......all gigs for 'May, 2011' } "monthYear": "June, 2011" {....records for 'June, 2011' so 'gigs'=>'monthYear'=>'other records' I've tried all sorts of combinations of putting the '$row['monthYear']' field in different places in the array, but I seem to loose data by doing so for some reason. any input greatly appreciated. Darren Any chance you could help me out with some probably simple code ? I need to change an image when the script change state. So instead of $Streamstatus "off"or "on" I would like to change an image. Cheers Code: [Select] <?php $request = 'http://api.own3d.tv/liveCheck.php?live_id='; $arg = 'Zerkilive'; $session = curl_init($request.$arg); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); curl_close($session); if (preg_match("/true/",$response, $result)) { $streamStatus="on"; $color="green"; } else { $streamStatus="off"; $color="red"; } echo $streamStatus; ?> |