|
-
Senior Member
PHP Survay
I am trying to make a flash movie which will consit of Radiobuttons,
textboxes(inputfields) and Check boxes. I would like to be able to have a email sent to me with all the details. If this cannot be done then have the survay results uploaded to mySQL. Does anyone know any tutorials on how this can be done.
Thanks in advance, William
-
Hi,
both sending to an email or to a mysql are pretty standard... May I suggest to use mysql - it is probably better at adding up values than your email program.
There is one thing to watch out for, however: textboxes just send their contents without extra help, while (at least the macromedia) checkboxes and radiobuttons require that you get their values and store them into some variables before sending
Musicman
-
Senior Member
Ok if i would use sql, what would i put in the php file, or to get the flash file to use the php file.
Originally posted by william_tropico
Does anyone know any tutorials on how this can be done.[/B]
I dont really know on how to go about this, so i really need a tutorial.
Thanks again, William
-
This information is subject to change without notice and
is provided "as is" with no warranty.
-
Hi,
suppose your survey sends just two radiobox choices c1, c2 with possible values a, b, c
You would need a database table with those fields
create table summary (
name varchar(3), -- would be c1 or c2 here
a int default 0,
b int default 0,
c int default 0
);
The php code would be
-- db.php --
<?
@mysql_connect("localhost", "somename", "somepass") or die("connect fail, error " . mysql_error());
@mysql_select_db("mydatabase") or die("cannot select database, error " . mysql_error());
?>
where all the names have to match your database
--- main script, e.g. addresult.php ---
<?
include "db.php";
$c1 = $_POST["c1"];
$c2 = $_POST["c2"];
if(!blank($c1))
mysql_query("UPDATE summary SET $c1 = $c1 + 1 where name = 'c1'");
if(!blank($c2))
mysql_query("UPDATE summary SET $c2 = $c2 + 1 where name = 'c2'");
print "status=ok";
?>
Now, suppose your survey includes the submitter's email AND you want to keep individual results, you would need another table
create table survey (
email varchar(50),
c1 varchar(2),
c2 varchar(2),
unique (email)
);
and could add this line to your php
@mysql_query("INSERT INTO survey values ('$email', '$c1', '$c2')") or die("status=fail");
Note: the "unique" part along with the die() would prevent duplicate submission [if you could check the validity of the email ]
Musicman
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|