简体   繁体   中英

to display message in same form page

I need to add a notification to this page saying " Thank you for your feedback" However,the notification did not appear at the correct place,which is above the form.

This is my code.

      $message="tq 4 feedback";
      $common->display_message($message);

This is where the feedback form. The function i'm using is

    function display_message($message) {
print $message;
}

Thanks

It's probably an issue with your view, to be honest. What's your view look like?

Not sure why if you have the message already you are passing it to a function to display, but you need to "return" the variable from the function. Then you can echo it out wherever you need to.

function display_message($message) {
    return $message;
}

To call it:

$message="tq 4 feedback";
$returned_message = $common->display_message($message);

And place it where you want:

echo $returned_message;

or just:

$message="tq 4 feedback";
echo $common->display_message($message);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM