473,399 Members | 4,177 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,399 software developers and data experts.

PHP EMail Form and set cookie

Hi,

Being new to PHP & cookies, I am looking to write an email form, where
a user can choose their name from a drop down list, fill in the
content of the email and hit send and the email will be from that
user.

Then the next time they visit the page, I want to be able to read that
cookie and preset the From part of the email from the cookie.

But I have no clue where to start and can't find any examples of the
web.

If anyone can help out or point me at a script that has this I'd be
very grateful.

Many thanks
Pete

Aug 23 '07 #1
3 2332
pe**********@gmail.com wrote:
Hi,

Being new to PHP & cookies, I am looking to write an email form, where
a user can choose their name from a drop down list, fill in the
content of the email and hit send and the email will be from that
user.

Then the next time they visit the page, I want to be able to read that
cookie and preset the From part of the email from the cookie.

But I have no clue where to start and can't find any examples of the
web.

If anyone can help out or point me at a script that has this I'd be
very grateful.

Many thanks
Pete
It's pretty easy - you can start at:

http://us.php.net/manual/en/features.cookies.php

Just keep in mind you can't control cookie behavior on the browser end.
For instance, my browser is set up to destroy all cookies when I close
it (except for sites I specify).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 23 '07 #2
Do you have any example code or give me some pointers.

Pretty new to this and not so sure where to start...

Thanks

On Aug 23, 4:21 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
pete.broo...@gmail.com wrote:
Hi,
Being new to PHP & cookies, I am looking to write an email form, where
a user can choose their name from a drop down list, fill in the
content of the email and hit send and the email will be from that
user.
Then the next time they visit the page, I want to be able to read that
cookie and preset the From part of the email from the cookie.
But I have no clue where to start and can't find any examples of the
web.
If anyone can help out or point me at a script that has this I'd be
very grateful.
Many thanks
Pete

It's pretty easy - you can start at:

http://us.php.net/manual/en/features.cookies.php

Just keep in mind you can't control cookie behavior on the browser end.
For instance, my browser is set up to destroy all cookies when I close
it (except for sites I specify).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================


Aug 31 '07 #3
On Fri, 31 Aug 2007 10:50:33 +0200, <pe**********@gmail.comwrote:
On Aug 23, 4:21 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>pete.broo...@gmail.com wrote:
Being new to PHP & cookies, I am looking to write an email form, where
a user can choose their name from a drop down list, fill in the
content of the email and hit send and the email will be from that
user.
Then the next time they visit the page, I want to be able to read that
cookie and preset the From part of the email from the cookie.
But I have no clue where to start and can't find any examples of the
web.
If anyone can help out or point me at a script that has this I'd be
very grateful.
Many thanks
Pete

It's pretty easy - you can start at:

http://us.php.net/manual/en/features.cookies.php

Just keep in mind you can't control cookie behavior on the browser end.
For instance, my browser is set up to destroy all cookies when I close
it (except for sites I specify).
(topposting fixed)
Do you have any example code or give me some pointers.

Pretty new to this and not so sure where to start...
In the 'form page':

$from = isset($_COOKIE['from']) ? htmlspecialchars($_COOKIE['from']): '';
echo '<input name="from" value="'.$from.'">';

In the page that sends the email:

if(isset($_POST['from']) && !isset($_COOKIE['from']))
setcookie('from',$_POST['from'],time() + (60 * 60 * 24 * 60), '/');

Keep in mind that the setcookie() function can only be used before ANY
OTHER output. No starting HTML tags, no whitespace, nothing can be sent
before this function.
--
Rik Wasmus

My new ISP's newsserver sucks. Anyone recommend a good one? Paying for
quality is certainly an option.
Aug 31 '07 #4

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

Similar topics

3
by: Daniel Ruscoe | last post by:
Hi chaps, I'm relatively new to the language, but I want to create a simple order form using PHP and cookies. Please let me know if there's a better way in this situation, database isn't...
4
by: Shannon Jacobs | last post by:
I'm doing some trivial surveys, and I want to know if the same user answers twice. Can't really know that, but at least I thought I could check for the same browser/computer combination by using a...
1
by: mhawkins19 | last post by:
I have a form built and on the onclick event I validate all of the fields and then if the form is ok, on the submit event I run a javascript function to set a cookie and download a file from the...
3
by: Philip Rayne | last post by:
I am hosting a website on my home PC. I have a dynamic IP address so I use a domain name that automatically gets updated with my IP address by my router. This domain name is something like...
1
by: ken.prat | last post by:
Given the following: <script>document.cookie = "foo=cookie;";</script> <form action="form.aspx?foo=query" method="post"> <input name="foo" type="hidden" value="fom" /> <input type="submit" />...
9
by: Justin Engelman | last post by:
Hi, I have a website that uses an ISAPI filter that will redirect anyone going to any page on the site to an SSL login page (on a different website with the same root domain) if they do not have...
1
by: logik3x | last post by:
I'm developping a program to automate the submisson of grades to a website called omnivox.ca (http://brebeuf.omnivox.ca). My problem is that I can't get the login working. I get the cookie right...
5
by: Navillus | last post by:
Hey gang, I have a login form that is empty by default, but can be filled with values from a previous form: <input type=text maxlength="40" size="40" name="user" value="`usr`"> <input...
3
by: bonus | last post by:
Im new at Javascripting and jumped in the ocean and Im a little lost, I am trying to get a form to do 2 things: 1) write a cookie (actually several cookies) 2) submit the information to a php...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.