xt07t
06-08-2004, 11:48 AM
I have created an email form for sending an email on my forum. I want to be able to use the logged in user name in the email. For example, here is a simple email form
<form action="email.php" method="post" name="emailform" target="_self">
Enter your email here:<br>
<input name="from" type="text" size="20" maxlength="20">
<hr>
Enter your message here:<br>
<textarea name="message" cols="30" rows="10"></textarea>
<input type="submit" value="submit">
</form>
The email.php file would be
<?php
$to = "test@test.com";
$from = $_POST['from'];
$subject = "This is a test email";
$message = $_POST['message'];
$headers = "From: $from\r\n";
$success = mail($to, $subject, $message, $headers);
if ($success)
echo "The email to $to from $from was successfully sent";
else
echo "An error occurred when sending the email to $to from $from";
?>
What I would like to be able to do here is put in the username that submited it. What would I need to put in the email.php file to do this? Thanks!!
xtort :confused:
<form action="email.php" method="post" name="emailform" target="_self">
Enter your email here:<br>
<input name="from" type="text" size="20" maxlength="20">
<hr>
Enter your message here:<br>
<textarea name="message" cols="30" rows="10"></textarea>
<input type="submit" value="submit">
</form>
The email.php file would be
<?php
$to = "test@test.com";
$from = $_POST['from'];
$subject = "This is a test email";
$message = $_POST['message'];
$headers = "From: $from\r\n";
$success = mail($to, $subject, $message, $headers);
if ($success)
echo "The email to $to from $from was successfully sent";
else
echo "An error occurred when sending the email to $to from $from";
?>
What I would like to be able to do here is put in the username that submited it. What would I need to put in the email.php file to do this? Thanks!!
xtort :confused: