I have binary which will generate html file. I am trying to call php function in the tag but it will take the relative path from current file. My code is as below. cpp file
cout<<"<?php"<<endl;
cout<<"if (isset($_GET['function'])){"<<endl;
cout<<"echo 'clicked'";
cout<<" }"<<endl;
cout<<">"<<endl;
sprintf(retStr,"<u>%s%s%s</u>", "<A HREF=\"?function\">",errorcode.c_str(),"</A>");
cout<<retStr.c_str();
Generated php:
<?php
if (isset($_GET['function'])){
echo 'clicked' }
>
Html:
<u><A HREF="?function">23427</A></u>
I want to call php function from the link, but it will take it as relative path of same binary. When i hover the link it will show http://localhost/dir/binary?function
How can I make it take the php function ?
NOTE: I don't have knowledge of php.
Your code has error which is generating PHP code it should be as following:
cout<<"<?php"<<endl;
cout<<"if (isset($_GET['function'])){"<<endl;
cout<<"echo 'clicked';";
cout<<" }"<<endl;
cout<<"?>"<<endl;
sprintf(retStr,"<u>%s%s%s</u>", "<a href=\"../binary?function\">",errorcode.c_str(),"</a>");
cout<<retStr.c_str();
Above code will work for you.
EDITED:
sprintf(retStr,"<u>%s%s%s</u>", "<a href=\"<?php echo $_REQUEST['SELF'];?>?function\">",errorcode.c_str(),"</a>");