Guest User

Untitled

a guest
Sep 1st, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. Call a function from Included file?
  2. // MyFunc.php
  3. <?php
  4. function DoStuff()
  5. {
  6. $var = 'something';
  7. return $var;
  8. }
  9. ?>
  10.  
  11.  
  12. // index.php
  13. <html>
  14. <head></head>
  15. <body>
  16. Hi, I am currently doing <?php include "MyFunc.php"; echo DoStuff(); ?>, pretty cool, right?
  17. </body>
  18. </html>
  19.  
  20. //splashgen.php
  21. <?php
  22.  
  23. $refid = $_GET['ref'];
  24. $output = 'Company';
  25.  
  26. function GetSponsor()
  27. {
  28.  
  29. if($refid!='')
  30. {
  31. $dbhost = "localhost";
  32. $dbuser = "myuser";
  33. $dbpass = "mypass";
  34.  
  35. $dbname = "mydb";
  36.  
  37. $sqlselect = "SELECT * FROM egbusiness_members WHERE loginid='$refid';";
  38.  
  39. $con = mysql_connect($dbhost,$dbuser,$dbpass) or die('Unable to connect to Database Server!');
  40. mysql_select_db($dbname) or die('Could Not Select Database!');
  41.  
  42. $refid = stripslashes($refid);
  43. $refid = mysql_real_escape_string($refid);
  44.  
  45. $result = mysql_query($sqlselect);
  46.  
  47. while ($row = mysql_fetch_array($result))
  48. {
  49. $output = $row['name_f']." ".$row['name_l']." (".$refid.")";
  50. }
  51. mysql_close($con);
  52. }
  53. return $output;
  54.  
  55. }
  56.  
  57.  
  58. ?>
  59.  
  60. /////////
  61.  
  62. // index.php
  63.  
  64. ...
  65.  
  66. <font style="font-size:19px" color="#0093C4" face="Calibri"><b>
  67. This page was brought to you by: <?php $_GET['ref']; include "../splashgen.php"; echo GetSponsor(); ?>
  68. </b></font></div>
  69. ...
  70.  
  71. <body>
  72. Hi, I am currently doing <?php include "MyFunc.php"; echo DoStuff(); ?>, pretty cool, right?
  73. </body>
  74.  
  75. echo DoStuff();
  76.  
  77. <body>
  78. Hi, I am currently doing <?php include "MyFunc.php"; echo DoStuff; ?>,
  79. pretty cool, right?
  80. </body>
  81.  
  82. <body>
  83. Hi, I am currently doing <?php include "MyFunc.php";
  84. echo DoStuff(); ?>, pretty cool, right?
  85. </body>
  86.  
  87. function GetSponsor() {
  88.  
  89. function GetSponsor($refid) {
  90.  
  91. <font style="font-size:19px" color="#0093C4" face="Calibri"><b>
  92. This page was brought to you by: <?php $_GET['ref'];
  93. include "../splashgen.php"; echo GetSponsor(); ?>
  94. </b></font>
  95.  
  96. <font style="font-size:19px" color="#0093C4" face="Calibri"><b>
  97. This page was brought to you by:
  98. <?php
  99. include "../splashgen.php";
  100. $refid = $_GET['ref'];
  101. echo GetSponsor($refid); ?>
  102. </b></font>
  103.  
  104. Function DoStuff($var)
  105. {
  106. if($var != '')
  107. {
  108. return 'I am currently '.$var;
  109. }
  110. }
  111.  
  112. ...
  113.  
  114. echo DoStuff('posting on Stack Overflow');
Add Comment
Please, Sign In to add comment