0

I want to pass a input value with a url.

<div class="modal-body">
    <div id="myDiv" class="answer_list">
        <form action="" id="usrform" method="get">
            <textarea name="comment" style="width: 450px; height: 80px; form="usrform"></textarea>

   <?php echo '<a href="reject_request.php?leave_id='.$id1.'&emp_id='.$emp_id.'">'?>
   <button style="float: right" type="button"  class="btn btn-primary" name="submit">
        Proceed
    </button></a></form></div>
</div>

Here I want to pass the textarea input value to 'reject_request.php' page with other variables. I couldn't able to find a way, Can any one help me !

5
  • <form action="reject_request.php" ... ? Commented Jun 13, 2016 at 11:23
  • 1
    Its not good habit to post textarea long content in url..instead post form to reject_request.php on anchor tag click Commented Jun 13, 2016 at 11:23
  • So how can I get its value? Commented Jun 13, 2016 at 11:27
  • you can get the value via GET/POST variable.ex-$_GET['value'] or $_POST['value'] Commented Jun 13, 2016 at 11:31
  • But it does not work in this case Commented Jun 13, 2016 at 11:33

2 Answers 2

2

Use method="POST" and action="reject_request.php"

<form action="reject_request.php" id="usrform" method="POST">
  <textarea name="comment" id="comment"></textarea>
  <input type="hidden" name="leave_id" id="leave_id" value="<?php echo $id1; ?>">
  <input type="hidden" name="emp_id" id="emp_id" value="<?php echo $emp_id; ?>">
 </form>

In reject_request.php you can access the form datas via $_POST['comment'],$_POST['leave_id'],$_POST['emp_id']

Sign up to request clarification or add additional context in comments.

1 Comment

That was exactly what I want. Thank you so much !
0

First of all, it is not advisable to pass long content in URL, as commented by @Dhara Parmar.

But if you want to do it,

<form action = "yourpage.php" .... as, again, commented by splash 58

As far as accessing those variables are concerned, you can access them via ASSOCIATIVE GLOBAL ARRAY $GET[KEY]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.