• Resolved ptsiridi

    (@ptsiridi)


    Hello to everyone. Well i am new in making plugins and on top of that i have to make one for a project i am into. I’m trying my best but it seems that i lack serious knowledge. Here is my first big problem. The following code is called in the admin’s menu and has 3 possible options.

    <form id="form" name="form" method="post" action="process.php">
      <table width="400">
        <tr>
          <td><label>
            <input type="checkbox" name="CheckboxGroup[]" value="A"/>
              Option 1</label></td>
        </tr>
        <tr>
          <td><label>
            <input type="checkbox" name="CheckboxGroup[]" value="B"/>
              Option 2</label></td>
    	</tr>
    	<tr>
    	  <td><label>
    	<input type="checkbox" name="CheckboxGroup[]" value="C"/>
              Option 3</label></td>
    	</tr>
      </table>
    <p><input type="submit" name="Finish" value="Finish"/></p>
    </form>

    The problem is that wordpress looking for the process.php into the wp-admin folder and not in my plugin folder. I tried using the whole directory but nothing changed. If i put my process.php into wp-admin folder everything works but i know this is not the solution. If anyone has any idea please guide me. Thank you. Here is the code from process.php

    <?php
    include_once("phpchartdir.php");
    
    $temp = $_POST['CheckboxGroup'];
    
    # Check which (if any) of the queries was selected
    
    if(empty($temp))
    {
        echo("You didn't select anything.");
    }
    else
    {
    	$N = count($temp);
    
        for($i=0; $i<$N; $i++)
    	{
    		if($temp[$i] == "A")
    		{
    			# SQL statement
    
    			$SQL = "SELECT COUNT( post_id ) , poster_id, wp_users.user_login, wp_users.ID FROM wp_bb_posts, wp_users WHERE poster_id = wp_users.ID GROUP BY poster_id ORDER BY COUNT( post_id ) DESC LIMIT 10";
    
    			# Connect to database and read the query result into arrays
    
    			mysql_connect("localhost", "root", "0000");
    			mysql_select_db("wordpress");
    
    			$result = mysql_query($SQL);
    
    			while($row = mysql_fetch_row($result))
    			{
        			$counter[] = $row[0];
        			$user_login[] = $row[2];
    			}
    
    			# Print the query's graph
    
    			# Create a PieChart object of size 360 x 300 pixels
    			$c = new PieChart(360, 300);
    
    			# Set the center of the pie at (180, 140) and the radius to 100 pixels
    			$c->setPieSize(180, 140, 100);
    
    			# Add a title to the pie chart
    			$c->addTitle("Pie");
    
    			# Set the pie data and the pie labels
    			$c->setData($counter, $user_login);
    
    			# Output the chart
    			header("Content-type: image/png");
    			print($c->makeChart2(PNG));
    			#$c->makeChart(dirname(__FILE__) . "/aaa.png");
    
    			unset($counter);
    			unset($user_login);
    		}
                    else if($temp[$i] == "B")
                    #and continues like that........
Viewing 2 replies - 1 through 2 (of 2 total)
  • You already seem to have registered an admin menu page (where the form will be shown). So you can take this very page URL (and script), use this one as form action value and include the process.php there.

    <?php
    if( {checkIfFormHasBeenSent} ) {
    
      include_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'process.php'
    
    }
    ?>
    <form action="admin.php?page=whateverYourPageSlugAlreadyIs" ...

    Or if you really must target your process.php directly you could do it like this
    <form action="<?php echo plugins_url(); ?>/yourPlugin/process.php" ...

    Thread Starter ptsiridi

    (@ptsiridi)

    Chris you are amazing. Thank you for your help. I used the
    <form action=”<?php echo plugins_url(); ?>/yourPlugin/process.php”…
    and it’s working perfectly. Thanks again!!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘trying processing data form’ is closed to new replies.