Jump to content

php mail


Ninjakreborn

Recommended Posts

This is really php related.
I was creating a program/script to email someone everytime a page was accessed, but a little more than that.  He has a list of links, and I was thinking of a way to email him the page that was accessed everytime someone goes to it, and Icouldn't think of anything with php that would allow me to do this, naturally.
I thought up something with javascript, to use an event handler, onclick, to initialize a javascript variable before page exit, that will capture
mail("emailaddress", "Asic Ip Access Page", "Someone has accessed whatever page in Asic Ip Download Page");
That will be saved in the javascript variable, then I can pull the javascript variable to php, and it would read mail(whatever) like it was in the variable, is this possible, if so how do I pull javascript variables.
Link to comment
Share on other sites

If i understand you correctly, you wish to, using PHP, email someone every time a link is clicked.

if so, make a PHP file 'whatever.php'
[code]
<?php

if (!$_GET['redirect']) exit('bad link');

$page = $_GET['redirect'];

/*
Email the person here, and do whatever other logging you want. $page contains the page the user is going to
*/

header('Location: ' . $page);
?>
[/code]

Then, link any links you wish to track to 'whatever.php?redirect=URL_TO_ACTUAL_PAGE'
Link to comment
Share on other sites

you can also do it in php use $_GET.

from the page the user goto's the page you want to email information from this is the link you put on that page ok.

//This is a link that the user using to enter the page to send the email ok.

echo"<a href='whatever.php?&email_users=users'>go to this page ok</a>";


Then on the email page you have this ok

if($_GET["email_users"]=="users") {

email code ok that sends the information to the user ok.

}else{

echo " Sorry this page emails information to the admin please make sure your email is valid ok!";
}



ps. if the user is going to use the page that the email is on then dont use a redirect header else use one ok.


Link to comment
Share on other sites

Ok, either way looks good, I tried this here, and I ran into 1 detail.
I got it working, I even learned now fully how to pass variables via url's but how do you pass already populated variables through url's
When I pulled in the email through post I did this
$emailaddress = $_POST['emailaddress']
then in the link i did this
<a href=""downloadhandler.php?redirect=dw/Adair100b.pdf&email=$emailaddress"
and when it went through I have the page set up to
[code]<?php

if (!$_GET['redirect']) exit('bad link');

$page = $_GET['redirect'];

mail("businessman332211@hotmail.com", "Asic Ip Download Access", "Someone has access {$page} from {$emailaddress}");

header('Location: ' . $page);
?>[/code]
The first part works it sends an email saying someone has accessed pagename, and it tells the name of the page, then on the email address area it's just blank, I know that they can be passed, but it must be a different method, how do I string an already populated variable into the url.
Link to comment
Share on other sites

If you are getting variables out of the url you use $_GET['var_name'], just like you do with $_POST['var_name']. SO to get the emailaddress from the url, use this: $_GET['email'] as email is the variable that holds the email address in the url.
Link to comment
Share on other sites

It's not picking up my email, I have the email address coming from post, it's being submitted through a form to the page with the links
Then I need to pass it from the page with the links over to that other page, to format into the email
register_globals is off and I have no choice on that because my client is using yahoo, so I still initialize my variables
I can do $emailaddress = $_POST['emailaddress']
But I tried it both ways, I did this, and passed it through post, and left it alone and past it with just get and neither of them worked, they both show up as blank.
Link to comment
Share on other sites

I don't think I understand how this works.
I know how to pass standard urls but for some reason it's not reading my variable, I have it coming from orm.
The form is post, into this page, then this page sends it out to like this.
I have a form that records the email address, it sends it off to the other page, via post.  If the email address exists, there you go, if not then it doesn't show hte page.  Then when they click on a link, it sends it to that page, and redirects them to the page, while sending the email, it'sn ot picking up my email address from that variable, I tried get, post, and a combination of the 2, but it's not working properly.
Link to comment
Share on other sites

