Hello friend ,
In the following code when user click submit i want to to radio buttton option means
user click 1 ,2 ,3 or 4
means its print tha option
but it snot print
can any body help me ?
[PHP]
<html>
<BODY>
<table border='0'><tr><td valign='top'><input
type='radio' name='quiz' value='1' />a</td><td>
<br></td></tr><tr><td valign='top'><input
type='radio' name='quiz' value='2' />b</td><td>
<br></td></tr><tr><td valign='top'><input
type='radio' name='quiz' value='3' />c</td><td>
<br></td></tr><tr><td valign='top'><input
type='radio' name='quiz' value='4' />d</td><td>
<br></td></tr></table><br></p></form>
</BODY></html>
<?php
echo $HTTP_POST_VARS['quiz'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Questionnaire</title></head>
<body>
<form name="myform" action="http://localhost//my1.php" method="post">
<input type="submit" name="submitted" value="submit" />
<input type="hidden" name="que" value="<?=$HTTP_POST_VARS['quiz']?>">
</form></body></html>
[/PHP]
sanjay
5 3845
You must include the input field radio buttons witihin your FORM, Then, after submission, the clicked items will be passed via the $_POST variable.
(Do not use the HTTP_* vars, because they are deprecated and will no longer be available in PHP 6, use $_POST instead).
Ronald :cool:
Sir
i replace $HTTP_POST_VARS by
$_POST but its not print option just like 1 ,2 and 3
i am using php 5
sanjay
Atli 5,058
Recognized Expert Expert
Hi. I'm sorry but I didn't understand what your trying to do.
A couple of things I noticed tho..
Were there more than one file posted there? Cuz if this was all one file id try not to open and close <html> tags all over the place.. and I wouldnt echo things after I close a html tag.
A form tag must be posted using a submit button (or scripts) before teh php can take it as $_Post data
This is a simple way to do what I think your trying to do...
[PHP]if(isset($_POST['Posted']))
{
echo "Option selected : ". $_POST['opt'] ."<br>";
}
?>
<form action="?" method="post">
<input type="radio" name="opt" value="1" /> 1<br>
<input type="radio" name="opt" value="2" /> 2<br>
<input type="radio" name="opt" value="3" /> 3<br>
<input type="radio" name="opt" value="4" /> 4<br><br>
<input type="submit" name="Posted" value="Select" />
</form>
<?[/PHP]
You must include the input field radio buttons witihin your FORM, Then, after submission, the clicked items will be passed via the $_POST variable.
(Do not use the HTTP_* vars, because they are deprecated and will no longer be available in PHP 6, use $_POST instead).
Ronald :cool:
Don't do just part 2 of my reply. Take note of part 1, which says that you can must include your buttons within the form, then submit it, and only after submission you can retrieve the values via $_POST!
Ronald :cool
[html]
<html><head><title>Questionnaire</title></head>
<body>
<form name="myform" action="http://localhost//my1.php" method="post">
<table border='0'><tr><td valign='top'><input
type='radio' name='quiz' value='1' />a</td><td>
<br></td></tr><tr><td valign='top'><input
type='radio' name='quiz' value='2' />b</td><td>
<br></td></tr><tr><td valign='top'><input
type='radio' name='quiz' value='3' />c</td><td>
<br></td></tr><tr><td valign='top'><input
type='radio' name='quiz' value='4' />d</td><td>
<br></td></tr></table><br></p>
<input type="submit" name="submitted" value="submit" />
<input type="hidden" name="que" value="<?=$HTTP_POST_VARS['quiz']?>">
</form>
</BODY></html>
<?php
// this line will print nothing
echo $HTTP_POST_VARS['quiz'];
?>
[/html]
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: S.Shaigany |
last post by:
Hi everybody,
Please help me. I have a problem with my login page, which worked fine
during the last one month. I have'nt made any changes in it. but from
yesterday on, it seems that my PHP code...
|
by: WindAndWaves |
last post by:
SHould I write $HTTP_POST_VARS or $HTTP_POST_VARS or $HTTP_POST_VARS
It seems that both of them (with or without quotes) work...
Sorry I am sure this is a very stupid question...
- Nicolaas
|
by: frey |
last post by:
the code is used for repost $HTTP_POST_VARS from a form to the insert
page at the "preview" page
<?php
/* Re-Post all POST'ed variables */
reset($HTTP_POST_VARS);
while (list($key, $value) =...
|
by: vinnie |
last post by:
Does anyone may help in understanding how these functions work, with
an easy example?
a) $HTTP_POST_VARS;
b) stripslashes();
c) addslashes();
thanks a lot
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |