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 298703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:45:21+00:00 2026-05-12T06:45:21+00:00

In a nutshell on page1.php I have a calculator that consists of an HTML

  • 0

In a nutshell on “page1.php” I have a calculator that consists of an HTML form, and then the PHP code totals the input and displays the total price. Below the price, it also displays a link to “page2.php” which contains an HTML form where they can enter their contact information. Upon submitting the form the selections they made on “page1.php” in the pricing calculator as well as the contact info on “page2.php” are emailed to me, and they are redirected to the home page.

In the email that is submitted to me, I receive the contact info from “page2.php”, but I don’t receive anything from “page1.php”, so the variables are not getting correctly passed. In addition to the PHP on each page, I am using hidden values in an HTML form on “page2.php” to echo the data that was entered in the HTML form on “page1.php”. I know that one of my issues is that I have a couple of $_GET fields when my form is “post”.

However when I change it so that everything is $_POST, the calculator no longer works. I tried to put this altogether with different snippets of code suggested by others. The form on “page1.php” has 13 fields, named “one” – “thirteen”. $total display the values of 1-13.

<?php
  $submit = $_GET['submit'];
  if($submit == "true")
  {
    $total = ($_POST['one'] + $_POST['two'] + $_POST['three'] + $_POST['four']  + 
    $_POST['five'] + $_POST['six'] + $_POST['seven'] + $_POST['eight']+ $_POST['nine'] + 
    $_POST['ten']+ $_POST['eleven'] + $_POST['twelve']+ $_POST['thirteen']); 
    echo  " Your Price is \$ " .number_format ($total, 2, '.', ','). "<BR>";
    echo ('">Get Your Project Started</a>');
  }
?>

The second form uses hidden values to echo the info from page1.php, and has three more fields named “name”, “email” and “details”.

<?php
  $to = "jessica@designs.com";
  $message = "Pages:\t$_POST[one]\n";
  $message .= "Pages:\t$_POST[two]\n";
  $message .= "Pages:\t$_POST[three]\n";
  $message .= "Ecommerce:\t$_POST[four]\n";
  $message .= "No Ecommerce:\t$_POST[five]\n";
  $message .= "CMS:\t$_POST[six]\n";
  $message .= "No CMS:\t$_POST[seven]\n";
  $message .= "Audio or Video:\t$_POST[eight]\n";
  $message .= "Flash Intro:\t$_POST[nine]\n";
  $message .= "Image Gallery:\t$_POST[ten]\n";
  $message .= "Graphic Design or Logo:\t$_POST[eleven]\n";
  $message .= "Copy:\t$_POST[twelve]\n";
  $message .= "Images:\t$_POST[thirteen]\n";
  $message .= "Price Total:\t$_POST[total]\n";
  $message .= "Name:\t$_POST[name]\n";
  $message .= "Email:\t$_POST[email]\n";
  $message .= "\n";
  $message .= "\n";
  $message .= "Details:\t$_POST[details]\n";
  mail($to, $subject, $message, $headers) ;
  }
?>

So what would be the correct PHP to put on “page1.php” and “page2.php”? Sorry the code is such a mess, if anyone could point me in the right direction, that would be great.

  • 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-12T06:45:21+00:00Added an answer on May 12, 2026 at 6:45 am

    PHP is stateless unless you save things in session (which isn’t secure right?)

    You would need to make page2.php read all the values from page1.php and store them either in a server side state (session) or a client state (cookies or maybe hidden fields in the form)

    If you want any of this secure or a secret, then you have to consider all of that as well. Nothing I explained is secret or secure in any way.

    EDIT: here is an example of page1.php that sends the values of page1.php to page2.php as get parameters. You can do this with hidden fields, cookies or sessions as well.

    What is important to remember is that page2.php is totally unaware of page1.php, and can’t get to the values like you could it forms programming. Each page starts and ends it’s life by the time you see a full web page, so you have to use some extra tricks to keep values. Those tricks are sessions, cookies, form posts, or gets.

    <html>
    <head>
    <title>Page 1</title>
    </head>
    <body>
    <?php
    //set defaults assuming the worst
    $total = 0;
    $one =0;
    $two=0;
    
    //verify we have that value in $__POST
    if (isset($_POST['submit']))
    {
        $submit = $_POST['submit'];
        //If it is true, try some math
        if($submit == "sub-total")
            {
                if (isset($_POST['one']))
                {   
                    $one = $_POST['one'];
                    //Add checks to see if your values are numbers
                    if ( ! is_numeric($one)) { $one = 0;}
                }
    
                if (isset($_POST['two']))
                {
                    $two = $_POST['two'];
                    if ( ! is_numeric($two)) { $two = 0;}
                }
                $total = $one + $two;
                echo " Your Price is \$ " .number_format ($total, 2, '.', ','). "<BR>";
            }
        if($submit == "submit" )
        {
            //go to page two, with the total from page1.php passed as a $__GET value
            header("Location: page2.php?total=".$total);
        }
    }
    ?>
        <form method="post" action="page1.php?submit=true">
            <input type="text" name="one" id="one" value="<?=$one?>"/>
            <input type="text" name="two" id="two"  value="<?=$two?>"/>
            <input type="submit" name="submit" value="sub-total" />
            <input type="submit" name="submit" value="submit" />
        </form>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a nutshell, I have a solution that builds fine in the IDE, and
I have a form that can be filled, saved, loaded and re-edited. When it
Nutshell: I launch a thread from my form, then some time later use the
I have a controller that in nutshell is as follows: public function download($id) {
In a nutshell what my program does is: it executes and takes user input
Here are the specs that I'm trying to implement in a nutshell: 1) Some
We have uplaod function on our site. And uploaded file, displays link which on
I have an ASP.NET user control that I want to write some dynamic Javascript
I have an avatar upload which works fine, the problem is that when the
I know that there have been a number of posts regarding the height:100% declaration

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.