Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

My question is how do I call input value of user selected which has show by php code from another php.

Normal simple way we get the input this way

 $calendar_id_val = $_GET['calendar_id']; 

and now it is not working:

For example Show.php, I have one form which show the values from Database and show the result with php variable with While Loop.

<input name="calendar_id" value="<?php echo $calendar_id;?>">

and when user is submit that form I will carry these user selected value and perform insert.php

share|improve this question
What is the type of your form.get or post..??Can you show the html..?? – User016 Aug 5 at 6:30
your form looks like this <form action="insert.php" method="get"> or <form action="insert.php" method="post"> ? if get is used in your form then you should use $_GET in insert page, if you used the post in your form then yous should use the $_POST variables in insert.php – sudhakar Aug 5 at 7:08
add comment (requires an account with 50 reputation)

4 Answers

While you are doing echo in the input use echo $calendar_id_val

share|improve this answer
I call $calendar_id_val at second php "insert.php" and the result is not shown. – ahkeno Aug 5 at 6:31
add comment (requires an account with 50 reputation)

You should use form like,

<form action="insert.php" method="get">
  <input type="text" name="calendar_id" value="<?php echo $calendar_id;?>"/>
  <input type="submit" name="submit_id" value="Insert"/>
</form>

Insert.php

echo $calendar_id_val = $_GET['calendar_id']; 
share|improve this answer
my form function is using <form action="insert.php" method="get"> and I type same way as echo $calendar_id_val = $_GET['calendar_id']; the result is not shown – ahkeno Aug 5 at 6:33
Try print_r($_REQUSET), before echoing, also check whether or not it goes on insert.php – Rohan Kumar Aug 5 at 6:35
add comment (requires an account with 50 reputation)

Does this answer your question?

<form action="insert.php" method="GET">
    <input name="calendar_id" value="<?php echo $calendar_id;?>">
</form>

If you want to redirect the user back to show.php, add this to the end of your insert.php script

header('Location: show.php');
exit();
share|improve this answer
I know how to redirect back,it is not my question – ahkeno Aug 5 at 6:34
add comment (requires an account with 50 reputation)

I suggest $_POST var like this:

<form action="insert.php" method="POST">
  <input type="text" name="calendar_id" value="<?php echo $calendar_id;?>" />
  <input type="submit" name="submit" value="Submit" />
</form>

insert.php file:

echo $calendar_id = $_POST['calendar_id']; 
share|improve this answer
add comment (requires an account with 50 reputation)

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.