NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Needed: 'Email a friend' php code with . . .

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

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 06-28-2005, 09:10 AM THREAD STARTER               #1 (permalink)
NamePros Regular
 
cjcjcj's Avatar
Join Date: Aug 2004
Location: London, UK
Posts: 727
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, 09:30 AM   #2 (permalink)
Senior Member
 
dgaussin's Avatar
Join Date: May 2004
Location: France
Posts: 1,226
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 beholddgaussin is a splendid one to behold
 




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']?>
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, 09:50 AM THREAD STARTER               #3 (permalink)
NamePros Regular
 
cjcjcj's Avatar
Join Date: Aug 2004
Location: London, UK
Posts: 727
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?
????: NamePros.com http://www.namepros.com/showthread.php?t=102474

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, 10:09 AM   #4 (permalink)
Senior Member
 
Porte's Avatar
Join Date: May 2005
Location: I'm right here
Posts: 3,526
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, 10:25 AM THREAD STARTER               #5 (permalink)
NamePros Regular
 
cjcjcj's Avatar
Join Date: Aug 2004
Location: London, UK
Posts: 727
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, 10:49 AM   #6 (permalink)
Senior Member
 
Porte's Avatar
Join Date: May 2005
Location: I'm right here
Posts: 3,526
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';}
????: 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.
Porte is offline  
Old 06-28-2005, 10:50 AM THREAD STARTER               #7 (permalink)
NamePros Regular
 
cjcjcj's Avatar
Join Date: Aug 2004
Location: London, UK
Posts: 727
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, 01:06 AM   #8 (permalink)
NamePros Member
Join Date: Oct 2003
Posts: 126
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


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

Liquid Web Smart Servers  
All times are GMT -7. The time now is 05:39 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger