hello
Many sites that you visit such as techtv.com allow you to send a page or the article
that you are reading to yourself or a friend that might be interested. how do you do that?
i have designed a simple php program that allows someone to send an email. i want to
add upon that and allow users to send the actual url of the page they are currently on as
well. i find viewing the source of websites that offer this feature do not usually tell all the code
you need to make it happen.
first off, how can you put the url in the code without actually typing it in. is there some sort
of code that will dynamically put it in for you.
secondly i started to put a hidden input tag in to send the url to the email thinking that might
be where i put it. is this a good start?
thanks for any help you can give me
<?php
$pageTitle="Sending emails, php book p229";
require("header.php");
if($beenSubmitted){
if($mailTo){
if(mail($mailTo,$subject,$body,"From: $mailFrom")){
print("<B><CENTER><FONT COLOR=BLUE>Your email has been successfully sent!</FONT></CENTER></B>\n");
}else{
print("<B><CENTER><FONT COLOR=RED>Your email was not successfully sent due to a system error!</FONT></CENTER></B>\n");
}
}else{
print("<B><CENTER><FONT COLOR=RED>Please enter the recipient's mail to address!</FONT></CENTER></B>\n");
}
}
?>
<FORM ACTION="email.php" METHOD=POST>
Recipient's Email Address: <INPUT TYPE=TEXT NAME="mailTo" SIZE=50><BR>
Your email Address: <INPUT TYPE=TEXT NAME="mailFrom" SIZE=50><BR>
Email Subject: <INPUT TYPE=TEXT NAME="subject" SIZE=80><BR>
Email Body: <TEXTAREA NAME="body" ROWS=10 COLS=50></TEXTAREA><P>
<INPUT TYPE=HIDDEN NAME=beenSubmitted VALUE=TRUE>
<INPUT TYPE=HIDDEN NAME=url value="?????????????">
<INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="Submit!">
</FORM>
<?
require("footer.php");
?>You don't need to include it as a hidden form variable. You can obtain the URI for the page you are on from the $_SERVER['REQUEST_URI']. Just add your domain name to the front of this. E.g.
define('DOMAIN', 'http://www.yourdomain.com');
// then assign the page info in whichever way you would normally
// Example:
$this_page = sprintf ('<a href=http://www.htmlforums.com/archive/index.php/"[%s]">Page Name</a>', DOMAIN.$_SERVER['REQUEST_URI']);
// or
$this_page = '<a href=http://www.htmlforums.com/archive/index.php/"' . DOMAIN.$_SERVER['REQUEST_URI'] . '">PAGE NAME</a>';Hey thanks so much for the code... it works. :cheers:
I have one problem. I cannot figure out how to put the url in the body which uses <textarea>. I can put it in the subject which uses <text>. Here is the code. Any help is greatly appreciated :rocker:
<?php
define('DOMAIN', 'http://www.ange-spring.com');
// then assign the page info in whichever way you would normally
//$url= DOMAIN.$_SERVER['$_REQUEST[URI]'].'/php_book_trials/email.php';
//$url= '<a href=http://www.htmlforums.com/archive/index.php/>'. DOMAIN.$_SERVER['REQUEST_URI'] .'</a>';
$url= DOMAIN.$_SERVER['REQUEST_URI'];
print("$url");
$pageTitle="Sending emails, php book p229";
require("header.php");
if($beenSubmitted){
if($mailTo){
if(mail($mailTo,$subject,$body,"From: $mailFrom")){
print("<B><CENTER><FONT COLOR=BLUE>Your email has been successfully sent!</FONT></CENTER></B>\n");
}else{
print("<B><CENTER><FONT COLOR=RED>Your email was not successfully sent due to a system error!</FONT></CENTER></B>\n");
}
}else{
print("<B><CENTER><FONT COLOR=RED>Please enter the recipient's mail to address!</FONT></CENTER></B>\n");
}
}
?>
<FORM ACTION="email.php" METHOD=POST>
Recipient's Email Address: <INPUT TYPE=TEXT NAME="mailTo" SIZE=50><BR>
Your email Address: <INPUT TYPE=TEXT NAME="mailFrom" SIZE=50><BR>
Email Subject: <INPUT TYPE=TEXT NAME="subject" SIZE=80 VALUE="<?php print("$url"); ?>"><BR>
Email Body: <TEXTAREA NAME="body" ROWS=10 COLS=50 VALUE="<?php print("$url"); ?> "></TEXTAREA><P>
<INPUT TYPE=HIDDEN NAME=beenSubmitted VALUE=TRUE>
<INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="Submit!">
</FORM>
<?
require("footer.php");
?>Well, not entirely sure why you're doing it the way you are but to answer your question; there's no value attribute for <textarea>. Place the text you want in between the tags:
<textarea>Text goes here</textarea>Thanks :rocker:
That did the trick.
Many sites that you visit such as techtv.com allow you to send a page or the article
that you are reading to yourself or a friend that might be interested. how do you do that?
i have designed a simple php program that allows someone to send an email. i want to
add upon that and allow users to send the actual url of the page they are currently on as
well. i find viewing the source of websites that offer this feature do not usually tell all the code
you need to make it happen.
first off, how can you put the url in the code without actually typing it in. is there some sort
of code that will dynamically put it in for you.
secondly i started to put a hidden input tag in to send the url to the email thinking that might
be where i put it. is this a good start?
thanks for any help you can give me
<?php
$pageTitle="Sending emails, php book p229";
require("header.php");
if($beenSubmitted){
if($mailTo){
if(mail($mailTo,$subject,$body,"From: $mailFrom")){
print("<B><CENTER><FONT COLOR=BLUE>Your email has been successfully sent!</FONT></CENTER></B>\n");
}else{
print("<B><CENTER><FONT COLOR=RED>Your email was not successfully sent due to a system error!</FONT></CENTER></B>\n");
}
}else{
print("<B><CENTER><FONT COLOR=RED>Please enter the recipient's mail to address!</FONT></CENTER></B>\n");
}
}
?>
<FORM ACTION="email.php" METHOD=POST>
Recipient's Email Address: <INPUT TYPE=TEXT NAME="mailTo" SIZE=50><BR>
Your email Address: <INPUT TYPE=TEXT NAME="mailFrom" SIZE=50><BR>
Email Subject: <INPUT TYPE=TEXT NAME="subject" SIZE=80><BR>
Email Body: <TEXTAREA NAME="body" ROWS=10 COLS=50></TEXTAREA><P>
<INPUT TYPE=HIDDEN NAME=beenSubmitted VALUE=TRUE>
<INPUT TYPE=HIDDEN NAME=url value="?????????????">
<INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="Submit!">
</FORM>
<?
require("footer.php");
?>You don't need to include it as a hidden form variable. You can obtain the URI for the page you are on from the $_SERVER['REQUEST_URI']. Just add your domain name to the front of this. E.g.
define('DOMAIN', 'http://www.yourdomain.com');
// then assign the page info in whichever way you would normally
// Example:
$this_page = sprintf ('<a href=http://www.htmlforums.com/archive/index.php/"[%s]">Page Name</a>', DOMAIN.$_SERVER['REQUEST_URI']);
// or
$this_page = '<a href=http://www.htmlforums.com/archive/index.php/"' . DOMAIN.$_SERVER['REQUEST_URI'] . '">PAGE NAME</a>';Hey thanks so much for the code... it works. :cheers:
I have one problem. I cannot figure out how to put the url in the body which uses <textarea>. I can put it in the subject which uses <text>. Here is the code. Any help is greatly appreciated :rocker:
<?php
define('DOMAIN', 'http://www.ange-spring.com');
// then assign the page info in whichever way you would normally
//$url= DOMAIN.$_SERVER['$_REQUEST[URI]'].'/php_book_trials/email.php';
//$url= '<a href=http://www.htmlforums.com/archive/index.php/>'. DOMAIN.$_SERVER['REQUEST_URI'] .'</a>';
$url= DOMAIN.$_SERVER['REQUEST_URI'];
print("$url");
$pageTitle="Sending emails, php book p229";
require("header.php");
if($beenSubmitted){
if($mailTo){
if(mail($mailTo,$subject,$body,"From: $mailFrom")){
print("<B><CENTER><FONT COLOR=BLUE>Your email has been successfully sent!</FONT></CENTER></B>\n");
}else{
print("<B><CENTER><FONT COLOR=RED>Your email was not successfully sent due to a system error!</FONT></CENTER></B>\n");
}
}else{
print("<B><CENTER><FONT COLOR=RED>Please enter the recipient's mail to address!</FONT></CENTER></B>\n");
}
}
?>
<FORM ACTION="email.php" METHOD=POST>
Recipient's Email Address: <INPUT TYPE=TEXT NAME="mailTo" SIZE=50><BR>
Your email Address: <INPUT TYPE=TEXT NAME="mailFrom" SIZE=50><BR>
Email Subject: <INPUT TYPE=TEXT NAME="subject" SIZE=80 VALUE="<?php print("$url"); ?>"><BR>
Email Body: <TEXTAREA NAME="body" ROWS=10 COLS=50 VALUE="<?php print("$url"); ?> "></TEXTAREA><P>
<INPUT TYPE=HIDDEN NAME=beenSubmitted VALUE=TRUE>
<INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="Submit!">
</FORM>
<?
require("footer.php");
?>Well, not entirely sure why you're doing it the way you are but to answer your question; there's no value attribute for <textarea>. Place the text you want in between the tags:
<textarea>Text goes here</textarea>Thanks :rocker:
That did the trick.