<?php
session_start();
require_once "mailer.php";
$msg="";
if (!empty($_POST['name1']))
{
$to ="bla@hotmail.com";
$subject = "Form Enquiry" ;
$from="xyz website";
$firstname=$_POST['name1'];
$lastname=$_POST['name2'];
$jobtitle=$_POST['jobtitle'];
$company=$_POST['company'];
$country=$_POST['country'];
$phone=$_POST['cTelNumber'];
$email1=$_POST['cEmail'];
$fromname=$firstname;
$message ="<table width='450' border='1' bgcolor='#FFFFFF' bordercolor='#FFCC00' style='color:#000000; text-align:left'>";
$message .="</tr><tr>";
$message .= " <td colspan='2'><strong>Enquiry Details</strong></td>";
$message .="</tr><tr>";
$message .= " <td>FirstName:</td><td style='text-align:left; width:250px;'>$firstname</td>";
$message .="</tr><tr>";
$message .= "<td>LastName:</td><td style='text-align:left;width:250px;'>$lastname</td>";
$message .="</tr><tr>";
$message .= "<td>Job-Title:</td><td style='text-align:left;width:250px;'>$jobtitle</td>";
$message .="</tr><tr>";
$message .= "<td>Country:</td><td style='text-align:left;width:250px;'>$country</td>";
$message .="</tr><tr>";
$message.= "<td>Company:</td><td style='text-align:left;width:250px;'>$company</td>" ;
$message .="</tr><tr>";
$message.= "<td>Email:</td><td style='text-align:left;width:250px;'>$email1</td>" ;
$message .="</tr><tr>";
$message.= "<td>Phone:</td><td style='text-align:left;width:250px;'>$phone</td>" ;
$message .="</tr><tr>";
$message.= "</table>" ;
$from="Support@xyz.com";
$MyEmail= new Mailer($to, $fromName, $from, $message, $subject);
if ($MyEmail->send()){
$msg ="Your message has been sent!";
$_SESSION['res']="Your message has been sent!";
var_dump($_SESSION['res']);
}
else{
$msg = "Your message could not be submitted, try again later!";
}
header("Location:mapping4.php");
}
?>
<?php var_dump($_SESSION['res']); ?>
//here comes the code for HTML form and the Submit button
<?php $_SESSION['res']=""; ?>
Session variable is empty
Page 1 of 15 Replies - 3079 Views - Last Post: 24 June 2011 - 06:28 AM
#1
Session variable is empty
Posted 24 June 2011 - 01:12 AM
i have made an email form, there i set a $_SESSION['res'] variable, when the mail is sent. Then i dump this var. After i dump it, i assign it an empty string. In my page all this code lies in a single page. I am getting a string(0) i.e an empty string in var_dump, although the email is being sent. Kindly see what wrong
Replies To: Session variable is empty
#2
Re: Session variable is empty
Posted 24 June 2011 - 05:33 AM
Assuming that $MyEmail->send() returns true, I don't see anything wrong with it. I notice you have two var_dumps in there... are they both executing? If only one is, then the send() method may be returning either false or 0. You may want to put an echo in there to verify that part of the code is really executing.
Assuming it does, you may wish to try a simple session test separately to see if sessions are working for you at all:
If they're not, check your temp folder settings in php.ini... I know if they're invalid, it can cause sessions to just not work.
Assuming it does, you may wish to try a simple session test separately to see if sessions are working for you at all:
<?php session_start(); $_SESSION['test'] = 'yes'; var_dump($_SESSION['test']); ?>
If they're not, check your temp folder settings in php.ini... I know if they're invalid, it can cause sessions to just not work.
#3
Re: Session variable is empty
Posted 24 June 2011 - 05:33 AM
Line #66 is making your string null. The = operator is for assignments and the == and === operators are for comparisons.
Also your mail script is vulnerable to header injections.
Also your mail script is vulnerable to header injections.
#4
Re: Session variable is empty
Posted 24 June 2011 - 06:19 AM
codeprada, on 24 June 2011 - 05:33 AM, said:
Line #66 is making your string null. The = operator is for assignments and the == and === operators are for comparisons.
Also your mail script is vulnerable to header injections.
Also your mail script is vulnerable to header injections.
I have dumped the session var before assigning it "" in line#66 so it should contain a value
satis, on 24 June 2011 - 05:33 AM, said:
Assuming that $MyEmail->send() returns true, I don't see anything wrong with it. I notice you have two var_dumps in there... are they both executing? If only one is, then the send() method may be returning either false or 0. You may want to put an echo in there to verify that part of the code is really executing.
Assuming it does, you may wish to try a simple session test separately to see if sessions are working for you at all:
If they're not, check your temp folder settings in php.ini... I know if they're invalid, it can cause sessions to just not work.
Assuming it does, you may wish to try a simple session test separately to see if sessions are working for you at all:
<?php session_start(); $_SESSION['test'] = 'yes'; var_dump($_SESSION['test']); ?>
If they're not, check your temp folder settings in php.ini... I know if they're invalid, it can cause sessions to just not work.
The session test returns yes... that means session is working. i really can't figure out the problem. now
#5
Re: Session variable is empty
Posted 24 June 2011 - 06:28 AM
Why didn't you assign $_SESSION['res'] to contain the error message also. It should be set in both statements in case your if statement doesn't validate to true which is suppose to initialize $_SESSION['res'].
Your next step is verifying that $MyEmail->send() returns true.
Your next step is verifying that $MyEmail->send() returns true.
#6
Re: Session variable is empty
Posted 24 June 2011 - 06:28 AM
Are you sure the send() method for the email is returning true? Throw an echo in there, just to be sure.
If you get an echo, but the session is still returning empty... I don't know. Did you turn up PHP error warnings and whatnot? You can throw this in at the top of the script:
Maybe it'll give a clue.
if ($MyEmail->send()){
$msg ="Your message has been sent!";
$_SESSION['res']="Your message has been sent!";
echo 'Message sent ...session var is ' .$_SESSION['res'] .'<br>';
var_dump($_SESSION['res']);
}
If you get an echo, but the session is still returning empty... I don't know. Did you turn up PHP error warnings and whatnot? You can throw this in at the top of the script:
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
Maybe it'll give a clue.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|