deanMKD Posted August 16, 2016 Share Posted August 16, 2016 Hi ! i have hard time to get my php code, that i insert into wordpress site to get work. This is the code that i have inserted into Wordpress post using "Insert PHP" plugin: [button style="btn-primary" url="" size="" block="false" target="_self"] Buscar [/button] [insert_php] $keyword = "doctor"; if( isset($_POST['key']) ) { $keyword = $_POST['key']; echo "nEntered keyword: $keyword"; //print $keyword; if( $keyword == "" ){ echo "Please enter a keyword."; exit; } $url = "http://webservices.myskillsmyfuture.org/Occupation.svc/occupationsbykeyword/userid/vWmZxue3MavGrMk/keyword/".$keyword."/limit/20 simplexml_load_file($url); $json = json_encode($xml); $jsonIterator = new RecursiveIteratorIterator( new RecursiveArrayIterator(json_decode($json, TRUE)), RecursiveIteratorIterator::SELF_FIRST); echo "nn Search Results: nn"; foreach ($jsonIterator as $key => $val) { if($key != "ErrorMessage" && $key != "ErrorNumber") { if(is_array($val)) { // echo "$key:n"; } else { if( $key == "AcinetUrl" ) { $val = "$val"; } echo "$key: $val"; } echo "n"; } } } // This is for 4th URL | Find occupation titles by keyword[/insert_php] This code now work when i press the button inserted via Visual Composer: [button style="btn-primary" url="" size="" block="false" target="_self"] Buscar[/button] How to resolve this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/301914-php-code-in-wordpress-post/ Share on other sites More sharing options...
Jacques1 Posted August 16, 2016 Share Posted August 16, 2016 (edited) WTF? First off, allowing arbitrary PHP code within posts is the absolute last thing you want, because this effectively turns every single post into a PHP shell with direct access to the server. Anybody who manages to add or manipulate a post can also execute any code they want. Wordpress is already infamous for its security problems. No need to make it even worse. And why would you process form values in a post? Isn't a post something like a blog post? My blog posts contain text, not PHP code. It seems what you actually want is a page. In the corresponding PHP script, you can safely do whatever you want to do. Edited August 16, 2016 by Jacques1 Quote Link to comment https://forums.phpfreaks.com/topic/301914-php-code-in-wordpress-post/#findComment-1536240 Share on other sites More sharing options...
deanMKD Posted August 16, 2016 Author Share Posted August 16, 2016 WTF? First off, allowing arbitrary PHP code within posts is the absolute last thing you want, because this effectively turns every single post into a PHP shell with direct access to the server. Anybody who manages to add or manipulate a post can also execute any code they want. Wordpress is already infamous for its security problems. No need to make it even worse. And why would you process form values in a post? Isn't a post something like a blog post? My blog posts contain text, not PHP code. It seems what you actually want is a page. In the corresponding PHP script, you can safely do whatever you want to do. Yes post is the same as blog post ! i simply want to grab data from url: $url = "http://webservices.myskillsmyfuture.org/Occupation.svc/occupationsbykeyword/userid/vWmZxue3MavGrMk/keyword/".$keyword."/limit/20 simplexml_load_file($url); and show results in wordpress post/page. thats all. Can you help me to make that code to work, or tell e alternative how to do this? Quote Link to comment https://forums.phpfreaks.com/topic/301914-php-code-in-wordpress-post/#findComment-1536242 Share on other sites More sharing options...
Jacques1 Posted August 16, 2016 Share Posted August 16, 2016 Like I said, why don't you create a new page based on a custom PHP template? The user enters their keywords, you fetch the XML data and show the results on the page. Quote Link to comment https://forums.phpfreaks.com/topic/301914-php-code-in-wordpress-post/#findComment-1536244 Share on other sites More sharing options...
deanMKD Posted August 16, 2016 Author Share Posted August 16, 2016 The problem is that i dont know how to do that.. Can you help me how to make work this? Quote Link to comment https://forums.phpfreaks.com/topic/301914-php-code-in-wordpress-post/#findComment-1536245 Share on other sites More sharing options...
Jacques1 Posted August 16, 2016 Share Posted August 16, 2016 It's all explained in the Wordpress handbook, and there are countless step-by-step tutorials. Quote Link to comment https://forums.phpfreaks.com/topic/301914-php-code-in-wordpress-post/#findComment-1536246 Share on other sites More sharing options...
deanMKD Posted August 16, 2016 Author Share Posted August 16, 2016 Dont exist other sollution then this to create a templates for that? im searching for easy sollution. Some iframe or something like that. Quote Link to comment https://forums.phpfreaks.com/topic/301914-php-code-in-wordpress-post/#findComment-1536247 Share on other sites More sharing options...
Jacques1 Posted August 17, 2016 Share Posted August 17, 2016 I see you've asked the exact same question in a different forum a week ago and got the exact same response. But instead of simply reading the damn tutorial and completing the site in maybe one hour, you wait an entire week and then try the exact same question here. You're wasting your time, buddy. WordPress is easy. It's specifically designed for non-programmers. If you cannot write a simple template, then you should probably just leave the site alone. Quote Link to comment https://forums.phpfreaks.com/topic/301914-php-code-in-wordpress-post/#findComment-1536250 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.