Menu
Ok…I have a resellers website that has a link to our website on it. I want to make it so when a user clicks on the link from our reseller site they come to our site and a session is started which holds the name of the reseller that they came to our site from. I then want to pull the reseller information from this session when they are filling out a form. at the end of the form I want to insert the reseller information into the form that is emailed to us, so we know which reseller site they were referred to us by.
I’m fairly new to php, but if I was pointed into the right direction I think I could handle it.
Thanks in advance.
[code=php]<?php
session_start();
#use $HTTP_SESSION_VARS with PHP 4.0.6 or less
$_SESSION['referrer'] = $_GET["referrer"];
?>[/code]
[code=php]function send_mail ( $Data )
{
/* Collect the email data here */
$To = "[email protected]";
$Subject = "***DAQbilling Evaluation Request***";
$Msg = stripcslashes ( "Contact Name: " . $Data["txt_name"] . "n" .
"Facility Name: " . $Data["txt_facname"] . "n" .
"Address #1: " . $Data["txt_address"] . "n" .
"Address #2: " . $Data["txt_address2"] . "n" .
"City: " . $Data["txt_city"] . "n" .
"State: " . $Data["txt_state"] . "n" .
"Zipcode: " . $Data["txt_zip"] . "n" .
"Phone Number: " . $Data["txt_phone"] . "n" .
"Hours of Operation: " . $Data["txt_hours"] . "n" .
"Best time to contact: " . $Data["txt_contact"] . "n" .
"Billing currently completed by (In-house staff or billing service)? " . $Data["txt_staff"] . "n" .
"Does any of your billing staff work from home? " . $Data["txt_home"] . "n" .
"FullTime Providers: " . $Data["txt_fulltime"] . "n" .
"PartTime Providers: " . $Data["txt_parttime"] . "n" .
"Number of locations: " . $Data["txt_locations"]. "n" .
"Average patients per day per provider? " . $Data["txt_average"] . "n" .
"Percentage of Medicare Patients in your practice? " . $Data["txt_percentage"]. "n" .
"Email Address: " . $Data["txt_mail"] . "n" .
"Questions or Comments: " . $Data["txt_comments"] . "n" );
"Referral Site: " . $Data["referrer"] . "n" );
$From = "From: " . stripcslashes ( $Data["txt_mail"] );
$Headers = trim ( $From . "n" );
/* Send the email using the SMTP mail() */
mail ( $To, $Subject, $Msg, $Headers );
}
%>[/code]
[/size][i]Originally posted by pyro [/i]
[B]When using sessions, you always need to use sessions_start() before you try to read/write to them. Also, the correct way to read the session would be $_SESSION["referrer"] (or, if you are using a version of PHP eariler than PHP 4.1.0, $HTTP_SESSION_VARS["referrer"]) [/B][/QUOTE]
[code=php]
<?php
session_start();
$_SESSION['referrer'] = $_GET["referrer"];
?>[/code]
[code=php]
session_start();
$_SESSION['referrer'] = $_GET["referrer"];
function send_mail ( $Data )
{
/* Collect the email data here */
$To = "[email protected]";
$Subject = "***DAQbilling Evaluation Request***";
$Msg = stripcslashes ( "Contact Name: " . $Data["txt_name"] . "n" .
"Facility Name: " . $Data["txt_facname"] . "n" .
"Address #1: " . $Data["txt_address"] . "n" .
"Address #2: " . $Data["txt_address2"] . "n" .
"City: " . $Data["txt_city"] . "n" .
"State: " . $Data["txt_state"] . "n" .
"Zipcode: " . $Data["txt_zip"] . "n" .
"Phone Number: " . $Data["txt_phone"] . "n" .
"Hours of Operation: " . $Data["txt_hours"] . "n" .
"Best time to contact: " . $Data["txt_contact"] . "n" .
"Billing currently completed by (In-house staff or billing service)? " . $Data["txt_staff"] . "n" .
"Does any of your billing staff work from home? " . $Data["txt_home"] . "n" .
"FullTime Providers: " . $Data["txt_fulltime"] . "n" .
"PartTime Providers: " . $Data["txt_parttime"] . "n" .
"Number of locations: " . $Data["txt_locations"]. "n" .
"Average patients per day per provider? " . $Data["txt_average"] . "n" .
"Percentage of Medicare Patients in your practice? " . $Data["txt_percentage"]. "n" .
"Email Address: " . $Data["txt_mail"] . "n" .
"Questions or Comments: " . $Data["txt_comments"] . "n" );
"Referral Code: " . $_SESSION["referrer"] . "n" );
$From = "From: " . stripcslashes ( $Data["txt_mail"] );
$Headers = trim ( $From . "n" );
/* Send the email using the SMTP mail() */
mail ( $To, $Subject, $Msg, $Headers );
}
%>
[/code]
[code=php]
<?php
session_start();
$_SESSION['referrer'] = $_GET["referrer"];
?>[/code]
[/b][code=php]$_SESSION['referrer'] = $_GET["referrer"];[/code]
[code=php]
function send_mail ( $Data )
{
/* Collect the email data here */
$To = "[email protected]";
$Subject = "***DAQbilling Evaluation Request***";
$Msg = stripcslashes ( "Contact Name: " . $Data["txt_name"] . "n" .
"Facility Name: " . $Data["txt_facname"] . "n" .
"Address #1: " . $Data["txt_address"] . "n" .
"Address #2: " . $Data["txt_address2"] . "n" .
"City: " . $Data["txt_city"] . "n" .
"State: " . $Data["txt_state"] . "n" .
"Zipcode: " . $Data["txt_zip"] . "n" .
"Phone Number: " . $Data["txt_phone"] . "n" .
"Hours of Operation: " . $Data["txt_hours"] . "n" .
"Best time to contact: " . $Data["txt_contact"] . "n" .
"Billing currently completed by (In-house staff or billing service)? " . $Data["txt_staff"] . "n" .
"Does any of your billing staff work from home? " . $Data["txt_home"] . "n" .
"FullTime Providers: " . $Data["txt_fulltime"] . "n" .
"PartTime Providers: " . $Data["txt_parttime"] . "n" .
"Number of locations: " . $Data["txt_locations"]. "n" .
"Average patients per day per provider? " . $Data["txt_average"] . "n" .
"Percentage of Medicare Patients in your practice? " . $Data["txt_percentage"]. "n" .
"Email Address: " . $Data["txt_mail"] . "n" .
"Questions or Comments: " . $Data["txt_comments"] . "n" .
"Referral Code: " . $_SESSION["referrer"] );
$From = "From: " . stripcslashes ( $Data["txt_mail"] );
$Headers = trim ( $From . "n" );
/* Send the email using the SMTP mail() */
mail ( $To, $Subject, $Msg, $Headers );
}
%>[/code]
[/size][code=php]function send_mail ( $Data )
{
session_start(); #start the session
/* Collect the email data here */
$To = "[email protected]";
$Subject = "***DAQbilling Evaluation Request***";
$Msg = stripcslashes ( "Contact Name: " . $Data["txt_name"] . "n" .
"Facility Name: " . $Data["txt_facname"] . "n" .
"Address #1: " . $Data["txt_address"] . "n" .
"Address #2: " . $Data["txt_address2"] . "n" .
"City: " . $Data["txt_city"] . "n" .
"State: " . $Data["txt_state"] . "n" .
"Zipcode: " . $Data["txt_zip"] . "n" .
"Phone Number: " . $Data["txt_phone"] . "n" .
"Hours of Operation: " . $Data["txt_hours"] . "n" .
"Best time to contact: " . $Data["txt_contact"] . "n" .
"Billing currently completed by (In-house staff or billing service)? " . $Data["txt_staff"] . "n" .
"Does any of your billing staff work from home? " . $Data["txt_home"] . "n" .
"FullTime Providers: " . $Data["txt_fulltime"] . "n" .
"PartTime Providers: " . $Data["txt_parttime"] . "n" .
"Number of locations: " . $Data["txt_locations"]. "n" .
"Average patients per day per provider? " . $Data["txt_average"] . "n" .
"Percentage of Medicare Patients in your practice? " . $Data["txt_percentage"]. "n" .
"Email Address: " . $Data["txt_mail"] . "n" .
"Questions or Comments: " . $Data["txt_comments"] . "n" .
"Referral Code: " . $_SESSION["referrer"] );
$From = "From: " . stripcslashes ( $Data["txt_mail"] );
$Headers = trim ( $From . "n" );
/* Send the email using the SMTP mail() */
mail ( $To, $Subject, $Msg, $Headers );
}[/code]
[code=php]function send_mail ( $Data )
{
session_start(); #start the session
/* Collect the email data here */
$To = "[email protected]";
$Subject = "***DAQbilling Evaluation Request***";
$Msg = stripcslashes ( "Contact Name: " . $Data["txt_name"] . "n" .
"Facility Name: " . $Data["txt_facname"] . "n" .
"Address #1: " . $Data["txt_address"] . "n" .
"Address #2: " . $Data["txt_address2"] . "n" .
"City: " . $Data["txt_city"] . "n" .
"State: " . $Data["txt_state"] . "n" .
"Zipcode: " . $Data["txt_zip"] . "n" .
"Phone Number: " . $Data["txt_phone"] . "n" .
"Hours of Operation: " . $Data["txt_hours"] . "n" .
"Best time to contact: " . $Data["txt_contact"] . "n" .
"Billing currently completed by (In-house staff or billing service)? " . $Data["txt_staff"] . "n" .
"Does any of your billing staff work from home? " . $Data["txt_home"] . "n" .
"FullTime Providers: " . $Data["txt_fulltime"] . "n" .
"PartTime Providers: " . $Data["txt_parttime"] . "n" .
"Number of locations: " . $Data["txt_locations"]. "n" .
"Average patients per day per provider? " . $Data["txt_average"] . "n" .
"Percentage of Medicare Patients in your practice? " . $Data["txt_percentage"]. "n" .
"Email Address: " . $Data["txt_mail"] . "n" .
"Questions or Comments: " . $Data["txt_comments"] . "n" .
"Referral Code: " . $_SESSION["referrer"] );
$From = "From: " . stripcslashes ( $Data["txt_mail"] );
$Headers = trim ( $From . "n" );
/* Send the email using the SMTP mail() */
mail ( $To, $Subject, $Msg, $Headers );
}[/code]
[i]Originally posted by pyro [/i]
[B]You need to insert session_start() before you can read the sessions variable.[/QUOTE]
[code=php]
<?php
session_start();
#use $HTTP_SESSION_VARS with PHP 4.0.6 or less
$_SESSION['referrer'] = $_GET["referrer"];
?>
<html>
<head>
<title>DAQbilling</title>
<a href="http://www.mydomian.com/sub/referform.php">form</a>
</body>
</html>[/code]
[code=php]
function send_mail ( $Data )
{
session_start(); #start the session
/* Collect the email data here */
$To = "[email protected]";
$Subject = "***DAQbilling Evaluation Request***";
$Msg = stripcslashes ( "Contact Name: " . $Data["txt_name"] . "n" .
"Facility Name: " . $Data["txt_facname"] . "n" .
"Address #1: " . $Data["txt_address"] . "n" .
"Address #2: " . $Data["txt_address2"] . "n" .
"City: " . $Data["txt_city"] . "n" .
"State: " . $Data["txt_state"] . "n" .
"Zipcode: " . $Data["txt_zip"] . "n" .
"Phone Number: " . $Data["txt_phone"] . "n" .
"Hours of Operation: " . $Data["txt_hours"] . "n" .
"Best time to contact: " . $Data["txt_contact"] . "n" .
"Billing currently completed by (In-house staff or billing service)? " . $Data["txt_staff"] . "n" .
"Does any of your billing staff work from home? " . $Data["txt_home"] . "n" .
"FullTime Providers: " . $Data["txt_fulltime"] . "n" .
"PartTime Providers: " . $Data["txt_parttime"] . "n" .
"Number of locations: " . $Data["txt_locations"]. "n" .
"Average patients per day per provider? " . $Data["txt_average"] . "n" .
"Percentage of Medicare Patients in your practice? " . $Data["txt_percentage"]. "n" .
"Email Address: " . $Data["txt_mail"] . "n" .
"Questions or Comments: " . $Data["txt_comments"] . "n" .
"Referral Code: " . $Data["referrer"] );
$From = "From: " . stripcslashes ( $Data["txt_mail"] );
$Headers = trim ( $From . "n" );
/* Send the email using the SMTP mail() */
mail ( $To, $Subject, $Msg, $Headers );
}
%>[/code]
[code=php]function send_mail ( $Data )
{
session_start(); #start the session
/* Collect the email data here */
$To = "[email protected]";
$Subject = "***DAQbilling Evaluation Request***";
$Msg = stripcslashes ( "Contact Name: " . $Data["txt_name"] . "n" .
"Facility Name: " . $Data["txt_facname"] . "n" .
"Address #1: " . $Data["txt_address"] . "n" .
"Address #2: " . $Data["txt_address2"] . "n" .
"City: " . $Data["txt_city"] . "n" .
"State: " . $Data["txt_state"] . "n" .
"Zipcode: " . $Data["txt_zip"] . "n" .
"Phone Number: " . $Data["txt_phone"] . "n" .
"Hours of Operation: " . $Data["txt_hours"] . "n" .
"Best time to contact: " . $Data["txt_contact"] . "n" .
"Billing currently completed by (In-house staff or billing service)? " . $Data["txt_staff"] . "n" .
"Does any of your billing staff work from home? " . $Data["txt_home"] . "n" .
"FullTime Providers: " . $Data["txt_fulltime"] . "n" .
"PartTime Providers: " . $Data["txt_parttime"] . "n" .
"Number of locations: " . $Data["txt_locations"]. "n" .
"Average patients per day per provider? " . $Data["txt_average"] . "n" .
"Percentage of Medicare Patients in your practice? " . $Data["txt_percentage"]. "n" .
"Email Address: " . $Data["txt_mail"] . "n" .
"Questions or Comments: " . $Data["txt_comments"] . "n" .
"Referral Code: " . $_SESSION["referrer"] );
$From = "From: " . stripcslashes ( $Data["txt_mail"] );
$Headers = trim ( $From . "n" );
/* Send the email using the SMTP mail() */
mail ( $To, $Subject, $Msg, $Headers );
}
%>[/code]
[i]Originally posted by pyro [/i]
[B]You referenced the session wrong in form.php. Try this one:
[code=php]function send_mail ( $Data )
[/B][/QUOTE]
{
session_start(); #start the session
/* Collect the email data here */
$To = "[email protected]";
$Subject = "***DAQbilling Evaluation Request***";
$Msg = stripcslashes ( "Contact Name: " . $Data["txt_name"] . "n" .
"Facility Name: " . $Data["txt_facname"] . "n" .
"Address #1: " . $Data["txt_address"] . "n" .
"Address #2: " . $Data["txt_address2"] . "n" .
"City: " . $Data["txt_city"] . "n" .
"State: " . $Data["txt_state"] . "n" .
"Zipcode: " . $Data["txt_zip"] . "n" .
"Phone Number: " . $Data["txt_phone"] . "n" .
"Hours of Operation: " . $Data["txt_hours"] . "n" .
"Best time to contact: " . $Data["txt_contact"] . "n" .
"Billing currently completed by (In-house staff or billing service)? " . $Data["txt_staff"] . "n" .
"Does any of your billing staff work from home? " . $Data["txt_home"] . "n" .
"FullTime Providers: " . $Data["txt_fulltime"] . "n" .
"PartTime Providers: " . $Data["txt_parttime"] . "n" .
"Number of locations: " . $Data["txt_locations"]. "n" .
"Average patients per day per provider? " . $Data["txt_average"] . "n" .
"Percentage of Medicare Patients in your practice? " . $Data["txt_percentage"]. "n" .
"Email Address: " . $Data["txt_mail"] . "n" .
"Questions or Comments: " . $Data["txt_comments"] . "n" .
"Referral Code: " . $_SESSION["referrer"] );
$From = "From: " . stripcslashes ( $Data["txt_mail"] );
$Headers = trim ( $From . "n" );
/* Send the email using the SMTP mail() */
mail ( $To, $Subject, $Msg, $Headers );
}
%>[/code]
[code=php]<?PHP
session_start();
echo $_SESSION["referrer"];
?>[/code]
See if that will return the value. If not, we know it isn't setting the session.[i]Originally posted by pyro [/i]
[B]Try a simple test page:
[code=php]<?PHP
See if that will return the value. If not, we know it isn't setting the session. [/B][/QUOTE]
session_start();
echo $_SESSION["referrer"];
?>[/code]
[code=php]function send_mail ( $Data )
{
session_start(); #start the session
$referrer = $_SESSION["referrer"];
/* Collect the email data here */
$To = "[email protected]";
$Subject = "***DAQbilling Evaluation Request***";
$Msg = stripcslashes ( "Contact Name: " . $Data["txt_name"] . "n" .
"Facility Name: " . $Data["txt_facname"] . "n" .
"Address #1: " . $Data["txt_address"] . "n" .
"Address #2: " . $Data["txt_address2"] . "n" .
"City: " . $Data["txt_city"] . "n" .
"State: " . $Data["txt_state"] . "n" .
"Zipcode: " . $Data["txt_zip"] . "n" .
"Phone Number: " . $Data["txt_phone"] . "n" .
"Hours of Operation: " . $Data["txt_hours"] . "n" .
"Best time to contact: " . $Data["txt_contact"] . "n" .
"Billing currently completed by (In-house staff or billing service)? " . $Data["txt_staff"] . "n" .
"Does any of your billing staff work from home? " . $Data["txt_home"] . "n" .
"FullTime Providers: " . $Data["txt_fulltime"] . "n" .
"PartTime Providers: " . $Data["txt_parttime"] . "n" .
"Number of locations: " . $Data["txt_locations"]. "n" .
"Average patients per day per provider? " . $Data["txt_average"] . "n" .
"Percentage of Medicare Patients in your practice? " . $Data["txt_percentage"]. "n" .
"Email Address: " . $Data["txt_mail"] . "n" .
"Questions or Comments: " . $Data["txt_comments"] . "n" .
"Referral Code: " . $referrer );
$From = "From: " . stripcslashes ( $Data["txt_mail"] );
$Headers = trim ( $From . "n" );
/* Send the email using the SMTP mail() */
mail ( $To, $Subject, $Msg, $Headers );
}[/code]
Also, you aren't printing any HTML to the screen before the session_start() is called, correct?0.1.9 — BETA 5.4