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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:41:05+00:00 2026-05-22T15:41:05+00:00

I am trying to get some data from page to page and then mail

  • 0

I am trying to get some data from page to page and then mail them.

So from one form I am getting a title of item :

//Form1
<form  class="orderFormFields" method="post" action="order">
<input type="hidden" name="productName" value="<?php the_title(); ?>">
<input class="oButton" value="Order" type="submit"/>
</form>

And then is another form (next page) with other fields witch I need to mail :

<?php 
//getting a variable from previous form
$product = $_POST['productName'];

if(isset($_POST['submit'])) 
{
$name = $_POST['order_name'];
$mail = $_POST['email'];
$phone = $_POST['mobile'];
$date = $_POST['date'];
$comment = $_POST['comment'];



//simple mail function goes here

$done = true;
}

?>

//Form2 goes here

So if I insert <?php echo $product; ?> before if(isset($_POST['submit'])) I can see my variable from previous page and all works just find. But when I am inserting that same variable in mail function witch is inside if(isset($_POST['submit'])) , I cant mail that variable, seems like it is empty.

Does form method POST delete all previous form data? Because, if I change my Form1 method to GET and $product = $_POST['productName']; to $product = $_GET['productName']; I am getting that variable after Form2 submit and I can mail that variable. But I would like to prefer using POST method, because of nice URL.

  • 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-22T15:41:06+00:00Added an answer on May 22, 2026 at 3:41 pm

    You forgot to name your submit button so there is no $_POST[‘submit’]

    <input class="oButton" value="Order" type="submit" name="submit" />
    

    EDIT:
    Okay, $_POST is array and have its values only after the post request. If you make another post request or change the page the previous values of $_POST are deleted and these from the new request are stored.
    You can store data from the first post in the sessions for example –

    $_SESSION['postData']['form1'] = $_POST;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get some form data from POST method. Here's the code
I'm trying to get some data from my database, and then pass it into
I'm trying to get some data from a certain web-based api using the libcurl
I'm trying to get some data from a table, where the tag has no
Using php I am trying to get some data from a .csv file which
I have sugar crm instance and i was trying to get some data from
I'm trying to get some json data from a remote website. I run my
I am trying to get some values from a List and then create a
Im trying to figure out a way to get some JSON data transfered from
I'm trying to get some data out my templates to, let's say, add an

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.