| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Regular Join Date: Aug 2004 Location: London, UK
Posts: 727
![]() ![]() ![]() | Needed: 'Email a friend' php code with . . . I need a php code like the one here: http://www.ibdjohn.com/sendurl/ BUT I need it to automatically read the name of the page it is on so I can paste it on 40+ pages without having to manually alter the code to point the email to the URL. Is this possible? |
| |
| | #2 (permalink) |
| Senior Member Join Date: May 2004 Location: France
Posts: 1,226
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | You could get the url of the current page with some PHP code like : ????: NamePros.com http://www.namepros.com/programming/102474-needed-email-a-friend-php-code.html Code: <? echo $_SERVER['PHP_SELF']?> Code: <script> document.write(document.title); </script> Hope that helps, David. |
| |
| | THREAD STARTER #3 (permalink) | ||||||||
| NamePros Regular Join Date: Aug 2004 Location: London, UK
Posts: 727
![]() ![]() ![]() | So I just take the first lot of code
????: NamePros.com http://www.namepros.com/showthread.php?t=102474
I don't know a lot about php so how does this work? <input type=hidden name="urlis" value=<? echo $_SERVER['PHP_SELF']?> Or where else does this code go ???????? | ||||||||
| |
| | #4 (permalink) |
| Senior Member Join Date: May 2005 Location: I'm right here
Posts: 3,526
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | cjcjcj, Like this: <input type=hidden name="urlis" value="http://www.yourdomainname/yourpagename"> Replace the bold so it could be: <input type=hidden name="urlis" value="<? $page_url = 'http://www.yourdomainname.com'; // your domain name here $page_url .= $_SERVER['PHP_SELF']; echo $page_url; ?>"> just edit the domain name.. |
| |
| | THREAD STARTER #5 (permalink) |
| NamePros Regular Join Date: Aug 2004 Location: London, UK
Posts: 727
![]() ![]() ![]() | A little confused. I wanted to get a code where I wouldn't need to enter the domain name on each page where I put the code. Instead, the code would read it from somewhere and adapt the email that is sent out to the 'friend'. What does the above code do? |
| |
| | #6 (permalink) |
| Senior Member Join Date: May 2005 Location: I'm right here
Posts: 3,526
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Ok well, I found this premade code for you, I think it does what you look for. <input type=hidden name="urlis" value=" <? $_SERVER['FULL_URL'] = 'http'; if($_SERVER['HTTPS']=='on'){$_SERVER['FULL_URL'] .= 's';} ????: NamePros.com http://www.namepros.com/showthread.php?t=102474 $_SERVER['FULL_URL'] .= '://'; if($_SERVER['SERVER_PORT']!='80') $_SERVER['FULL_URL'] .= $_SERVER['HTTP_HOST'].':'.$_SERVER ['SERVER_PORT'].$_SERVER['SCRIPT_NAME']; else $_SERVER['FULL_URL'] .= $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; if($_SERVER['QUERY_STRING']>' '){$_SERVER['FULL_URL'] .= '?'.$_SERVER['QUERY_STRING'];} echo $_SERVER['FULL_URL']; ?> "> It should output the full url in the value. Copy the code where you want to use it, and you do not need to edit anything. |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Tutorial: Getting started with PHP (The Basics) | deadserious | Webmaster Tutorials | 60 | 11-17-2007 12:35 PM |
| HOWTO: Protect Your Email | DarkDevil | Webmaster Tutorials | 12 | 08-17-2004 09:49 PM |