Author |
Message |
jazzfuser
Worker


Joined: Mar 30, 2006
Posts: 111
|
Posted:
Fri Jun 29, 2007 1:14 am |
|
I have a form which emails information to me submitted by my users to register for events. Included with their information I also collect their IP address using $REMOTE_ADDR to help ensure the validity of the submission. I would like to automatically collect their username as I have with the IP. Is there a simple way to do that? If so, could someone direct me to the code I would include in my mail function, or is there a universal reference like $REMOTE_ADDR for usernames? I've tried $username, $uname, and some others I've seen in other areas of nuke with no luck.
Here is a condensed version;
<?
$EmailTo = " support@mysite.com, $email";
$Subject = " [NEW REGISTRATION] $lname , $fname";
$Name = "$fname lname\n";
$App = "EVENT REGISTRATION\n----------------------------\n\nIP Address: $REMOTE_ADDR\nLast Name: $lname\nFirst Name: $fname";
mail($EmailTo,$Subject,$App,"From: $email\n");
?>
After the IP Address I would like to include the Username of the registered (logged in) user submitting the form.
I hope I've given you enough information. Thanks in advance for any help. |
|
|
|
 |
kguske
Site Admin

Joined: Jun 04, 2004
Posts: 6437
|
Posted:
Fri Jun 29, 2007 6:12 am |
|
Almost enough information...is the form a block? You may need to declare a global variable for the $user array. Note that it's an array, so you'll need to get the appropriate value from the array for the user name for your log or email. |
_________________ I search, therefore I exist...
Only registered users can see links on this board! Get registered or login! |
|
|
 |
evaders99
Former Moderator in Good Standing

Joined: Apr 30, 2004
Posts: 3221
|
Posted:
Fri Jun 29, 2007 8:27 am |
|
You should be able to use this code
Code:
if (is_user($user)) {
cookiedecode($user);
$username = $cookie[1];
}
|
|
_________________ - Only registered users can see links on this board! Get registered or login! -
Need help? Only registered users can see links on this board! Get registered or login! |
|
|
 |
jazzfuser

|
Posted:
Fri Jun 29, 2007 11:55 am |
|
Thank you both. I should declare I am not very savvy in regard to PHP. I certainly know enough to get into trouble, and enough to know to back up everything before I make changes .
Kguske, the form is a module which refers to a file that contains the above sample. I'm assuming that is where I would apply the array.
Evaders99, I added your code to the file and received a Fatal error message referring to the line where that was added. I'm certain I'm missing something. Here is what it looked like;
<?
if (is_user($user)) {
cookiedecode($user);
$username = $cookie[1];
}
$EmailTo = " support@mysite.com, $email";
$Subject = " [NEW REGISTRATION] $lname , $fname";
$Name = "$fname lname\n";
$App = "EVENT REGISTRATION\n----------------------------\nUser: $username\nIP Address: $REMOTE_ADDR\nLast Name: $lname\nFirst Name: $fname";
mail($EmailTo,$Subject,$App,"From: $email\n");
?>
If you could, and it is not much trouble, would you explain in more detail or show me what it should look like?
Thank you. |
|
|
|
 |
evaders99

|
Posted:
Fri Jun 29, 2007 12:13 pm |
|
What exactly is the error?
That code equires the use of phpNuke, which means you need to include phpNuke's mainfile.php |
|
|
|
 |
jazzfuser

|
Posted:
Fri Jun 29, 2007 12:26 pm |
|
Thank you, that was all I needed. For the sake of other newbies, here is the code that worked;
Code:<?
require_once("mainfile.php");
if (is_user($user)) {
cookiedecode($user);
$username = $cookie[1];
}
$EmailTo = " support@mysite.com, $email";
$Subject = " [NEW REGISTRATION] $lname , $fname";
$Name = "$fname lname\n";
$App = "EVENT REGISTRATION\n----------------------------\nUser: $username\nIP Address: $REMOTE_ADDR\nLast Name: $lname\nFirst Name: $fname";
mail($EmailTo,$Subject,$App,"From: $email\n");
?>
|
Thank you once again Evaders99! |
|
|
|
 |
|