473,385 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

forms sessions email

here is the set up.
7 page form all get set to sessions
8th page sessions are called and results displayed for user to see
this is the php script for page 8
<?
ksort($_SESSION);
foreach ($_SESSION as $page=>$_POST)
{
echo "<div class=\"h3\">$page</div><br>";
foreach ($_POST as $field=>$value)
{
echo "$field: $value<br>";
}
}
?>

now i would like for the user to press a submit link/button and the
results sent to an email address. i know how to set up basic feedback
forms and have them emailed to me but not really sure where to go from
here once i ve called the sessions to recall them on another page.. any
help greatly appreciated.
thank you

Jul 17 '05 #1
7 2420
lig
Quinonez wrote:
here is the set up.
7 page form all get set to sessions
8th page sessions are called and results displayed for user to see
this is the php script for page 8
<?
ksort($_SESSION);
foreach ($_SESSION as $page=>$_POST)
{
echo "<div class=\"h3\">$page</div><br>";
foreach ($_POST as $field=>$value)
{
echo "$field: $value<br>";
}
}
?>

now i would like for the user to press a submit link/button and the
results sent to an email address. i know how to set up basic feedback
forms and have them emailed to me but not really sure where to go from here once i ve called the sessions to recall them on another page.. any help greatly appreciated.
thank you

While you are loading the HTML page for display you could also load it
into the message variable of the email. Don't forget emails can be in
the HTML format also. You could litereally send yourself the page the
user sees. Ahhh and session variables may be called and recalled as
many times as you want.

Basic logic:
if (submitted)
{
create the HTML page to be displayed and save it into the
variable $body.

Example: ksort($_SESSION);
foreach ($_SESSION as $page=>$_POST)
{
message .= "<div class=\"h3\">$page</div><br>";
foreach ($_POST as $field=>$value)
{
message .= "$field: $value<br>";
}
}
echo $message;
mail($to, $subject, $message, $headers);
}

Make sense?

Reference: mail:
http://www.php.net/manual/en/function.mail.php - Note example 4
Sessions:
http://us2.php.net/variables.predefined
http://us2.php.net/manual/en/reserve...iables.session
http://us2.php.net/manual/en/ref.session.php

Jul 17 '05 #2
Quinonez wrote:
now i would like for the user to press a submit link/button and the
results sent to an email address. i know how to set up basic feedback
forms and have them emailed to me but not really sure where to go from
here once i ve called the sessions to recall them on another page.. any
help greatly appreciated.


First: indent your scripts.
then ...

Build a string with the info from the $_SESSION and then mail it.

[copied from your code and reformatted]
<?php
ksort($_SESSION);

/* initializae $msg_body */
$msg_body = '';

foreach ($_SESSION as $page=>$_POST)
{
# echo "<div class=\"h3\">$page</div><br>";

/* add $page to message */
$msg_body .= "\n$page\n";

foreach ($_POST as $field=>$value)
{
# echo "$field: $value<br>";

/* add $field and $value to message */
$msg_body .= "$field: $value\n";

}
}

/* send it */
if (!mail($somebody, 'Form contents', $msg_body)) {
/* mail not sent! */
/* write error_log or something :-) */
}

?>

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #3
i tried this version and it sent the email but it sent 6 different
emails one for each page....and also send teh PHPSESSID

Jul 17 '05 #4
i got it to work now my only prob is the PHPSESSID...anyone know how to
get this to not show?

Jul 17 '05 #5
Quinonez wrote:
i got it to work now my only prob is the PHPSESSID...anyone know how to
get this to not show?


Why is the PHPSESSID in the $_SESSION array?

If you can't remove it from there, at the moment you're building the
message, check whether the current key is 'PHPSESSID' and do not add it
to the message.
--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #6
the problem is its generating automatically because of the code. so i
dont know how to take PHPSESSID out? or not include it

Jul 17 '05 #7
Quinonez wrote:
the problem is its generating automatically because of the code. so i
dont know how to take PHPSESSID out? or not include it

unset($saved_sessid); /* to make sure it doesn't exist */

if (isset($_SESSION['PHPSESSID'])) {
$saved_sessid = $_SESSION['PHPSESSID'];
unset($_SESSION['PHPSESSID']); /* remove it from the $_SESSION */
}

/* do your printing stuff here */

/* restore $_SESSION, it might be needed by php */
if (isset($saved_sessid)) {
$_SESSION['PHPSESSID'] = $saved_sessid;
unset($saved_sessid); /* save a few bytes of memory */
}

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: jing_li | last post by:
Hi, you all, I am a newbee for php and I need your help. One of my coworker and I are both developing a webpage for our project using php. We have a copy of the same files in different location...
2
by: yoelgold | last post by:
Hi I want to start writing a new site. It will include 3 forms that will collect information from the user. I know how to keep the info in sessions etc. my question is about the design of the...
3
by: Joshua Russell | last post by:
Hi, Both the methods below open up a windows form called MasterForm. However, one works better than the other. Method 1 opens the form correctly but I don't have any reference to the instance of...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
1
by: Rob | last post by:
I have an ASP.NET application that uses forms-based authentication. A user wishes to be able to run multiple sessions of this application simultaneously from the user's client machine. The...
3
by: Martin | last post by:
Dear fellow ASP.NET programmer, I stared using forms authentication and temporarily used a <credentials> tag in web.config. After I got it working I realized this wasn't really practical. I...
7
by: mircu | last post by:
Hi, I noticed weird behaviour with the site that is using forms authentication. I am logged to the site from the same machine from two browsers (opened separately, not ctrl-N) as different users...
6
by: Radium | last post by:
Is it possible to fill out a form on an foreign website. E.g. is it possible to fill out the google form from a php script and then initialize the search? Thx Axel
16
by: sebastiangarth | last post by:
I need to be able to make a variable persistent between page invocations without submitting a form or sending it as a name-value pair in the URL. Another requirement I have is that I can't store...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.