Jump to content

Recommended Posts

Hey,

 

I have defined a post value into a constants and I am trying to call the defined constant into a URL but its not working. It worked for a variable, but not for a constant.

 

I have noticed that usually constants are defined in all caps. I defined it in lower case... Can that be the issue? Below is an example of how I wrote the code.

 

Thank you!

 

 

if(isset($_POST['submit'])) {
define("store_name", "{$_POST['store_name']}");
goto_page("store_configuration_setting.php?send_store=".store_name."");

That's not really what constants are for. You are relying on the fact that a variable will exist prior to setting the constant. A variable which comes from the user, and is only set under certain circumstances. Why not, then, just use a variable in place of the constant?

That's not really what constants are for. You are relying on the fact that a variable will exist prior to setting the constant. A variable which comes from the user, and is only set under certain circumstances. Why not, then, just use a variable in place of the constant?

 

I like to get int he habit of using constants, since its always going to stay constant and not change. Is it possible to store POST subper globals into constants??

Can you please explain me what do you mean by setting it?

 

It means use a hardcoded value i.e

define('SITE_EMAIL_ADDRESS', 'joe@bloggs.com');

 

As the site email address will never change (it is constant) it is hardcoded into a CONSTANT.

 

Data which comes from the superglobal arrays $_POST, $_GET, etc is NOT constant. It can be ammended by a user.

 

The answer is to hardcode a value. There is no need to post it through a form or send it through the url as it will always be available if you are including you constants definintion file throughout your site.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.