PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old September 21st, 2009, 04:16 PM
xenocide8d xenocide8d is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Sep 2009
Posts: 3 xenocide8d User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 4 sec
Reputation Power: 0
Pull Current Address From Browser

I am using a comment module on my knowledge base website. Basically, it appears at the bottom of each page. Comments are emailed to the administrator.

The trouble is that it only emails the content of what was entered in the comment box. But I need it to also let me know what page it was sent from.

What can I add to my code to make that happen? The contents of the php module are below:


defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

$task = trim( mosGetParam( $_REQUEST, 'task', null ) );

if ($task == 'submit') {
$query = "select email from jos_users where name = 'Administrator'";
$res = mysql_query($query);
$resArray = mysql_fetch_array($res);
$recipient = $resArray[0];
$subject = "Suggestion from SugBox";
$message = $_POST['mytextarea1'];

if($message != "") {
mail($recipient, $subject, $message);
}

}

?>

<script type="text/javascript" language="javascript">
var http_request = false;
function makePOSTRequest(url, parameters) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
// set type accordingly to anticipated content type
//http_request.overrideMimeType('text/xml');
http_request.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}

http_request.onreadystatechange = alertContents;
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);
}

function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
//alert(http_request.responseText);
result = http_request.responseText;
} else {
alert('There was a problem with the request.');
}
}
}

function get(obj) {
var poststr = "mytextarea1=" + encodeURI( document.getElementById("mytextarea1").value );
makePOSTRequest('?task=submit', poststr);
document.getElementById('mytextarea1').value = '';
alert('Your suggestion has been submitted. Thank you!');
return true;
}
</script>


<form action="javascript:get(document.getElementById('myform')); " name="myform" id="myform" method="POST">
<textarea id="mytextarea1" cols="18" rows="5">
</textarea>
<br>
<input type="button" name="button" value="Submit"
onclick="javascript:get(this.parentNode);">
</form>


Thanks you in advance for any help.

Jon

Reply With Quote
  #2  
Old September 21st, 2009, 04:19 PM
xenocide8d xenocide8d is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Sep 2009
Posts: 3 xenocide8d User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 4 sec
Reputation Power: 0
Sorry, I am using php5

Reply With Quote
  #3  
Old September 22nd, 2009, 11:15 AM
AndyJGreen AndyJGreen is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Sep 2009
Location: UK
Posts: 3 AndyJGreen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 40 m 3 sec
Reputation Power: 0
Facebook MySpace
Hi,

Try editing the line where it actually sends the email, like so:

PHP Code:
if($message != "") {
mail($recipient$subject$message."\n\nReferer:".$_SERVER['HTTP_REFERER']);



That should tack on the referer at the end of the message.

HTH

Reply With Quote
  #4  
Old September 23rd, 2009, 09:19 AM
xenocide8d xenocide8d is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Sep 2009
Posts: 3 xenocide8d User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 4 sec
Reputation Power: 0
Thank you very much. That took care of it for me. Exactly what I was looking for, though now it seems success is making me greedy. So now I'm curious if there is a way to cause that to show as a hyperlink in the email, rather than plain text?

And next time I'll make sure to post my code properly next time...

Reply With Quote
  #5  
Old September 23rd, 2009, 09:58 AM
MatthewJ MatthewJ is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: May 2007
Location: Davenport, Iowa
Posts: 633 MatthewJ User rank is Private First Class (20 - 50 Reputation Level)MatthewJ User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 22 h 11 m 29 sec
Reputation Power: 3
You would need to send the email as html and not as plain text like you currently are...

Example #4 should show you the difference http://us2.php.net/manual/en/function.mail.php

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Pull Current Address From Browser


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 12 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek