[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 06-28-2005, 08:10 AM   #1 (permalink)
NamePros Regular
 
cjcjcj's Avatar
 
Join Date: Aug 2004
Location: London, UK
Posts: 727
168.75 NP$ (Donate)

cjcjcj is a jewel in the roughcjcjcj is a jewel in the roughcjcjcj is a jewel in the rough


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?
cjcjcj is offline  
Old 06-28-2005, 08:30 AM   #2 (permalink)
Senior Member
 
dgaussin's Avatar
 
Join Date: May 2004
Location: France
Posts: 1,294
85.60 NP$ (Donate)

dgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to behold


You could get the url of the current page with some PHP code like :

Code:
 <? echo $_SERVER['PHP_SELF']?>
And for the title of page you could try something like :
Code:
<script>
document.write(document.title);
</script>
I didn't test but it should work... Replace the value in the form with the code and test...

Hope that helps,
David.
dgaussin is offline  
Old 06-28-2005, 08:50 AM   #3 (permalink)
NamePros Regular
 
cjcjcj's Avatar
 
Join Date: Aug 2004
Location: London, UK
Posts: 727
168.75 NP$ (Donate)

cjcjcj is a jewel in the roughcjcjcj is a jewel in the roughcjcjcj is a jewel in the rough


So I just take the first lot of code

Quote:
<? echo $_SERVER['PHP_SELF']?>
and put it in the place where the 'URL' would go?

Quote:
<!-- Change 'value' to site URL you want to be sent to the friend -->
<input type=hidden name="urlis" value="http://www.yourdomainname/yourpagename">

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 ????????
cjcjcj is offline  
Old 06-28-2005, 09:09 AM   #4 (permalink)
Senior Member
 
Porte's Avatar
 
Join Date: May 2005
Location: Somewhere on earth!
Posts: 3,528
21.30 NP$ (Donate)

Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of


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..
Porte is offline  
Old 06-28-2005, 09:25 AM   #5 (permalink)
NamePros Regular
 
cjcjcj's Avatar
 
Join Date: Aug 2004
Location: London, UK
Posts: 727
168.75 NP$ (Donate)

cjcjcj is a jewel in the roughcjcjcj is a jewel in the roughcjcjcj is a jewel in the rough


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?
cjcjcj is offline  
Old 06-28-2005, 09:49 AM   #6 (permalink)
Senior Member
 
Porte's Avatar
 
Join Date: May 2005
Location: Somewhere on earth!
Posts: 3,528
21.30 NP$ (Donate)

Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of


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';}
$_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.
Porte is offline  
Old 06-28-2005, 09:50 AM   #7 (permalink)
NamePros Regular
 
cjcjcj's Avatar
 
Join Date: Aug 2004
Location: London, UK
Posts: 727
168.75 NP$ (Donate)

cjcjcj is a jewel in the roughcjcjcj is a jewel in the roughcjcjcj is a jewel in the rough


Looks great - I'll let you know - thanks!
cjcjcj is offline  
Old 06-29-2005, 12:06 AM   #8 (permalink)
NamePros Member
 
Join Date: Oct 2003
Posts: 126
251.90 NP$ (Donate)

i386 is an unknown quantity at this point


If I understand this correctly, you'd need to use 'mailto:blah@blah.com' links. But... I'm not too sure if I understand it :-)
i386 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial: Getting started with PHP (The Basics) deadserious Webmaster Tutorials 60 11-17-2007 11:35 AM
HOWTO: Protect Your Email DarkDevil Webmaster Tutorials 12 08-17-2004 08:49 PM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 03:24 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85