Atnaize
Atnaize

Reputation: 1816

Call PHP page with argument within PHP

I have to create a PHP menu that can manage simple billing stuff.

I created a PHP page that generate a quote (create_quote.php). This page get an argument and I use a button <a href=\"create_quote.php?var=$id_patient\" >Create quote</a> to call this page.

I have another page that is pretty similar but this second page generate a billing (create_billing.php). Same story, I send an argument to get this document filled.

A billing can not be created if the quote was not generated before. I do not want a simple warning to display so I would like to create the quote if the billing is not created and the user clicked the 'Create billing' link anyway

I added this to my create_billing.php

if( /*The quote is not yet generated*/)
{
    include "create_quote.php?var='$myVarToSend'";
}
else
{
    ...
}

But it is not working. Do I have to make an Ajax call ? Why does it not work ?

Upvotes: 1

Views: 46

Answers (1)

Geoff Atkins
Geoff Atkins

Reputation: 1703

You don't need to pass variables in a $_GET string to an included page.

Simply define the variable and it will be available to the code within the include.

if( /*The quote is not yet generated*/)
{
    $var = $myVarToSend;
    include "create_quote.php";
}
else
{
    ...
}

The variable being sent will now be available as $var for the included file.

Upvotes: 3

Related Questions