Support » Plugins and Hacks » Hacks » trying processing data form

  • Resolved 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">
            <input type="checkbox" name="CheckboxGroup[]" value="A"/>
              Option 1</label></td>
            <input type="checkbox" name="CheckboxGroup[]" value="B"/>
              Option 2</label></td>
    	<input type="checkbox" name="CheckboxGroup[]" value="C"/>
              Option 3</label></td>
    <p><input type="submit" name="Finish" value="Finish"/></p>

    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

    $temp = $_POST['CheckboxGroup'];
    # Check which (if any) of the queries was selected
        echo("You didn't select anything.");
    	$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");
    			$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
    			# Set the pie data and the pie labels
    			$c->setData($counter, $user_login);
    			# Output the chart
    			header("Content-type: image/png");
    			#$c->makeChart(dirname(__FILE__) . "/aaa.png");
                    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.

    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" ...

    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.