1

I have this code in HTML:

 <input type ="text" name="<?php echo $id_global;?>"</input>

Then after submitting the form, I am trying something like this, but it's not working:

$id_s = $_POST['$id_global'];
1
  • You can't do this because when you submit your form, the name will be something you don't know. It's $_POST something. You can do print_r($_POST); to find it Commented Aug 28, 2015 at 12:11

3 Answers 3

2

You need to remove the quotes,

try $id_s=$_POST[$id_global];

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

2 Comments

Then we will need more context around your code, because that is the only error we can see right now.
@zeeshansarfraz does this $id_global variable still contain a value after you have posted?
0

Remove the quotation marks '

$id_s=$_POST[$id_global];

Comments

0

Try with double quotes php will not consider variable between single quotes and try with this also :

<?php 
    $id_global = 'field_name';
?>
<form action="/Stackoverflow/index.php" name="testForm" method="POST">
    <input type ="text" name="<?php echo $id_global;?>" />
</form>

<?php 
if($_POST){
    echo '<pre>';
    print_r($_POST[$id_global]);
}
?>

Edit the action as per your need

1 Comment

$id_global =$_GET['id']; This is how i am storing value in $id_global; @Ashish Ranade

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.