jeudi 27 août 2015

how to get the value of selected text box value using php

I have list of properties and i get the list of users who matched to my selection criteria.

I need to send mail to the selected users.

I am check all option to check every user.

and i have text box for every user to change the rent value.

And i selected some user and click on send i need to send mail with value in the textbox.

I want to get the selected text box value in to form submit code.

Here is the sample code.

    while($tenant = mysqli_fetch_array($result))
        {
        echo '
        <tr>

            <td>
                <a href="property.php?id='.$pro['id'].'"><img src="'.(($pro['image_1']) ? $pro['image_1'] : 'images/placeholder.png').'" alt="" width="100"></a>
            </td>

            <td><a href="#">'.$name['name'].$tenant['tenant_id'].' </a><br> '.$pro['name'].'</td>

            <td><b>'.$tenant['lease_exp'].'</b><br><i>'.$pro['ready'].'</i></td>

            <td>'.$pro['type'].'</td>

            <td><div class="price"><strong>$</strong><span>'.$tenant['rent_from'].'-'.$tenant['rent_to'].'</span></div><br><br><input type="text" name="new_rent'.$i.'" value='.$pro['rent'].' class="form-control" style="width:30%;" ></td>

            <td>
                <input type="checkbox" name="rent[]" id="rent'.$i.'" value="'.$tenant['tenant_id'].'"> Send

            </td>
        </tr>
        ';
    }

    <script>
    $(document).ready(function() {
    $('#all').change(function(){
    var ckb_status = $("#all").prop('checked');
    $('input[type="checkbox"]').prop("checked", ckb_status );
    });
    });
    </script>

    if(isset($_POST['submit'])) {
      if(!empty($_POST['rent'])) {
          print_r($_POST);
        foreach($_POST['rent'] as $check) {

            $tenant_profile = "SELECT * FROM tenant where id=".$check;
            $prof = mysqli_query($link, $tenant_profile);
            $profile = mysqli_fetch_array($prof);



            //echo $tenant_profile;
            //echo "</br>";
            //echo $pro['name'];

            echo $_POST['new_rent'];echo "</br>";

            $to      = $profile['email'];
            $subject = 'Price Change Alert';
            $header = "From: ".ADMIN_EMAIL."\r\n"; 
            $header.= "MIME-Version: 1.0\r\n"; 
            $header.= "Content-Type: text/plain; charset=utf-8\r\n"; 
            $header.= "X-Priority: 1\r\n"; 
            $message = '' ;
            $message .= "<div><p>Dear User there is a price drop for the property
            <a href='".$_SERVER['SERVER_NAME']."/property.php?id=".$pro['id']."'>".$pro['name']."</a></p>
            <p>Owner offering you ".$_POST['new_rent'].". </p>
            <p>please contact the owner for the complete details. </p>
            <p>Owner email id:#</div>";

            $mail1 = mail($to, $subject, $message, $header);

            if($mail1) { echo 'mail sent successfully'; }


        }// foreach
      } //empty checkbox check
    else  { echo "Plase Check Any Result"; }
    }//submit




Aucun commentaire:

Enregistrer un commentaire