I hate register_globals on, but my client is using yahoo, this wasn't my project, I picked up where another developer left off, and yahoo restricts ini access, I cused them out 2-3 times already for it.  I do however always call them with $_POST[''] and $_GET[''] anyway, but I like register globals off whenever I have a choice.
Here is the gateway code leading to the links page.
[code]<form name="gatewayform" action="download.php" method="post">
<label for="emailaddress">Email Address:</label>
<input name="emailaddress" id="emailaddress" type="text" maxlength="80" />
<input name="submit" id="submit" type="submit" value="Gain Access!" />
</form>[/code]
This sends the email address variable to the page with the links, here

[code]<?php
if ($_POST['emailaddress'] != "") {
?>
<?php
mail("businessman332211@hotmail.com", "Asic Ip Download Page Access", "Someone has accessed the download page on asic ip with the email address {$_POST[emailaddress]}");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
<title>ASIC IP</title>
</head>
<body bgcolor="#9aa8c7" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<script type="text/javascript">
<!--
if (parseInt(navigator.appVersion.substring(0,1))>=3) { // 3.0 or greater.

ch1_on  = new Image();  ch1_off  = new Image();
ch2_on  = new Image();  ch2_off  = new Image();
ch3_on  = new Image();  ch3_off  = new Image();
ch4_on  = new Image();  ch4_off  = new Image();
ch5_on  = new Image();  ch5_off  = new Image();
ch6_on  = new Image();  ch6_off  = new Image();
ch7_on  = new Image();  ch7_off  = new Image();
ch8_on  = new Image();  ch8_off  = new Image();

ch1_on.src  = 'images/b_homeap.gif';
ch1_off.src  = 'images/b_home.gif';
ch2_on.src  = 'images/b_aboutap.gif';
ch2_off.src  = 'images/b_about.gif';
ch3_on.src  = 'images/b_infoap.gif';
ch3_off.src  = 'images/b_info.gif';
ch4_on.src  = 'images/b_downloadap.gif';
ch4_off.src  = 'images/b_download.gif';
ch5_on.src  = 'images/b_careerap.gif';
ch5_off.src  = 'images/b_career.gif';
ch6_on.src  = 'images/b_teamap.gif';
ch6_off.src  = 'images/b_team.gif';
ch7_on.src  = 'images/b_pressap.gif';
ch7_off.src  = 'images/b_press.gif';
ch8_on.src  = 'images/b_contactap.gif';
ch8_off.src  = 'images/b_contact.gif';

}

function activate(image) {
  if (parseInt(navigator.appVersion.substring(0,1))>=3) { // 3.0 or greater.
      imagesrc = eval(image + '_on.src');
      document[image].src = imagesrc;
  }
}

function deactivate(image) {
  if (parseInt(navigator.appVersion.substring(0,1))>=3) { // 3.0 or greater.
      imagesrc = eval(image + "_off.src");
      document[image].src = imagesrc;
  }
}
-->
</script>
<center>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="right" valign="top">&nbsp;</td>
<td align="center"><table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000" width="700">
<tr>
<td bgcolor="#9aa8c7"><? include("incs/top_menu.inc.php");  ?>
<table border="0" cellpadding="0" cellspacing="0" width="700" bgcolor="#FFFFFF">
<tr>
<td><table border="0" cellpadding="0" cellspacing="0" width="700">
<tr>
<td width="6">&nbsp;</td>
<td width="164" valign="top" bgcolor="#f1f1f1"><table  border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="6"></td>
<td height="24"><font class="titlu2">Downloads : :</font> </td>
</tr>
</table>
<img src="images/p.gif" width="164" height="1" border="0" /><br />
<table  border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="10" height="20"></td>
<td><a href="downloadgateway.php" class="n">Downloads</a> </td>
</tr>
</table>
<img src="images/p.gif" width="164" height="1" border="0" /><br />
<br />
</td>
<td width="10">&nbsp;</td>
<td width="510" valign="top"><img src="images/linie.gif" /><br />
<br />
&nbsp;&nbsp;<font class="titlu">Downloads</font> <br />
<br />
<img src="images/linie.gif" /><br />
<br />
<table  border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"><img src="images/rosu.gif" border="0" /> &nbsp; <a href="dw/100mABoost.pdf" class="n" target="_blank">ASIC IP 100mA Boost</a> <br />
<br />
<img src="images/rosu.gif" border="0" /> &nbsp; <a href="downloadhandler.php?redirect=dw/Adair100b.pdf&$_GET[emailaddress]" class="n" target="_blank">ASIC IP Adair 100b</a> <br />
<br />
<img src="images/rosu.gif" border="0" /> &nbsp; <a href="dw/Adair80211andnetworktester.pdf" class="n" target="_blank">ASIC IP Adair 802.11 and network tester (UBT)</a> <br />
<br />
<img src="images/rosu.gif" border="0" /> &nbsp; <a href="dw/Adair900and2.4G.pdf" class="n" target="_blank">ASIC IP Adair 900 and 2.4G</a> <br />
<br />
<img src="images/rosu.gif" border="0" /> &nbsp; <a href="dw/AntennaModules.pdf" class="n" target="_blank">ASIC IP Antenna Modules</a> <br />
<br />
<img src="images/rosu.gif" border="0" /> &nbsp; <a href="dw/BandgapRef.pdf" class="n" target="_blank">ASIC IP Bandgap Ref</a> <br />
<br />
<img src="images/rosu.gif" border="0" /> &nbsp; <a href="dw/BoosPS0100.pdf" class="n" target="_blank">ASIC IP Boost PS0100</a> <br />
<br />
<img src="images/rosu.gif" border="0" /> &nbsp; <a href="dw/Controllerboard.pdf" class="n" target="_blank">ASIC IP Controller board</a> <br />
<br />
<img src="images/rosu.gif" border="0" /> &nbsp; <a href="dw/LDO150mA.pdf" class="n" target="_blank">ASIC IP LDO 150mA</a> <br />
<br />
<img src="images/rosu.gif" border="0" /> &nbsp; <a href="dw/LDO300mA.pdf" class="n" target="_blank">ASIC IP LDO 300mA</a> <br />
<br />
<img src="images/rosu.gif" border="0" /> &nbsp; <a href="dw/LDO50mA.pdf" class="n" target="_blank">ASIC IP LDO 50mA</a> <br />
<br />
<img src="images/rosu.gif" border="0" /> &nbsp; <a href="dw/R2400RadioModule.pdf" class="n" target="_blank">ASIC IP R2400 Radio Module</a> <br />
<br />
<img src="images/rosu.gif" border="0" /> &nbsp; <a href="dw/RFModules.pdf" class="n" target="_blank">ASIC IP RF Modules</a> <br />
<br />
<img src="images/rosu.gif" border="0" /> &nbsp; <a href="dw/LDO300mA.pdf" class="n" target="_blank">IP Intranet Supplier Station</a> <br />
<br />
<img src="images/rosu.gif" border="0" /> &nbsp; <a href="dw/LDO50mA.pdf" class="n" target="_blank">IP Provider Station</a> <br />
<br />
<img src="images/rosu.gif" border="0" /> &nbsp; <a href="dw/IPReuseStation.pdf" class="n" target="_blank">IP Reuse Station</a> <br />
<br />
<img src="images/rosu.gif" border="0" /> &nbsp; <a href="dw/IPSoCCollaborativePlatform.pdf" class="n" target="_blank">IP SoC Collaborative Platform</a> <br />
<br /></td>
</tr>
</table>
<br />
<br />
<img src="images/linie.gif" /><br />
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="images/sigla_jos.gif" /><br /></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Trademarks/Copyright ©2006 ASIC IP. All Rights Reserved.</td>
</tr>
</table>
<img src="images/linie.gif" /><br />
<br />
</td>
<td width="10">&nbsp;</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
<td align="left" valign="top">&nbsp;</td>
<td></td></td>
</tr>
</table>
</center>
<!-- Start of StatCounter Code -->
<script type="text/javascript" language="javascript">
var sc_project=1721944;
var sc_invisible=1;
var sc_partition=16;
var sc_security="1e4db6ff";
</script>

<script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript><a href="http://www.statcounter.com/" target="_blank"><img  src="http://c17.statcounter.com/counter.php?sc_project=1721944&amp;java=0&amp;security=1e4db6ff&amp;invisible=1" alt="web statistics" border="0"></a> </noscript>
<!-- End of StatCounter Code -->
</body>
</html>
<?php
}else {
echo "The proper parameters are not in place for you to view this page<br />";
echo "You have to have registered your email address with the gateway page<br />";
echo "As well this script must be activated from the gateway page, and<br />";
echo "Not an external source<br />";
echo "Please go to www.asicip.com and click on the downloads page<br />";
echo "and add your Email address properly to gain access to this page.<br />";
echo "Either that or the domain name of your email address was a<br />";
echo "non-existent one<br />";
}
?>[/code]
That wil email my client upon page access, then in each url I am settnig up that redirect page someone showed me on here, but I can't get it to pass the form variable, with the email
I tried multiple ways, the other page that takes care of this is
[code]<?php

