• Resolved Fahim Mahmood

    (@urbloodismywine)


    Hi there i am new to this WordPress Development…Here i am making a Plug in that will run a Script with some Parameters which can be set by User and that script will run in wp_footer apart from that i am saving user data in a simple text file which is created when the user submit the data and that file is saved with the login name of user and accomplished it i am successfully making a user submit the values and file is also been created but when i logout it is not making me logout and either when i try to login from other browser it also give me header errors here i will post the code below:

    plugin index.php:

    <?php
    /*
    Plugin Name: Dhudora
    Version: 0.1
    Description: Advertisment Plugin
    Author: Fahim Mahmood Mir
    Author URI: http://www.prelovac.com/vladimir
    Plugin URI: http://www.prelovac.com/vladimir/wordpress-plugins/
    wp-digg-this
    */
    ?>
    <!--<script type="text/javascript">
    
    function formValidator(forme)
    {
    
    	var limit = document.getElementById('txtlimit').value;
    	var seck = document.getElementById('txtkey').value;
    	var interval = document.getElementById('txtinterval').value;
    
    }
    
    </script>-->
    
    <?php
    add_action('admin_menu', 'basicPluginMenu');
    function basicPluginMenu() {
    $appName = 'Dhundora';
    $appID = 'basic-plugin';
    add_menu_page($appName, $appName, 'administrator', $appID, 'pluginAdminScreen');
    }
    function pluginAdminScreen() {
    
    	  global $current_user;
          get_currentuserinfo();
    
           $userlog=  $current_user->user_login ;
    
    	echo '<h1> Welcome to Dhundora Advertising Script</h1>';
    	?>
        This is the Plugin that will be helping the Dhundora to Successfully launch the Script In this Plugin of WordPress<br>
    
    <form id="forme" action="../wp-content/plugins/dhundora/process-file.php"  method="get">
    <br /><br />
    <span name="login-subheading">Secrect Key</span><br />
    <input  id="txtkey" name="userkey" type="text" style="width:300px" /><br />
    <br />
    
    <input type="hidden" id="txtuser" name="username" value ='<?php echo $userlog; ?>' /><br />
    
    <span name="login-subheading">Limit</span><br />
    <input id="txtlimit" name="userlimit" style="width:300px" type="text" />&nbsp;
    
    <br /><br />
    
    <span name="login-subheading">Interval</span><br />
    <input id="txtinterval" name="userinterval" type="text" style="width:300px" />&nbsp;<br /><br />
    
    <input id="login-submit" name="Continue" type="submit" value="Register" style="padding:8px"/>
    </form>
    <div id="result">
    <?php
    $data = array();
    $myFile = "../wp-content/plugins/dhundora/".$userlog.".txt";
    $fh = fopen($myFile, 'a+') or die("No Settings Saved");
    $i = -1;
    //Output a line of the file until the end is reached
    while(!feof($fh))
      {
    	  $i = $i+1;
      $data[$i] = fgets($fh);
      }
    fclose($fh);
    
    echo  '<br /><br />'.'<input type="text" readonly="readonly" value =  '.$data[0]. ' /><br />';
    echo  '<br /><br />'.'<input type="text" readonly="readonly" value =  '.$data[1]. ' /><br />';
    echo  '<br /><br />'.'<input type="text" readonly="readonly" value =  '.$data[2]. ' /><br />';
    
    ?>
    </div>
    
    <?php
    
    }
    
    ?>

    and the form submittion file process-file.php

    <?php
    
    /*$userlim =  $_GET['userlimit']."\n";
    $userint =  $_GET['userinterval']."\n";
    $userkey = $_GET['userkey']."\n";
    */
    $myFile = $_GET['username'].".txt";
    $fh = fopen($myFile, 'w+') or die("can't open file");
    
    $stringData = $userkey = $_GET['userkey']."\n".$_GET['userlimit']."\n".$_GET['userinterval']."\n";
    fwrite($fh, $stringData);
    fclose($fh);
    
    ?>
    Your Settings are Saved <a href="javascript:void()" onclick="window.history.back();" > Go to Back</a><br>

    can anyone tell me why this thing giving header error ??

Viewing 1 replies (of 1 total)
  • Thread Starter Fahim Mahmood

    (@urbloodismywine)

    i Got it!!

    The Problem was really Tiny lol Just the Blank Spaces before php Tags Phewwwwww

    Never Leave a Blank Space before PHP Tags

    …!!!

Viewing 1 replies (of 1 total)
  • The topic ‘Header Error In Plugin’ is closed to new replies.