Jump to content

first attempt


juniorek9

Recommended Posts

Hi all.

I`m starting with the php programming and i try to create a simple questionnaire

i want to ask few questions with few possible answers

could anyone give me any sample how the code should look like, i`ve created few quetsions but they are all seperate code, how can i put them together into one code?

any suggestions?

Thanks

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/221265-first-attempt/
Share on other sites

it isn't your first attempt, as that you posted earlier in this forum...

 

you should mess around with echo post data from forms.

 

<form method="post" action="">

<input type="text" name="var" />

</form>

 

<?php

$array[]='string1';

$array[]='string2';

$array[]='string3';

foreach($array AS $string){

  if(!empty($_POST['var'])){

    if($_POST['var']==$string){

      echo $_POST['var'].' is the same as '.$string;

    }

  }

}

?>

Link to comment
https://forums.phpfreaks.com/topic/221265-first-attempt/#findComment-1145589
Share on other sites

Did you try searching

 

"php questionnaire tutorial"

 

In google?

 

http://www.google.co.uk/search?q=php+questionnaire+tutorial&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-GB:official&client=firefox-a

 

There's tons of tutorials on this kind of stuff. Also, you might want to try search for "php survey tutorial" too.

 

Hope that helps.

Link to comment
https://forums.phpfreaks.com/topic/221265-first-attempt/#findComment-1145696
Share on other sites

<?php
if(isset($_POST['submit'])) {
foreach($_POST as $k => $v) {
	echo $k . ' = ' . $v;

	if($_POST[$v] == 'the right answer') {
		echo 'well done you got ' . $_POST[$k] . ' right';
	} else {
		echo 'you have failed';
	}
}
}

$transport = array('r' => 'Cruise the street in your hot ride',
                 'a' => 'Join the army',
                 'p' => 'go to a science convention',
			 'h' => 'stay home and work on the computer');
foreach ($transport as $key => $transport) {
   $return .= '<input type="radio" name="transport" value="' . $key . '"/> ' . $transport . '<br/>';
}

echo '<form action="" method="">' . $return . '<input type="submit" name="submit"></form>';

 

James.

Link to comment
https://forums.phpfreaks.com/topic/221265-first-attempt/#findComment-1145714
Share on other sites

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.