ollie007 Posted June 10, 2009 Share Posted June 10, 2009 $_POST[$type] is that how i write the variable or do i need ".$type." ? Quote Link to comment Share on other sites More sharing options...
FWDrew Posted June 10, 2009 Share Posted June 10, 2009 Assuming $type is defined somewhere, that should be fine. Quote Link to comment Share on other sites More sharing options...
gevans Posted June 10, 2009 Share Posted June 10, 2009 You don't need the dollar sign. You are trying to access a $_POST value with the key of whatever is assigned to $type, which I'd imagine is nothing. $_POST['type']; Quote Link to comment Share on other sites More sharing options...
ollie007 Posted June 10, 2009 Author Share Posted June 10, 2009 no, $type is a string, so do i need the $ sign? $type='name' $type='address' Quote Link to comment Share on other sites More sharing options...
gevans Posted June 10, 2009 Share Posted June 10, 2009 In which case yes, you need the dollar sign. If $type is a string, and the string references one of the keys in $_POST it should work fine the way you originally posted. <?php //assuming name has been sent via post $type = 'name'; $name = $_POST[$type]; echo $name; If you are in a development environment and have errors on, you will see an error if the key does not exist. Quote Link to comment Share on other sites More sharing options...
trq Posted June 10, 2009 Share Posted June 10, 2009 ollie, I seriously think you need to find a good book. Coming here an asking multiple simple questions will take you forever to learn what's going on. There's a good free book in my signature (Hudzilla) should get you started. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.