Take a look at the syntax used in the examples
I dont understand, please fix the script
Which part do you not understand?
Hint: You donāt want the round brackets.
In one post, you said this:
yet now, youāve said this:
Can you see the difference? Which one of those two have you used? If youāve used the first, it should be fine. If youāve used the second pair, it wonāt work. Look at the difference between these lines, and the lines in the first quote in this post, or indeed your (working) use of session variables in your earlier posts. Theyāre not the same. I know itās only a minor difference, but details like this are the difference between right and wrong.
You have a misunderstanding of how forums work. I am presuming English is not your first language and your repeated demands for someone to do your work for you is just down to poor translation.
which round brackets?
Look at my post above, you must be able to see the difference between the two quotes from your code?
i used
$name=$_SESSION[āsessnameā];
$message=$_SESSION[āsessmessageā];
not working PHPMailer says
Notice: Undefined index: sessmessage in /home
i have fixed it properly with this
$name=$_SESSION[āsessnameā];
$message=$_SESSION[āsessmessageā];
PHPMailer is now working fine and able to send message to my email address, but dont send the data that it needs to send. i.e the name and the message
what am i not doing right?
Post the current code, exactly as it is now.
have a look at the actual contents of these variables with var_dump
<?php session_start(); ?>
<?php
$name=$_SESSION['sessname'];
$message=$_SESSION['sessmessage'];
require 'PHPMailer-master/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "mail.mydomainname.com"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "info@mydomainname.com"; // SMTP username
$mail->Password = "12345678"; // SMTP password
$mail->From = "info@mydomainname.com";
$mail->FromName = "mydomainname.com";
$mail->AddAddress("info2@mydomainname.com", "info2");
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->Subject = "message enquiry";
$mail->Body = "Name: $name\nMessage: $message;
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
header( "Location: https://mydomainname.com" );
?>
Iām amazed that this bit of code:
$mail->Body = "Name: $name\nMessage: $message;
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
results in a message being sent. Do you see anything missing from the end of the first line in that section, or is it a copy/paste error when you copy the code to the forum?
i have used that code to send messages several times, it is working fine, the problem is how to collect data to be sent
Where are you setting your session variables?
This is the message that was sent to my email address with the PHPMailer script
Name:
Message:
Message sent from computer IP: 0.0.0.0
The IP was successfully sent , but the name and message was not sent.
In PHPMailer
<?php session_start(); ?>
<?php
$name=$_SESSION['sessname'];
$message=$_SESSION['sessmessage'];
require 'PHPMailer-master/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "mail.mydomainname.com"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "info@mydomainname.com"; // SMTP username
$mail->Password = "12345678"; // SMTP password
$mail->From = "info@mydomainname.com";
$mail->FromName = "mydomainname.com";
$mail->AddAddress("info2@mydomainname.com", "info2");
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->Subject = "message enquiry";
$mail->Body = "Name: $name\nMessage: $message;
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
header( "Location: https://mydomainname.com" );
?>
That looks like the code you have already posted. I donāt see how or where it answers my question.
i want to set it in my PHPMailer script so i can be able to send the data to my email address.
the error is coming from here
$name=$_SESSION[āsessnameā];
$message=$_SESSION[āsessmessageā];
That is extracting the values from the $_SESSION array. In order to extract values, you first have to put something in there.