Link to home
Start Free TrialLog in
Avatar of AHMED SAMY
AHMED SAMYFlag for Egypt

asked on

when i pass array how can i get input value

when i pass array how can i get input value in php

$value1=$resultpackages['Package_Price'];
                    $value2=$resultmarkup['markup'];
                    $value3=($value1*$value2)/100;
                    $value4=$value1+$value3;
                    $downname1=$_POST['downloadname'];

                    $priceid=$resultpackages['package_id'];
                    $pricevalue=$value4;
                    $price = array("$priceid","$value2","$value3","$pricevalue","$downname1");

                    $TP = json_encode($price);
                    $RequestTP = urlencode($TP);

Open in new window


the problem is downname1 is empty how i can do
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

the problem is downname1 is empty how i can do
What are you expecting to be?
Where is your form code?

Your question is not clear - can you clarify what you are wanting?
Avatar of AHMED SAMY

ASKER

i am trying to export php to word and there is images and some inputs need to take it's values

i make it in a separate page it is working but inputs value is empty

and images not appears

this is the code in the first page :

<div id="Download" class="hide  breadcrumb">
				
        	<div class="col-lg-12">
                <p style="color:#F00">Ti consigliamo di impostare il markup standard per un livello di maturità più elevato.</p>
				<div class="float-left col-lg-6">
                    nome del cliente :

                    <?php
                    $user=$_SESSION['username'];
                    $sqlmarkup="SELECT markup FROM markup WHERE user_name='$user'";
                    $querymarkup=mysqli_query($connect,$sqlmarkup);
                    $resultmarkup=mysqli_fetch_array($querymarkup);

                    $value1=$resultpackages['Package_Price'];
                    $value2=$resultmarkup['markup'];
                    $value3=($value1*$value2)/100;
                    $value4=$value1+$value3;
                    $downname1=$_POST['downloadname'];

                    $priceid=$resultpackages['package_id'];
                    $pricevalue=$value4;
                    $price = array("$priceid","$value2","$value3","$pricevalue","$downname1");

                    $TP = json_encode($price);
                    $RequestTP = urlencode($TP);
                    ?>
                    <input type="text" name="downloadname" placeholder="client name" class="form-control" >
					<br>

                    Scarica il tipo:

                    <a href="hi.php?wordText=<?php echo $RequestTP; ?>" class="btn btn-primary">word</a>

                    <br>
					<br>

                    <p>Il tuo markup: <input type="text" id="markup" name="markup" value="<?php echo $value2; ?>" disabled/></p>
                    <br>

                </div>

Open in new window


export page is
$TP = urldecode($_REQUEST['wordText']);
    $Mixed = json_decode($TP);
    $id=$Mixed[0];
    $value2=$Mixed[1];
    $value3=$Mixed[2];
    $pricevalue=$Mixed[3];


    $sqlpackages="SELECT * FROM packages WHERE package_id='$id' ";
    $querypackages=mysqli_query($connect,$sqlpackages);
    $resultpackages=mysqli_fetch_array($querypackages);

    $name=$_SESSION['username'];
    $sqlname="SELECT * FROM users WHERE user_name='$name' ";
    $queryname=mysqli_query($connect,$sqlname);
    $resultname=mysqli_fetch_array($queryname);

    $name=$_SESSION['username'];
    $today=date("d/m/y");
    $travel=$resultpackages['valid_date'];
    $trip=$resultpackages['Trip_Duration'];
    $price=$resultpackages['Package_Price'];
    $client=$Mixed[4];

    $download_sql="INSERT INTO download(Downloads,Travel_Date,Trip,Markup,Net,Markup_Price,Sale,Reference,user_name) VALUES('$today','$travel','$trip','$value2','$price','$value3','$pricevalue','$downname','$name')";
    $downquery=mysqli_query($connect,$download_sql);


    header("cotent-type:application/vnd.msword");

    $filname="package.doc";
    header("content-disposition:attachment;filename=".$filname);

Open in new window

if there is simple way to export data from form to word please help
i tried many ways useless
Where is package.doc coming from?
from database and i bring some data pass in array
You want to know about this
$downname1=$_POST['downloadname'];

Open in new window

Which implies somewhere you have a form or a script that is posting to this script.

Where are you doing the post - where is the code that is doing that?
exactly what i mean i will make some inputs and will take this all values to another page to print it or export it
first is page you give inputs
export page is taking values to export word
There are many things I don't understand here
The code you posted - there is no <form> tag
You have lines like this
$value1=$resultpackages['Package_Price'];

Open in new window

$resultpackages is not defined anywhere.

To help you I need something to work with.

Your question is
the problem is downname1 is empty how i can do
This comes from this form element
<input type="text" name="downloadname" placeholder="client name" class="form-control" >

Open in new window


So without seeing the rest of your code I am going to say it is empty because
Either you are not setting your <form method="POST" ...> and the value is not being POSTED
OR
You are not entering a value for that control

I can't help anymore until you give me more information.

Start with posting your full <form> code - not just a bit of it.
first

$sqlpackages="SELECT * FROM packages WHERE package_id='$id' ";
    $querypackages=mysqli_query($connect,$sqlpackages);
    $resultpackages=mysqli_fetch_array($querypackages);

second

<form action="<?php echo $PHP_SELF; ?>" method="post">
$sqlpackages="SELECT * FROM packages WHERE package_id='$id' ";
    $querypackages=mysqli_query($connect,$sqlpackages);
    $resultpackages=mysqli_fetch_array($querypackages);

Open in new window

This comes from the export page.
The first page uses $resultpackages as well - that is what I was referring to.

Chang your <form> to point to this script
reflect.php
<?php
echo "<pre>";
print_r($_POST);
print_r($_GET);
echo "</pre>";
?>

Open in new window

And post the results here.
change first or second page
<form>
I don't understand? You have a form that is posting to a page?

Change the form's action to be the script I posted above - this is called a reflection script - it shows us what was entered into the form.

Your question is why certain information is not being posted by the form. To do that we need to break the process down into

1. What the form sends - is it sending what we think it is
2. What the receiving script is receiving.
Array
(
    [cust_date] => 01/02/2018
    [Duration] => 10 Notti / 11 Giorni
    [cust_rooms] => 4
    [carused] => Toyota Hiace
    [meal] => Breakfast
    [cust_clientname] => 54545
    [category] => Hilton Marsa Alam Nubian Resort
    [cust_Comment] => per 4545scrivi qui
    [customize] => personalizzare
    [book_date] =>
    [clientname] =>
    [rooms] => 0
    [children] => 0
    [agechildren] => 0
    [comment] => per favore scrivi qui....
    [clientsave] =>
)
Array
(
)
thanks and forgive me for disturbing
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you are right
i changed many times because that time i make this job no body support
let me change and see result