Jump to content


Photo

Button link to include file


  • Please log in to reply
2 replies to this topic

#1 GameOn

GameOn
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 04 May 2005 - 12:47 PM

Hi
Couple of small questions...

1.
I have about six buttons but I need one to link to a php include file... how do i do this???

I tried
<td align="left" valign="top" ><a href="<? include 'about.inc.php' ?>" target="_self"><img src="aboutus.gif" alt="Click here to view" width="143" height="35" border="0"></a></td>

But it just showed the contents of the include file underneath the previous button in the table...

Any ideas?
Also any ideas to my other hyperlink query post?


2.
Also, say a php file carries out a action like updating the database, you have a echo at the end once the update has occured confirming that it was successful.
I want to put it into another php file, eg. a successful comment in index, how do I do this?

I tried the echo before the include statement, but it put the comment above the page information rather then in the middle of it.

eg.
<?PHP
echo "<br>Update complete.\n
<br><br>
Here are the products.<br><br>";
include 'products.php';
?>

How do I get it to go to another page after its processed the info of the inc file, and put the confirm message (echo code in inc file) to another page.

At the moment I basically have to put the entire contents of the site on the processing page so that its not just a blank page with a confirmation message.

#2 bzerr

bzerr
  • Members
  • Pip
  • Newbie
  • 5 posts
  • LocationCold Lake, Alberta, Canada

Posted 05 May 2005 - 03:20 PM

Okay, for what you're talking about, it seems that you are using include a bit too much :P

Question 1
You can't make a button include a php file once the file is in your browser window. What you could do is make the button link to that php file, or link to the local file, with a variable in the request string, making PHP include the file itself.
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--][span style=\"color:#0000BB\"]<?
[/span][span style=\"color:#007700\"]if([/span][span style=\"color:#0000BB\"]$_GET[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]includefile[/span][span style=\"color:#007700\"]]==[/span][span style=\"color:#0000BB\"]1[/span][span style=\"color:#007700\"]) {
  include([/span][span style=\"color:#DD0000\"]\"myfile.php\"[/span][span style=\"color:#007700\"]);
}
[/span][span style=\"color:#0000BB\"]?>
[/span]<td align=\"left\" valign=\"top\" ><a href=\"thisfile.php?includefile=1\" target=\"_self\"><img src=\"aboutus.gif\" alt=\"Click here to view\" width=\"143\" height=\"35\" border=\"0\"></a></td>[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

Question 2
Once again use a variable on the URL, stay away from that include if you can :P
File 1

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--][span style=\"color:#0000BB\"]<?
[/span][span style=\"color:#FF8000\"]//successful database query here
[/span][span style=\"color:#0000BB\"]header[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"Location: index.php?dbquerysuccess=1\"[/span][span style=\"color:#007700\"]);
[/span][span style=\"color:#0000BB\"]?>
[/span]
[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

File 2 (index.php)
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--][span style=\"color:#0000BB\"]<?
[/span][span style=\"color:#FF8000\"]//your code here
[/span][span style=\"color:#007700\"]if([/span][span style=\"color:#0000BB\"]$_GET[/span][span style=\"color:#007700\"][[/span][span style=\"color:#0000BB\"]dbquerysuccess[/span][span style=\"color:#007700\"]] == [/span][span style=\"color:#0000BB\"]1[/span][span style=\"color:#007700\"]) {
  echo [/span][span style=\"color:#DD0000\"]\"Successful Database Query\"[/span][span style=\"color:#007700\"];
}
[/span][span style=\"color:#0000BB\"]?>[/span]
[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]
Apache 1.3.33
MySQL 4.0.21
PHP 5.0.3
Linux 2.6.3

#3 GameOn

GameOn
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 07 May 2005 - 03:46 AM

:)

A big thanks for that. I dont know what i was thinking... I was actually thinking along the lines of performing something when the button was clicked so this what i used:

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
td align=\"left\" valign=\"top\" ><a href=\"login.php?ShowRegister=yes\" target=\"_self\"><img src=\"register.gif\" alt=\"Click here to Register\" width=\"143\" height=\"35\" border=\"0\"></a></td>
[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

Yes stay away from using includes!! Thanks for the help in such a insane question.

As for question two, I'll have a play around, your code looks useful :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users