Jump to content


Photo

textfile radiobuttons


  • Please log in to reply
6 replies to this topic

#1 gish

gish
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts

Posted 29 May 2006 - 05:26 AM

It is official I am going nuts
I am a beginner i php5. I got on the net and down loaded a lot of information. after reading the info. I decided to start
forms. That easy enough. I can email it myself without a problem. The I decided that I would write to a text file on the
apache2 server. I found some code of the net and that was easy enough. if you are writing text. put for three months I have
been trying to get this php code to write its self to a text file on the server. I am sure at it is very easy.

In the <head> I have been trying to get the variable $question to change value and then write and I cannot do it
please can anyone help. Or even a tut that will break it down step by step

P.s. the next step for me I though was Mysql but i have been reading that mysql would be adquate for a beginner is this true
does anyone have an opinion.

Sorry P.S
Is there a newsletter I can subscribe to for beginners in php

<html>
<head>

<title>Sample</title>
</head>
<body>
<FORM method="POST" action="<?php echo $_SERVER['PHP_SELF']?>">

<?php
echo '<input type="radio" name="gender" value= $Question1 = "1" checked />1 unsure<br>';
echo '<input type="radio" name="gender" value= $Question1 = "2" />2 Thats true<br>';
echo '<input type="radio" name="gender" value= $Question1 = "3" />3 I never thought<br>';
echo '<input type="radio" name="gender" value= $Question1 = "4" />4 Nice one<br>';
?>
<INPUT TYPE="SUBMIT" value="Send data">

</body>
</html>




#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 29 May 2006 - 07:16 AM

I can't understand what is your problem. You don't need the $Question1 variable in there. Besides, the string is enclosed by single quotes, so it's not interpolated what means $Question1 would actually do nothing.

Also, there is no such thing in HTML like value= something = "1".

Simply value="1" is enough, assuming you just want to know the user's choice.
~ D Kuang

#3 gish

gish
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts

Posted 29 May 2006 - 09:40 AM

[!--quoteo(post=378004:date=May 29 2006, 02:16 AM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ May 29 2006, 02:16 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I can't understand what is your problem. You don't need the $Question1 variable in there. Besides, the string is enclosed by single quotes, so it's not interpolated what means $Question1 would actually do nothing.

Also, there is no such thing in HTML like value= something = "1".

Simply value="1" is enough, assuming you just want to know the user's choice.
[/quote]

It sounds like i am trying to hard. if I am on the same wave lenght all i the number is suficent enough. so when it gets submited it reads the valued that is selected by the user. Then I have grab that info and send it. I am sorry poirot as I said I am only a beginner.

#4 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 29 May 2006 - 04:56 PM

No problem.

When you have a group of radio buttons like this:
<input type="radio" name="fruit" value="banana"> Banana
<input type="radio" name="fruit" value="apple"> Apple
<input type="radio" name="fruit" value="lemon"> Lemon
and the user selects for example "apple" when posted to PHP it gives you $_POST['fruit'] = 'apple';
~ D Kuang

#5 ale_jrb

ale_jrb
  • Members
  • PipPip
  • Member
  • 17 posts
  • LocationLondon, UK

Posted 29 May 2006 - 07:44 PM

<html>
<head>
<title>Favourite Fruit</title>
</head>
<body>

<p><strong>Question 1:</strong> What is your favourite fruit?
<p><FORM method="POST" action="<?php echo $_SERVER['PHP_SELF']?>">
<input type="radio" name="fruit" value="Apple" checked />Apple<br>
<input type="radio" name="fruit" value="Banana" />Banana<br>
<input type="radio" name="fruit" value="Grape" />Grape<br>
<input type="radio" name="fruit" value="Orange" />Orange<br>
<INPUT TYPE="SUBMIT" value="Send data">

</body>
</html>

Did you mean to do something like this? This asks that user their favourite fruit. They choose one of the options and click "Send" and it stores their answer in a text file.

Is that what you were trying to do?

#6 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 29 May 2006 - 08:12 PM

[!--quoteo(post=378185:date=May 29 2006, 12:44 PM:name=ale_jrb)--][div class=\'quotetop\']QUOTE(ale_jrb @ May 29 2006, 12:44 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]Did you mean to do something like this? This asks that user their favourite fruit. They choose one of the options and click "Send" and it stores their answer in a text file.

Is that what you were trying to do?
[/quote]
Actually I was giving him an example [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /]
Obviously you'd need the form, the submit button and so on, but I was justing showing him the basics of radio buttons.

~ D Kuang

#7 gish

gish
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts

Posted 02 June 2006 - 03:41 AM

[!--quoteo(post=378185:date=May 29 2006, 02:44 PM:name=ale_jrb)--][div class=\'quotetop\']QUOTE(ale_jrb @ May 29 2006, 02:44 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
<html>
<head>
<title>Favourite Fruit</title>
</head>
<body>

<p><strong>Question 1:</strong> What is your favourite fruit?
<p><FORM method="POST" action="<?php echo $_SERVER['PHP_SELF']?>">
<input type="radio" name="fruit" value="Apple" checked />Apple<br>
<input type="radio" name="fruit" value="Banana" />Banana<br>
<input type="radio" name="fruit" value="Grape" />Grape<br>
<input type="radio" name="fruit" value="Orange" />Orange<br>
<INPUT TYPE="SUBMIT" value="Send data">

</body>
</html>

Did you mean to do something like this? This asks that user their favourite fruit. They choose one of the options and click "Send" and it stores their answer in a text file.

Is that what you were trying to do?
[/quote]


this is exactly what i was looking for. but this raises an issiue when you use a submit button
does the submit button gather all the in information with in the form and then send it the server.
witth this code

<FORM method="POST" action="<?php echo $_SERVER['PHP_SELF']?>">

if so when it sends how do I manipulte it.

not sure how this works

"<?php echo $_SERVER['PHP_SELF']?>

Iam sure that it is very easy when you know now




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users