Jump to content

PHP Code in Wordpress post?


deanMKD

Recommended Posts

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

Link to comment
Share on other sites

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 by Jacques1
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.