Forum Moderators: coopster

Message Too Old, No Replies

Processing a PHP Survey

There must be a better way than receiving through email and counting by hand

         

Jeremy_H

4:42 am on Feb 28, 2006 (gmt 0)

10+ Year Member



Hello,

I've developed a PHP based survey for my website that has been spread out over five pages.

As the person presses next, the portion of the survey they have just filled out is emailed to a special email address. When the person presses next on the 2nd page, part two of the survey then gets emailed. This has been setup this way so in-case someone doesnt finish all their survey, then at least some of their information has still been gathered.

The end result is a mailbox that has five emails per person that must be matched up by IP address, and then printed, and all the totals counted by hand.

What I think would be ideal would be the content that has been gathered from the survey is then sent to a script that can process this information, that can then output both the totals or the full information of any specific sample.

Is this possible? And how would I being something like this?

Thanks

Anyango

6:17 am on Feb 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would change action of those forms to a script which would

1) Create a session for each visitor
2) Save all form informations in Database for that session

and then would create simple reporting page, by telling code to group form results on Session_ID you stored, you can get any repots you want, easily.

counts,questions filled,yes,no,this n that, everything.

jamie

6:27 am on Feb 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi jeremy,

you can process emails using php by setting up an alias in your mail config:

#emailuser: "¦/path/to/email_process.php"

this pipes all the mails to the php processing script. you then have to parse the mails, separate the headers and bodies and get the info you need. search for 'php parse email"

hth

zulu_dude

11:01 am on Feb 28, 2006 (gmt 0)

10+ Year Member Top Contributors Of The Month



Not sure what your setup is, but couldn't you simply store the info in a database, along with the session id? That way, the user's results are stored at the end of every page, without emailing them to you until the user has finished the survey.

Then, you can write another script to sort through the results, pull out the stats/results you need and email them to you. Or set it up so that the results are emailed to you when the user finishes the survery.

You could also set up a cronjob to fetch the results every day/hour if you don't want them emailed right away.

Jeremy_H

5:01 pm on Feb 28, 2006 (gmt 0)

10+ Year Member



Thank you everyone for your feedback.

It looks like writing to a database is a move in the right direction. I've never done anything like this before, so hopefully I'll explore a wonderful new world that could open up new possibilities for me in the future!

One question about session ids. I was taking a look at PHP's site, and they said that session ids are either passed through a cookie (which might make users wary) or through the url (which is not search engine friendly). Could I not just use some variable unique to them (something like an IP address) and just use that?

Thanks

jatar_k

5:11 pm on Feb 28, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the problem is that ips aren't unique to a single user and identifying them uniquely with out usind the session id is very difficult and not overly reliable.

I always go the cookie route

Jeremy_H

5:26 pm on Feb 28, 2006 (gmt 0)

10+ Year Member



Thanks jatar_k, I'll definitely have to look more into cookies.

So, I'm building my MySQL database (or trying to) when I read in the help files that I can only have a maximum of 50 simultaneous connections. Now, right now I'm not getting that, but I'm wondering if this might be an Achilles heel to scalability. Does this number seem high/low/just right?

jatar_k

6:52 pm on Feb 28, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> 50 simultaneous connections

it's a little higher than I often see, I think shared hosts hover around 20-30

50 at the exact same second is a lot

>> cookies

for clarity, I meant session cookies, wasn't sure if that was clear

s9901470

4:31 pm on Mar 3, 2006 (gmt 0)

10+ Year Member



Hi Jeremy

I did a similar questionnaire over 8 pages, and I used a hidden variable 'username' on each page which was passed onto the next. I used username to identify each respondent.
Ask them to enter a username on the first page, then include this on each subsequent page as a hidden variable
<input type="hidden" name="username" value=<?=$username?>>

In the PHP of each subsequent page, you can call the username variable like this:

$username = $_REQUEST['username'];

I would also recommend storing the data in a database (e.g. MySQL) rather than using e-mail.