macky nyxz
macky nyxz

Reputation: 1

How to pass the data in the input type using php

Hi, I want to know how to pass the data into the input type field; I'm using only $_POST method and also I did not use the database first. Please help.

form.php

 <form action="booking.php" method="post">
         <p>
          I want to be pick up at:
         </p>
         <p>
          <input placeholder="Enter Address, Airport, Landmark" type="text" name="pickupplace" id="pickupplace" autocomplete="off" tabindex="1" style="width: 260px;"/>
         </p>
         <p>
          drop off at
         </p>
         <p>
           <input placeholder="Enter Address, Airport, Landmark" type="text" name="dropoff" id="dropoff" autocomplete="off" tabindex="2" style="width: 260px;" />
         </p>

      </form>

in the booking.php

<div>
    <p>From</p>
    <p>

   <p>
  <?php

    if(isset($_POST['pickupplace']) == NULL){
        echo "-";
        }
    else{
    echo $_POST['pickupplace'];
    }

    ?></p>

  </div>

in the edit_ride.php

<div>
   <p>From</p>
   <p> 
  <input type="text" name="pickupplace" placeholder="Enter Address, Airport, Landmark"/>
   </p>

 </div>

i want to pass the data into the edit_ride.php in the input type please help here it is,

Upvotes: 0

Views: 260

Answers (2)

G10DRA
G10DRA

Reputation: 61

why are you specifying the form action booking.php if you need to submit your data on edit ride.php

so first of all change the form action to edit_ride.php and then recieve the data in your textbox as following on the page edit_ride.php

 <input type="text" value="<?php if(isset($_REQUEST['pickupplace'])) echo $_REQUEST['pickupplace']; ?>" name="pickupplace" placeholder="Enter Address, Airport, Landmark"/>

Upvotes: 0

AjayR
AjayR

Reputation: 4179

What you can do is, you can merge edit_ride.php and booking.php, so that directly you can display the values using

  <input type="text" name="pickupplace" value="<?php echo $_POST['pickupplace']" placeholder="Enter Address, Airport, Landmark"/>

This may not be the only solution, as some time we need multiple pages, in that case you may consider sessions or cookies also.

Alternatively, you can pass the values from one page to another using querystring ($_GET) method also without submit the forms in internal pages.

Upvotes: 1

Related Questions