if (!$_GET['redirect']) exit('bad link');

$page = $_GET['redirect'];

mail("businessman332211@hotmail.com", "Asic Ip Download Access", "Someone has access {$page} from {$_GET[emailaddress]}");

header('Location: ' . $page);
?>[/code]
it works with the name of the site, but it's not passing my email at all.
Link to comment
Share on other sites

If you have register globals on then you can not use $_GET, or $_POST vars. You'll have to this:
$redirect instead of $_GET['redirect'];
$emailaddress instead of $_GET['emailaddress']

etc. Also does yahoo allow you to use .htaccess files? If they do you can probably add this:
[code]php_flag register_globals Off[/code]
Which will turn of register_globals temporarly for your script.
Link to comment
Share on other sites

With register globals on, you can still access them with $_GET
and $_POST, it's just not working on this situation for some reason, I always initialize my variables, everytime I work on a server that has register globals off, for instance, what he showed about the other thing, it works, even though it's get, $_GET is a safe way to do it, with or without register globals, $_GET can be used by both but straight accessing the variable can't so I use $_GET always to make sure it's compatible in both
Link to comment
Share on other sites

[quote]With register globals on, you can still access them with $_GET and $_POST[/quote]
And where did you get that from? As far as I know you cannot use $_GET or $_POST if register_globals is on, off yes but not on.

