WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If (!array_key_exists(‘authed’, $_SESSION))
     include ‘not_authed.inc’;

// go about your business.


and i'm trying to add that to this:


function checkValues($value)
     // Use this function on all those values where you want to check for both sql injection and cross site scripting
     //Trim the value
     $value = trim($value);

    // Stripslashes
    if (get_magic_quotes_gpc()) {
        $value = stripslashes($value);

     // Convert all &lt;, &gt; etc. to normal html and then strip these
     $value = strtr($value,array_flip(get_html_translation_table(HTML_ENTITIES)));

     // Strip HTML Tags
     $value = strip_tags($value);

    // Quote the value
    $value = mysql_real_escape_string($value);
    return $value;

mysql_connect ("mysql.*****.com", "****","$*****")  or die (mysql_error());
mysql_select_db ("***********");

$term = checkValues($_REQUEST['val']);
$term = mysql_real_escape_string($term);

$sql = mysql_query("select * FROM patient_db WHERE id_number = '$term'");

if($row = mysql_fetch_array($sql)) {
    echo "<img src=\"******\" class='leftfloat' border=0>";
    echo '<p>';
    echo '<br /> ID Number: '   .$row['id_number'];
    echo '<br /> Name: '        .$row['Name'];
    echo '<br /> Exp. Date: '   .$row['exp_date'];
    echo '<br /> DOB: '         .$row['dob'];
    echo '</p>';
    //echo "<a href='******' title='Printer Friendly Version' alt='Printer Friendly Version'><img src=\"*****\" class='rightfloat' border=0 height=33 width=33></a>";
} else {
    echo "<img src=\"*****\" height=50 width=50 class='leftfloat' border=0>";
    print "<h1>USER ID <br/>NOT FOUND</h1><br />";
    print "<strong>OOPS!! THIS COULD BE AN ERROR</strong><br />";
    print "<br />";
    print "<div>*****</div>";

share|improve this question
I am trying to detect a Session Variable or Cookie from wordpress to queue from. Nobody should be able to enter the exactly url of the php document that this is used on – Jeffrey Jones May 10 '11 at 21:28

It might not be very light solution but it might be much more straightforward approach to load WP core and use current_user_can() and related stuff for determining user permissions.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.