• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Javascript in footer of Minimum Pro

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Javascript in footer of Minimum Pro

This topic is: not resolved

Tagged: database, footer, javascript, php

  • This topic has 4 replies, 2 voices, and was last updated 9 years, 2 months ago by unklee.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • January 2, 2017 at 4:00 am #198586
    unklee
    Member

    Hi, last year I transferred a bunch of HTML pages into Minimum Pro pages, successfully I'm pleased to say - except for one thing.

    At the bottom of my HTML pages I had a 3-way radio button that allowed readers to give feedback. A javascript file which ran in the HTML page head called a php file which stored the result of the feedback in my database. Using phpMyAdmin I can check the feedback. I am not a javascript programmer, and my php is pretty rudimentary, but it was enough to make that work with a lot of help from the internet.

    When I converted the pages to WordPress/Genesis/Minimum Pro, I put the php file under themes/Minimum- Pro, and put the javascript in the footer scripts section of the Genesis Theme settings (people seemed to recommend putting it there rather than in the header), adjusted the link to the php file, and thought that would be OK.

    When I try the feedback radio buttons, I get the initial response of the javascript (the buttons disappear and are replaced by a "thank you") but nothing is recorded in the database. I am at a loss to understand what else I must need to change, and would appreciate any advice please. Here are the two scripts:

    <script type="text/javascript">
    function hresponse(helpfulResponse) {
    	document.getElementById("feedback").innerHTML = "";
    	document.getElementById("formfeed").innerHTML = "Thank you for your feedback.";
       var request = false;
       try {
         request = new XMLHttpRequest();
       } catch (trymicrosoft) {
         try {
           request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (othermicrosoft) {
           try {
             request = new ActiveXObject("Microsoft.XMLHTTP");
           } catch (failed) {
             request = false;
           }  
         }
       }
       if (!request) {
         return;
    	}
       var url = "URL/wp-content/themes/minimum-pro/insertHelpful.php";
       request.open("POST", url, true);
    	var page = document.title;
    	var helpful = 'Result='+helpfulResponse +'&Page='+page;
       request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    	request.send(helpful);
    }
    </script>

    And this is insertHelpful.php:

    <?php
    if (get_magic_quotes_gpc())
    {
    	function stripslashes_deep($value)
    	{
    		$value = is_array($value) ?
    				array_map('stripslashes_deep', $value) :
    				stripslashes($value);
    
    		return $value;
    	}
    
    	$_POST = array_map('stripslashes_deep', $_POST);
    }
    
    $link = mysqli_connect('localhost', '***********', '********', '************');
    mysqli_set_charset($link, 'utf8');
    
    if (isset($_POST['Page']))
    {
    	$value1 =mysqli_real_escape_string($link, $_POST['Result']);
    	$value2 =mysqli_real_escape_string($link, $_POST['Page']); 
    	mysqli_query($link, "INSERT INTO page_helpful (Result, Page, Date) VALUES('$value1','$value2',CURDATE())");
     	mysqli_close($link);
    	exit();
    }
    ?>

    Thanks.

    http://www.is-there-a-god.info
    January 2, 2017 at 7:54 am #198594
    Victor Font
    Moderator

    First off, your JavaScript is written for a Microsoft environment. You are calling ActiveXObjects. ActiveXObject is the key/initial function to enable and reference an "Automation object" in a Microsoft programming environment or the Internet Explorer browser. ActiveX does not exist in a WordPress environment. Even your PHP is very old school. This should all be updated to use Ajax, which works across any technology. Since you're not a developer, you'll probably need to hire someone to do this for you. It should only take a couple of hours to write and test the code. It's not very complicated.

    By the way, you should probably change your database userid and password since you posted them publicly in your PHP code.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    January 2, 2017 at 11:59 am #198608
    unklee
    Member

    Thanks, I'll see what I can do with that information.

    Yes, I woke up in the night and realised with horror that I'd forgotten to take out the password, etc. I'll fix it straight away.

    January 2, 2017 at 1:15 pm #198616
    unklee
    Member

    Is there any way I can modify the code I posted now?

    January 2, 2017 at 2:37 pm #198638
    unklee
    Member

    Thanks to StudioPress, the password information has been removed. Panic over!

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble