Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6898073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:14:59+00:00 2026-05-27T07:14:59+00:00

I am anew to php please help… I am trying to collect a variable

  • 0

I am anew to php please help…
I am trying to collect a variable (in specific the counter I used in my loop) on a $_POST after I submit my form.

<form action="reportingTemplate.php" method="post">
<?php
    function buildform() {
    if (file_exists('textt.txt')){

            $x = file_get_contents('textt.txt');
            $y = explode("\r\n", $x);

                $incr = 1;
            foreach ($y as $value) {
            $z = explode(",", $value);

            writehtml($incr,$z[1],$z[2],$z[0]);

      $incr++;
            }   
            if ($incr < 15)
                for ($incr = $incr; $incr<16; $incr++) {
                    writehtml($incr,"","","");

                }
        }
        else
        for ($increm = 1; $increm<16; $increm++) {
            writehtml($increm,"","","");
        }
    }
    ?>
    <input type="hidden" id="test" name"countt" value="<?php echo $incr; ?>"/> <!--error area -->
    <input type="submit"/>
    </form>

where I am getting my $_POST:

$the = $_POST["countt"];
echo $the;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:15:00+00:00Added an answer on May 27, 2026 at 7:15 am

    Try it this way:

    $incr = 0;
    function buildform() {
        global $incr;
        ...
        $incr++;
    }
    

    Declare $incr outside the function, then announce that it’s a global variable you’re manipulating from inside function buildform() then you can echo it…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build a website with mysql and php. This is the
I am new to php. Trying to send confirmation about user upload. I am
I wonder whether someone may be able to help me please. Using some excellent
I'm trying to manipulate my mysql tables with PHP but when I update them
Below are the files in PHP that I am trying to include a file
I'm new to php so please bear with me here. Its a rough example
This is quite difficulty for me. Please help. I've a website created with cake
I'm trying to make a dynamic table with PHP. I have a page which
im a new guy in php i want help ,i google a lot about
I've been trying to use grubers latest url matching regex in a php project.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.