/    Sign up×
Community /Pin to ProfileBookmark

save wepage url

Hi,

I created a form that sends a link to the email address entered in a form field.

it pulls the wep page address from the page where the form is inbeded.

I want to change it so that I can have a link on my page which will display a popup with a form do the above, my problem is capturing the web page url .

any throughts

current code

[code]

<body>
<?
$url = “http://www.tomorrownextweek.com”.$_SERVER[‘REQUEST_URI’];
?>

<h5 style=”text-align: center;”>Send Page Link to a Friend</h5>
<div id =”referralForm”>
<form name=”referral” id =”referral” method=”post” action=”http://www.tomorrownextweek.com/rf/sf.php”>
<fieldset>
<legend></legend>

<input type=”hidden” name=”url” value=”<?php echo $url;?>”>

<label for=”fromEmail”>
Your Email Address:
<input id=”fromEmail” name=”fromEmail” type=”text”>
</label>

<label for=”toEmail”>
There Email Address:
<input id=”toEmail” name=”toEmail” type=”text”>
</label>

<label>
<input type=”submit” value=”Send” onclick=”compute(this.form)”>
</label>
</fieldset>
</form>
</div>
</body>

</html>

[/code]

creating the email

[code=php]
<body>
<div id=”outer”>

<div id=”sub”>
<div id=”center”>
<?
// Let’s mail the user!
$toEmail = $_POST[‘toEmail’];
$fromEmail = $_POST[‘fromEmail’];

$url = $_POST[‘url’];
$subject = “Site Referred from $fromEmail”;
$message = “Have a look at this page!

A Friend thought that this website might be of interest
please click here: $url

Thank You for Visiting Tomorrow Next Week.

This is an automated response, please do not reply!”;

mail($toEmail, $subject, $message,
“From: TomorrowNextWeek.com<[email protected]>n
X-Mailer: PHP/” . phpversion());
echo ‘Thank you for Referring my Webpage <br />’;

echo “<a href=’$url’>$url</a>”;

?>
</div>
</div>
<div id=”footer”>
<p>Copyright &copy; TomorrowNextweek.com</p>
</div>
</div>

</body>
</html>

[/code]

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@kprocauthorJun 01.2006 — Is there a way that I can work this into my code

?

$url = "http://www.tomorrownextweek.com".$_SERVER['REQUEST_URI'];

?>

popup code

<a href="" OnClick= "window.open ('http://www.tomorrownextweek.com/rf/referralform.php', 'mywindow');">Email This Page</a>
Copy linkTweet thisAlerts:
@kprocauthorJun 02.2006 — the steps that need to happen are

1. the user clicks the link (this stores the webpages URL to a variable)

2. a form pops up for input, when submit is clicked the user is sent an email with a link to the webpage url in step 1.

After the submit button is clicked the a thank message displays with a link back to the page they refered

the problem that I'm having is the code above only works when the form is inbeded into the web page
Copy linkTweet thisAlerts:
@Li0rEJun 02.2006 — Actually, what you would have to do is this:

[CODE]<?php
$url = "http://www.tomorrownextweek.com".$_SERVER['REQUEST_URI'];
?>
function sharePage() {
window.open('yourpopupscript.php?url=<?php echo("$url"); ?>','popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=500,height=500,screenX=150,screenY=150,top=150,left=150')
}


Click <a href="javascript:sharePage()">here</a> to send to a friend![/CODE]


What that will do is send the url of the page you want to share to the popup window.
Copy linkTweet thisAlerts:
@kprocauthorJun 02.2006 — Thank you for the help, would I call the function on the page that generates the email
Copy linkTweet thisAlerts:
@Li0rEJun 02.2006 — the function is a javascript function, it's just used to popup the window and send the ID
Copy linkTweet thisAlerts:
@kprocauthorJun 03.2006 — thanks that worked
Copy linkTweet thisAlerts:
@Li0rEJun 03.2006 — well what you would have to do is give the user the option to send to more than one person and chose how many before the page is loaded (or use AJAX, but that makes it more complicated)

So the user wants to send to 4 different friends. What you do is somehow get the variable $amount_to_send set to whatever the preference.

Then you make a for loop
[code=php]<form method=post action=mailer.php>
<input type=hidden name=amount value=<?php echo $amount_to_send; ?>
<input type=hidden name=url value=<?php echo $url; ?>>
<?php

for($i=1; $i<$amount_to_send; $i++)
{
echo("Person #$i's Name: <input name=name[$i]><br />
Person #$i's eMail: <input name=email[$i]><br>----------------</br>");
}
?>
<input type=submit value=Send!></form>[/code]


So, what we have done so far is make a script that will automatically give and name the inputs for the amount of people to send to specified by $amount_to_send. Now we have to make a for loop in the mailer script to parse the information submitted in the form.

[code=php]<?php
$url = $_POST['url'];
$amount = $_POST['amount'];
for($i=1; $i<$amount; $i++)
{
mail( whatever you want to do with this. name will be $name[$i] and email will be $email[$i]);
echo("Message sent to $name[$i] successfully!");
}
?>[/code]
×

Success!

Help @kproc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...