|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
Sorry, I am using php5
|
|
#3
|
|||
|
|||
|
Hi,
Try editing the line where it actually sends the email, like so: PHP Code:
That should tack on the referer at the end of the message. HTH |
|
#4
|
|||
|
|||
|
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... |
|
#5
|
|||
|
|||
|
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 |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Pull Current Address From Browser |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|