0

I have a file with the following code block inside some of the page html:

<input name="appname" type="text" value="<?php Load('appname'); ?>" placeholder="Your App Name" />

which calls this function:

<?php
// Load cookie values 
function Load($item) {
    $item = strtolower($item);
    if(!$_COOKIE['appsite_'.$item]) return null;
    return $_COOKIE['appsite_'.$item];
}
?>

The function is at the top of the HTML file, the cookies are created but for some reason the code inside the input HTML markup is not being executed.

I can access the value of the cookie by doing the following just beneath the function:

$item = "appname";
echo $_COOKIE['w8appsite_'.$item];

It seems like the PHP code lower down the file is just not being executed?

2
  • HTML and PHP are not the same. Commented Dec 10, 2012 at 22:39
  • Is a simple return statement of a function sufficient to echo out the contents? Commented Dec 10, 2012 at 22:41

2 Answers 2

6

Try the following:

<input name="appname" type="text" value="<?php echo Load('appname'); ?>" placeholder="Your App Name" />

You need to echo strings in PHP

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

Comments

0

You are setting cookie $_COOKIE['w8appsite_appname'] and in the function checking for $_COOKIE['appsite_appname'] which will always return null.

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.