GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-Jan-2006, 00:07
ohm_ ohm_ is offline
New Member
 
Join Date: Jan 2006
Posts: 7
ohm_ is on a distinguished road

Sessions Question


Hi, I'm working on a project for a mortgage site where I'm using a session to hold session variables as the client navigates from page to page. The problem is not capturing the clients info, the problem is...

1. Sending the info via e-mail to an administrator.
2. Adding the submitted info to a database. (Not yet there!)

Also, I'm using Smarty. FYI

This is how I have it all set up.

<Php Files>
index.php
step2.php
step3.php
step4.php
thankyou.php

<Template files>
The same as above, but include header.tpl and footer.tpl.

In index.php I have the following code for starting the session.

Code:
/* session_name('Mortgate-Quote"); session_start(); //All Registered Session variables go here!

NOW!

-My form handling script goes like this.-

PHP Code:

<?
//This is how I navigate from page to page. (Maybe the problem)

//If form 1, 2, 3, or 4 have a value process appropriate header.
if(isset($_POST['submit_1'])) {
header("Location: step2.php");
exit;
} elseif(isset($_POST['submit_2'])) {
header("Location: step3.php");
exit;
} elseif(isset($_POST['submit_3'])) {
header("Location: step4.php");
exit;
} elseif(isset($_POST['submit_4'])) {
header("Location: thankyou.php");
exit;
echo $_SESSION['email'];
} else {
echo "There has been a problem procession your request. 
Please report this problem to the site administrator at <a href='mailto:administrator@somewhere.com> Site Admin</a>";
}

//send email function
# Email to Function
function sendemail() {
$emailTo = '"Little o' me" <littleome@somewhere.com>';
$emailSubject = "Mortgage Quote";
$emailHeader = "From: $_SESSION['email']n"
 . "Reply-To: $_SESSION['email']n"
 . "MIME-Version: 1.0n"
 . "Content-type: text/plain; charset="ISO-8859-1\"\n"
 . "Content-transfer-encoding: quoted-printable\n";
 
$emailBody = "E-mail content will go here!";

mail($emailTo, $emailSubject, $emailBody, $emailHeader);
}

if(isset($_SESSION['submit_4'])) {
sendemail();
}


?>


Now every time I try to run this script with out sending the e-mail it works the way it should. It takes me from page to page registering all the session variables. But when I add the send e-mail function to process the information I get this:

Error:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /Users/littleome/Sites/mysite.com/form.php on line 2

Clould someone assist with this. I have no Idea why it gives me an error. Or advise if there is a better method to do the same thing.

Thanks!
Last edited by admin : 03-Jan-2006 at 06:34. Reason: Please insert your PHP code between [php] & [/php] tags
  #2  
Old 03-Jan-2006, 06:44
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 841
admin will become famous soon enough

Re: Sessions Question


First, the session codes -- the following line contains mismatched quotes:

Code:
session_name('Mortgate-Quote");

and should really be:

PHP Code:

session_name('Mortgate-Quote'); 



In the second example, you have your quotes messed up again (see comments starting with "Edited by Admin:"):

PHP Code:

<?
//This is how I navigate from page to page. (Maybe the problem)

//If form 1, 2, 3, or 4 have a value process appropriate header.
if(isset($_POST['submit_1'])) {
header("Location: step2.php");
exit;
} elseif(isset($_POST['submit_2'])) {
header("Location: step3.php");
exit;
} elseif(isset($_POST['submit_3'])) {
header("Location: step4.php");
exit;
} elseif(isset($_POST['submit_4'])) {
header("Location: thankyou.php");
exit;
echo $_SESSION['email'];
} else {
 // edited by Admin: inserted the missing ' in the <a> attribute
echo "There has been a problem procession your request. 
Please report this problem to the site administrator at <a href='mailto:administrator@somewhere.com'> Site Admin</a>";
}

//send email function
# Email to Function
function sendemail() {
// Edited by Admin: escape the '
$emailTo = '"Little o\' me" <littleome@somewhere.com>';
$emailSubject = "Mortgage Quote";
// Edited by Admin: used curly braces...
$emailHeader = "From: {$_SESSION['email']}\n"
 . "Reply-To: {$_SESSION['email']}\n"
 . "MIME-Version: 1.0\n"
 . "Content-type: text/plain; charset=\"ISO-8859-1\"\n"
 . "Content-transfer-encoding: quoted-printable\n";
 
$emailBody = "E-mail content will go here!";

mail($emailTo, $emailSubject, $emailBody, $emailHeader);
}

if(isset($_SESSION['submit_4'])) {
sendemail();
}


?>

__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
  #3  
Old 03-Jan-2006, 19:09
ohm_ ohm_ is offline
New Member
 
Join Date: Jan 2006
Posts: 7
ohm_ is on a distinguished road

Re: Sessions Question


Hi, Admin! Thanks for the reply. I updated the script to what you edited. I added
an mail(); function with variables to process when the submit_4 is pressed, but it still doesn't work. I may have missed an (') or two.

New edited script. Could you see whats wrong!

<?

//Headers
if(isset($_POST['submit_1'])) {
header("Location: step2.php");
exit;
} elseif(isset($_POST['submit_2'])) {
header("Location: step3.php");
exit;
} elseif(isset($_POST['submit_3'])) {
header("Location: step4.php");
exit;
} elseif(isset($_POST['submit_4'])) {
header("Location: thankyou.php");
exit;
} else {
echo "There has been a problem procession your request.
Please report this problem to the site administrator at <a href='mailto:administrator@somewhere.com'> Site Admin</a>";
}

//send email function
# Email to Function
function sendemail() {
// Edited by Admin: escape the '
$emailTo = '"Javier Lopez" <jalopez13@yahoo.com>';
$emailSubject = "Mortgage Quote";
// Edited by Admin: used curly braces...
$emailHeader = "From: {$_SESSION['email']}\n"
. "Reply-To: {$_SESSION['email']}\n"
. "MIME-Version: 1.0\n"
. "Content-type: text/plain; charset=\"ISO-8859-1\"\n"
. "Content-transfer-encoding: quoted-printable\n";

$emailBody =
":................................................ ..................................:"
."Mortgage Quote Request"
"\n"
."<h3>Contact Information</h3>"
. "\n"
. "First Name:............................................. ......................: $_POST['first_name']"
. "Last Name:............................................. ......................: $_POST['last_name']"
. "Address:......................................... .............................: $_POST['address']"
. "City:............................................ ...............................: $_POST['city']"
. "State:........................................... ..............................: $_POST['stateCode']"
. "Zip Code:............................................. ........................: $_POST['zipcode']"
. "Preferred Number:........................................... ...............: $_POST['day_npa'].$_POST['day_nxx'].$_POST['day_station'].$_POST['day_ext']"
. "Alternate Number:........................................... ...............: $_POST['eve_npa'].$_POST['eve_nxx'].$_POST['eve_station']"
. "Email:........................................... ..............................: $_POST['email']"
. " Best Time to Call:............................................. .............: $_POST['BestTime']"
. "\n"
. "<h3>Property Information</h3>"
. "\n"
. "Subject Property State:............................................ .......: $_POST['propertyStateCode']"
. "Subject Description:...................................... ..................: $_POST['propertyDesc']"
. "Credit Rating:........................................... ....................: $_POST['credit_rating']"
. "Loan Type:............................................. .....................: $_POST['typeOfLoan']"
. "Loan Purpose:.......................................... ....................: $_POST['refi_purpose']"
. "Property Purchased:........................................ ..............: $_POST['homepurchaseyear']"
. "Estimate Value:............................................ ................: $_POST['home_value_preset']"
. "Other Value:............................................ ...................: $_POST['home_value_other']"
. "Mortgage Balance:.......................................... ..............: $_POST['mortgage1_balance']"
. "Current Rate:............................................. ................: $_POST['m1IrDDa'].$_POST['m1IrDDb']"
. "Mortgage Type:............................................. ..............: $_POST['mortgageRateType']"
. "Second Mortgage:......................................... ...............: $_POST['second_mortgage']"
. "2nd Current Balance:.......................................... ...........: $_POST['mortgage2_balance']"
. "Current Rate:............................................. .................: $_POST['m2IrDDa'].$_POST['m2IrDDb']"
. "\n"
. "Income Incormation"
. "\n"
. "Annual Income:........................................... .................: $_POST['annualIncome']"
. "Occupation:...................................... ..........................: $_POST['occupational_status']"
. "Est. Monthly debt:............................................. ...........: $_POST['monthlyDebtPayments']"
. " Bankruptcy:....................................... ........................: $_POST['bankruptcy']"
. "\n"
;




mail($emailTo, $emailSubject, $emailBody, $emailHeader);
}

if(isset($_SESSION['submit_4'])) {
sendemail();
}


?>

Thanks for you help!
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
non-member function question crq C++ Forum 1 03-Feb-2005 22:59
Simple question on arrays--please help! brookeville C++ Forum 16 18-Nov-2004 00:23
Repetition structure problem and question brookeville C++ Forum 17 29-Oct-2004 18:48
question of practice magiccreative C++ Forum 1 06-Feb-2004 08:17
a C input question tmike C Programming Language 1 16-Sep-2003 03:31

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 17:28.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.