But if you add the following to a htaccess file:
php_flag register_globals Off

you will. Which I expect your friend has done.
Link to comment
Share on other sites

Here.

For a test run, go onto some sort of test server
change register_globals on
Then create a form
[code]<form name="testform" action="page.php" method="post">
<input name="username" id="username" type="text" maxlength="80" />
<input name="password" id="password" type="text" maxlength="80" />
<input name="emailaddress" id="emailaddress" type="text" maxlength="80" />
<input name="submit" id="submit" type="submit" value="Submit" />
</form>[/code]
In the form type in
[quote]
test123
thisisapassword
youremailhere
[/quote]

In your script do this
[code]<?php
echo "$_POST['username']";
echo "$_POST['password']";
echo "$_POST['submit']";
?>[/code]
You will get the output
[quote]test123
thisisapassword
youremailhere[/quote]
After that rewrite your form to do method="get" then redo your code to
[code]<?php
echo "$_GET['username']";
echo "$_GET['password']";
echo "$_GET['submit']";
?>[/code]
You will get the output in the browser
[quote]test123
thisisapassword
youremailhere[/quote]
The reason I found this out, I was really into security when I first got started, but I realized some servers don't let me, so I came up with this, for when people do that
If you do your registration
$emailaddress = $_GET['emailaddress']
and so forth it sets them so someone can't use them against you, I do this everytime when I have to work with register globals on which I try to do whenever I can, also I tried that htaccess and it didn't work.  It won't let me upload it those filetypes are restricted/ with yahoo.
Link to comment
Share on other sites

