Re: web-based survey form design : PHP & MySQL

From: Date: Sun, 21 Jul 2002 21:36:45 +0000
Subject: Re: web-based survey form design : PHP & MySQL
Groups: php.general 
Request: Send a blank email to php-general+get-108760@lists.php.net to get a copy of this message
> I am newbie in PHP. I am just learning the PHP >through tutorials and this mailing list. I have very >first goal of doing one project "Design web-based >survey" using PHP and MySQL. I would appreciate if >anybody give me some links that help to develope such >skills. Search the code archives linked from http://php.net/links.php You will doubtless find a *LOT* of web-based Survey packages in varying stages of complexity and completion within them. Here, however, is yet another free one to get you started: <HTML><BODY> <?php require 'connect.inc'; # This file is in your home dir and has in it: # <?php $connection = mysql_connect('localhost', 'USERNAME', 'PASSWORD');?> # Change your include_path in .htaccess or php.ini PHP can find that file. $answer = substr($answer, 0, 1); $answer = strtolower($answer); if ($answer != 'y'){ echo "Wrong answer.<BR>\n"; } $query = "insert into answers (answer) value('$answer')"; $insert = mysql_query($query, $connection) or error_log(mysql_error()); if (!$insert){ "Unable to record your answer. Ask the site administrator to read his Apache error_log.<BR>\n"; } else{ echo "Thanks for filling out our Survey!<BR>\n"; } if (!isset($answer) || $answer != 'y'){ ?> <FORM ACTION=<?=$PHP_SELF?> METHOD=POST> Should I have searched the archives and code repositories before posting to PHP-General?<BR> <INPUT TYPE=RADIO NAME=answer VALUE=y CHECKED> Yes<BR> <INPUT TYPE=RADIO NAME=answer VALUE=n> No<BR> <INPUT TYPE=SUBMIT> </FORM> <?php } ?> </BODY></HTML> PS The logical error some readers will think they have spotted on lines 10 and 21 is not, in fact, a bug at all. :-) -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#108760) next »