Forum Moderators: coopster

Message Too Old, No Replies

Enter an email address and it sends a link of that current page .

         

kevdog

3:40 am on Oct 7, 2008 (gmt 0)

10+ Year Member



Sorta like 'send to a friend' where the friend is my email address and the that email is a constant. Just a one box form that calls a php page and sends both email address a link to that webpage is what I'm trying to make.

[edited by: kevdog at 4:06 am (utc) on Oct. 7, 2008]

eeek

3:50 am on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm lost as to why you're lost. Just get the value from the form and send to it with the mail() function.

kevdog

4:12 am on Oct 7, 2008 (gmt 0)

10+ Year Member



hey eeek, not sure how to do much in php.

How to I insert the url of that page into the message?

The site is all html and I have 1 form that when submitted, opens a php page that emails me every form element and its value to only my email.

[edited by: kevdog at 4:18 am (utc) on Oct. 7, 2008]

eeek

4:17 am on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can make the URL a hidden value in the form. But if you do that, make sure you verify the value so you don't let the server by exploited by spammers. If you use sessions, you could keep the value there. Just don't try to rely on the referrer info; it can easily be spoofed.

kevdog

4:29 am on Oct 7, 2008 (gmt 0)

10+ Year Member



this is all i have and know a little about:

page with form

<form action="form-confirm.php" method="post" name="Form Inquiry" id="Form Inquiry">

Email: <input name="Email" size="30" />
<input type="submit" value="Submit" name="Submit" />

</form>

php page:

<?
$receiver="my@email.com";

$subject="Form Inquiry";
$header="MIME-Version: 1.0\r\nContent-type: text/plain; charset=iso-8859-1\r\n";

//'add every form element and its value to the email
$body="";
foreach (array_keys($_POST) as $el)
{
if (strcmp("subject",strtolower($el))==0) $subject=$subject." -- ".$_POST[$el];

$value=$_POST[$el];
$display="";
if (is_array($value))
{
foreach ($value as $everydisplay)
{
$display.=$everydisplay." ";
}
}
else
{
$display=$value;
}
$body=$body. $el . ": " . $display . "\r\n";
}

//mail($receiver,$subject,$body);
if ($body!="") mail($receiver,$subject,$body,$header);

?>

kevdog

4:52 am on Oct 7, 2008 (gmt 0)

10+ Year Member



So here's what I got. Not sure how to pass the URL to $message.

emailthispage.php:

<?php

$to = "my@email.com, $email";
$subject = "The Link You Requested";
$message = "not sure how to get the url here;
$from = "$email";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";

?>

------

<form method='post' action='emailthispage.php'>
Email me this page:
<input name='email' type='text' />
<input value="Send Me Link" type='submit' />
</form>

sastro

5:42 am on Oct 7, 2008 (gmt 0)

10+ Year Member



Curent Page on PHP

$currenpage='http://'.$_SERVER[HTTP_HOST].'/'.$_SERVER["REQUEST_URI"];

Hope this help...

kevdog

5:49 am on Oct 7, 2008 (gmt 0)

10+ Year Member



Like so?

<?php
$currentpage='http://'.$_SERVER[HTTP_HOST].'/'.$_SERVER["REQUEST_URI"];
$to = "$email";
$subject = "Test mail";
$message = "URL: $currentpage";
$from = "$email";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";

?>

kevdog

6:03 am on Oct 7, 2008 (gmt 0)

10+ Year Member



"No recipient addresses found in header" is all I got so far.

This is an HTML page with a form action to the php page.

[edited by: kevdog at 6:16 am (utc) on Oct. 7, 2008]

eeek

6:16 am on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



"No recipient addresses found in header" is all I got so far.

I'm not surprised. This doesn't do much of anything:

$to = "$email";

kevdog

6:18 am on Oct 7, 2008 (gmt 0)

10+ Year Member



not sure how to use the input from the form i guess.

kevdog

6:20 am on Oct 7, 2008 (gmt 0)

10+ Year Member



AHH

$email = $_REQUEST['email'] ;

Ok, I get this:

URL: http://www.example.com//emailthispage.php

$currentpage='http://'.$_SERVER[HTTP_HOST].'/'.$_SERVER["REQUEST_URI"];

This is displaying the php page and not the html that the form was submitted on.

[edited by: dreamcatcher at 6:50 am (utc) on Oct. 7, 2008]
[edit reason] use example.com. Thanks. [/edit]

kevdog

6:37 am on Oct 7, 2008 (gmt 0)

10+ Year Member



Trying this:

<script>
function start() {
var ref = document.getElementById('referrer');
ref.value = document.referrer;
}
onload = start;
</script>

Form:

<input type="hidden" id="referrer" value="">

[edited by: kevdog at 6:49 am (utc) on Oct. 7, 2008]

kevdog

6:40 am on Oct 7, 2008 (gmt 0)

10+ Year Member



No luck there.

URL: <?php print $_SERVER[

dreamcatcher

6:59 am on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Always access your post vars using $_POST.

Example:
$_POST['email']

If you are passing the form to another page for processing, you need to access the referer, as the page that held the form will be the previous page. I`m assuming the form is actually on the page you want to send the link for and not in a pop up window?

Try:
$currentpage = $_SERVER['HTTP_REFERER'];

Or store the current page in a hidden field as you have done, but use PHP instead of javascript.

$thispage='http://'.$_SERVER[HTTP_HOST].'/'.$_SERVER["REQUEST_URI"];

<input type="hidden" name="page" value="<?php echo $thispage; ?>" />

$message = "URL: ".$_POST['page'];

dc

kevdog

7:21 am on Oct 7, 2008 (gmt 0)

10+ Year Member



$currentpage = $_SERVER['HTTP_REFERER'];

That worked!

kevdog

7:45 am on Oct 7, 2008 (gmt 0)

10+ Year Member



now on to dressing up the echos...