Jump to content


Photo

href include


  • Please log in to reply
4 replies to this topic

#1 proctk

proctk
  • Members
  • PipPipPip
  • Advanced Member
  • 300 posts

Posted 09 September 2006 - 01:47 AM

Below is code that I'm trying to use to include a page if a link is clicked from some reason it does not wany ideas why

<p><a href="lost_pw.php" onClick="<? include 'last_pw.php';?>"> Get new Password</a></p>



#2 sim0ng

sim0ng
  • New Members
  • Pip
  • Newbie
  • 7 posts
  • LocationEngland

Posted 09 September 2006 - 01:56 AM

personally, i do include tags like

<?php include('last_pw.php'); ?>

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 09 September 2006 - 02:01 AM

php runs on your server before the generated code is sent to your browser. html/javascript runs on the client (your computer). You can't run php on your client, so the onClick include stuff just isn't going to work.  You'll need to direct the lost password to a NEW file.
Legend has it that reading the manual never killed anyone.
My site

#4 proctk

proctk
  • Members
  • PipPipPip
  • Advanced Member
  • 300 posts

Posted 09 September 2006 - 02:02 AM

ops thanks for pointing out my error however it still just rediects me to the next page


updated code
<p><a href="lost_pw.php" onClick="<?php include('last_pw.php');?>">Get new Password</a></p>


#5 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 09 September 2006 - 02:13 AM

Right. The include isn't going to happen and clicking the link is just going to take you to lost_pw.php.

Perhaps what you can work with is passing a value in the link ...

<a href="lost_pw.php?help=now">lost pw</a>

And then in lost_pw.php - all on its own as a file - retrieve the value of $help from the $_GET array.  If $help =="now" you'll know you arrived there from the link above and THEN you can include the last_pw.php file
Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users