Title: pass data using insert php
Last modified: April 19, 2018

---

# pass data using insert php

 *  [veselyf2](https://wordpress.org/support/users/veselyf2/)
 * (@veselyf2)
 * [8 years ago](https://wordpress.org/support/topic/pass-data-using-insert-php/)
 * I try to pass a parameter to a php script of my own. I created a page called “
   myscript.php” and used the plugin Insert PHP to do some basic things. Now I want
   to do things depending on a parameter par1 and try the usual syntax
    `<a href
   ="myscript.php?par1=something">` with `$_GET["par1"]` within the script No success.
   I also tried to name the page just “myscript”, without suffix; didn’t help.
    -  This topic was modified 8 years ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fpass-data-using-insert-php%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [hyperionstudios](https://wordpress.org/support/users/hyperionstudios/)
 * (@hyperionstudios)
 * [8 years ago](https://wordpress.org/support/topic/pass-data-using-insert-php/#post-10200554)
 * So what is the issue? am guessing that WordPress is not recognising myscript.
   php? is that what you mean by no success?
 *  Thread Starter [veselyf2](https://wordpress.org/support/users/veselyf2/)
 * (@veselyf2)
 * [8 years ago](https://wordpress.org/support/topic/pass-data-using-insert-php/#post-10201535)
 * That is not the main issue. I assume (based on trial) that the suffix .php is
   not recognized under wordpress, so I named the sandbox script just “myscript”.
   It looks like this:
 * [insert_php]
    echo ‘Server date and time is: ‘; echo date(‘l, F j, Y \a\t G:i:
   s’); echo ‘<br> </br>’; echo ‘Hallo ‘ . $_GET[“name”] . ‘!’; [/insert_php]
 * If I call it as …/myscript it does give the date and says Hallo; if I say …/myscript?
   name=anna
    it produces a 404 error.
 *  [Jacob Peattie](https://wordpress.org/support/users/jakept/)
 * (@jakept)
 * [8 years ago](https://wordpress.org/support/topic/pass-data-using-insert-php/#post-10201833)
 * I’m not understanding the relationship between myscript.php and the insert_php
   shortcode. Where is your example code? Where is the shortcode being used?
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [8 years ago](https://wordpress.org/support/topic/pass-data-using-insert-php/#post-10202080)
 * There are more issues in this regard than you realize. First of all, you shouldn’t
   directly request custom PHP files in WP. There is no reliable way to invoke the
   WP environment when you do this. If you are utilizing shortcodes to cause your
   custom code to execute, there is no reason for a separate file. Put the shortcode
   in a post and make the request using the post’s permalink. You may add URL parameters
   like you would any other URL.
 * Besides using shortcodes, there are 4 other valid ways in WP to cause custom 
   code to execute. 1) hook a filter or action. 2) Use Ajax. 3) Make a custom page
   template. 4) send your request through wp-admin/admin-post.php.
 * Don’t bother with Insert PHP plugin. If you can write PHP within the shortcode,
   you can just as easily create [your own shortcode](https://codex.wordpress.org/Shortcode_API)
   without the plugin. There is also some added security risk in using Insert PHP
   and similar plugins. The way the plugin works might also be why you are having
   trouble with getting URL parameters, but I cannot be sure about this.
 * The main thing to remember in making your own shortcode is the handler function
   must never generate output by using echo, fprint, etc. Instead, accumulate output
   into a variable that your handler function returns. WP will then echo out the
   returned string at the appropriate location in the post.
 *  Thread Starter [veselyf2](https://wordpress.org/support/users/veselyf2/)
 * (@veselyf2)
 * [8 years ago](https://wordpress.org/support/topic/pass-data-using-insert-php/#post-10205601)
 * Thank you for your extensive response. I will follow up your suggestions and 
   warnings.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘pass data using insert php’ is closed to new replies.

## Tags

 * [$_get](https://wordpress.org/support/topic-tag/_get/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 5 replies
 * 4 participants
 * Last reply from: [veselyf2](https://wordpress.org/support/users/veselyf2/)
 * Last activity: [8 years ago](https://wordpress.org/support/topic/pass-data-using-insert-php/#post-10205601)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