I am not saying your wrong, I am also not saying I am right.  All I am saying is so far, when I ahve worked on a server using register_globals on
I have been able to still access my variables in the same way I access them when it is off, if it's not suppose to be that way, then maybe it has something to do with my server settings but I have done this on multiple servers, I have even done it on this website asic ip before, numerous times.  I can access them directly but I liked hte $_POST['']
and $_GET['']
maybe you can show video to prove me wrong, I am not saying you can't but it won't change the fact that when I have so far worked on different servers with it off, it still allows me to access them that way, if that is abnormal then only nobody knows why it allows me too.
Link to comment
Share on other sites

http://ca.php.net/manual/en/security.globals.php

According to the PHP manual, the existance of super globals is independant of register globals.
$_GET should exist in every configuration. (except for versions prior to when it was added)
Link to comment
Share on other sites

[quote author=joehaley link=topic=100867.msg398722#msg398722 date=1153150340]
http://ca.php.net/manual/en/security.globals.php

According to the PHP manual, the existance of super globals is independant of register globals.
$_GET should exist in every configuration. (except for versions prior to when it was added)
[/quote]
When was that change made? I swear when register_globals was turned on you wouldn't be able to use any superglobal arrays, until it was turned off. This has complety thrown me.
Link to comment
Share on other sites

wildteen88 from php version 4.2.0 but you couldnt use the $_GET[] and $_POST below version 4.2.0


Perhaps the most controversial change in PHP is when the default value for the PHP directive register_globals went from ON to OFF in PHP 4.2.0. Reliance on this directive was quite common and many people didn't even know it existed and assumed it's just how PHP works. This page will explain how one can write insecure code with this directive but keep in mind that the directive itself isn't insecure but rather it's the misuse of it.

When on, register_globals will inject your scripts with all sorts of variables, like request variables from HTML forms. This coupled with the fact that PHP doesn't require variable initialization means writing insecure code is that much easier. It was a difficult decision, but the PHP community decided to disable this directive by default. When on, people use variables yet really don't know for sure where they come from and can only assume. Internal variables that are defined in the script itself get mixed up with request data sent by users and disabling register_globals changes this. Let's demonstrate with an example misuse of register_globals:
Link to comment
Share on other sites

Redarrow I know what register_globals is, its just that I got confused when I tested businessmans script earlier that it worked when register_globals was on, even though I was using superglobal arrays. I always presumed that you couldnt use super_globals (_POST, GET, _COOKIE, _SESSION etc) when register_globals was turned on.
Link to comment
Share on other sites

Ok, I sitll don't understand why this isn't working, I saw some sample script and I tried this
"downloadhandler.php?redirect=dw/LDO150mA.pdf"

In here I had
"downloadhandler.php?redirect=dw/LDO150mA.pdf&emailaddress=$_POST[emailaddress]"
but nothing is working, it's still leaving my email blank, I was going to scrap this feature, but he said he needed it, he would call me in 30 minutes, I just need to figure this out, does anyone have advice on this.  I always try to use register globals off, but sometimes I am forced to because of yahoo, I try to deter my clients from using yahoo, they suck.
Link to comment
Share on other sites

downloadhandler.php?redirect=dw/LDO150mA.pdf&emailaddress=$_POST[emailaddress]"

to

downloadhandler.php?redirect=dw/LDO150mA.pdf&emailaddress=$_POST['emailaddress']"

[' '] single quotes missing


sorry wildteen88 i got really confused ok.
Link to comment
Share on other sites

[quote]Someone has access dw/LDO150mA.pdf using $_POST[\'email\'][/quote]
That is the output I am getting
inside the email
[code]<?php

if (!$_GET['redirect']) exit('bad link');

$page = $_GET['redirect'];
mail("businessman332211@hotmail.com", "Asic Ip Download Access", "Someone has access {$page} using {$email}");

header('Location: ' . $page);
?>[/code]
That is exactly what I am using to process it, after I changed my line like you siad, but that output is all I get in teh email, this is the part that is confusing me.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.