Jump to content

basic user login for survey


bambiiRULZ

Recommended Posts

:-[

Sorry if this is too big a question! But I thought I'd add another post the the nearly 200,000 post on here.

 

THE PROBLEM: I can barely speak PHP :(

 

I'm using Joomla which is fantastic, but my problem is I wish to write a basic custom survey. I need to record the user name, and user answers (no CHAR types only answers from TINYINT 1 to 10 for graph purposes). I have the basic php set up to record this ( not very well but sufficient) What I'd like help/advise with is setting it up so the user can come back at a later date to finish off the survey, it may become quite a lengthy questionnaire.

 

This is my test table for MySQL,

CREATE TABLE Results

(

ID INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,

User_Name CHAR(20) UNSIGNED NOT NULL,

Q1  CHAR(2),

Q2  CHAR(2),

Q3  CHAR(2),

Q4  CHAR(2)

 

)TYPE = MyISAM;

 

and my PHP is as follows

<?php

 

$thisFname = ($_REQUEST['fname']);

$Q1 = ($_REQUEST['Result']);

$Q2 = ($_REQUEST['Result1']);

$Q3 = ($_REQUEST['Result2']);

$Q4 = ($_REQUEST['Result3']);

 

$sqlQuery = "INSERT INTO results ( User_Name , Q1 , Q2 , Q3 , Q4 )

VALUES ('$thisFname' , '$Q1' , '$Q2' , '$Q3' , '$Q4' )";

$result = MYSQL_QUERY($sqlQuery);

 

?>

 

Now also to let you know, there is a fantastic plugin for joomla that allows me to handle 'groups'. I was planning on managing the accessibility of the survey with this. So a primary school may register with the Joomla login "country school" 'password', in the back end of Joomla I can assign an access level of the survey to only appear when the "country school" logs in (after I create a new table for their survey) Then I expect the teacher/employer to login and allow the children/employees to input a name and take part in the survey. But if it's incomplete I wish for the teacher and student to come back at a later date to complete it. As far as I can work out a SQL command of

 

SELECT * FROM results WHERE User_Name = 'lex'

 

will pull the data, and a command of

 

UPDATE `results` SET `Q4` = '3' WHERE `results`.`ID` =2 LIMIT 1 ;

 

will update. I can't work out the PHP required and I can't find anywhere to hack a little PHP together to take care of this.

 

Help would give me warm fuzzys, which I hope will make the helper feel special.

PS I'v made great progress (i thought) in the relams of PHP with the tutorials form phpfreaks, thanks a bunch for the tutorials.

Link to comment
https://forums.phpfreaks.com/topic/56480-basic-user-login-for-survey/
Share on other sites

SELECT * FROM results WHERE User_Name = 'lex'

 

will pull the data, and a command of

 

UPDATE `results` SET `Q4` = '3' WHERE `results`.`ID` =2 LIMIT 1 ;

 

$query="SELECT * FROM results WHERE User_Name = 'lex'";

$result=mysql_query($query);

$row=mysql_fetch_assoc($result);

 

mysql_query("UPDATE `results` SET `Q4` = '3' WHERE ID= $row['ID'] LIMIT 1 ");

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.