Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio button wont work

Status
Not open for further replies.

gokeeffe

Programmer
Jan 11, 2005
170
IE
Help,

I;m trying to pass a variable from a radion button how

can I do this. This is the code i am using but i cant get

the $_POST['agree'] to work, whats wrong

Can anyone help

I agree<input type="radio" name="terms" id= "agree" value="<?php if(isset($_POST['agree']));?>"/>

Tks
Gaz
 
Yes when i press the submit button it still doesn't pass

Here's the entire code

Tks TANSTAAFL

<?php # index.php

// This is the main page for the site

// Include the configuration file for error management and such
require_once ('includes/config.inc');

// Set the title and the html header
$page_title = 'Tell A Friend';

// Include the header file
include_once('includes/header.html');

?>

<div id = "content"><!-- Start of Content -->


<h3>Welcome to the registration phase</h3>

<p align="center">There are just 3 simple steps to complete.
You can register as many subjects as you want.</p>

<?php

if (isset($_POST['submit']))
{ // Check if the form has been submitted
$test = $_POST['agree'];
echo"$test";

}

?>


<table align="center">
<textarea name ="terms_conditions" rows="15" cols="60">
Terms and Conditions

AGREEMENT


This Agreement ("the Agreement") outlines the terms and conditions governing the User's access to and use of the Find A Grind Limited ("FG") web site. By accessing and/or using this web site each of the Tutor and the Student/Potential Student ("the User") agrees to be bound by these terms and conditions. Kindly ensure that the terms and conditions are read carefully. If the User has any queries regarding them, please contact info@findagrind.ie
FG reserves the right at any time and from time to time, to modify or amend this Agreement and/or any part thereof.
The User is responsible for regularly reviewing this Agreement and his/her continued use of the FG web site
constitutes an affirmative acknowledgement of any modification to this Agreement and consent to be bound by its terms.


RIGHTS AND OBLIGATIONS OF FG


1. FG
FG acts as a venue for Tutors to list availability of educational tuition and Students to determine availability of educational tuition and purchase the details. The Tutor warrants that he/she is legally entitled to provide the tuition and the Student warrants that he/she is in a position to purchase the details of education tuition. FG does not provide a guarantee for the quality of educational tuition listed. Also, due to the difficulty of authenticating people over the internet, FG cannot and does not confirm any User's identity.
2. Limitation of Liability
FG shall not be liable for any direct, indirect, incidental, punitive, special, consequential or exemplary damages or loss howsoever arising (including, but not limited to, an action in contract, negligence or other tortious action) that results from the use of information and material available on the FG web site.
FG does not warrant that the web site is free from infection by viruses.
FG does not accept any liability for any losses or claims arising from any inability to access this web site.
3. Disclaimer
The material and information contained in the FG web site including, but not limited to educational tuition listings, pricing information or reviews may contain inaccuracies and typographical errors.
FG does not warrant the accuracy of any information provided or the reliability or truth of any advice, opinion, statement or other information displayed or distributed through the web site. The User acknowledges that any reliance on any such opinion, statement, memorandum or information shall be at his/her own risk.
FG shall not be liable for any failure to perform any of its obligations under this Agreement which is caused by matters beyond its reasonable control including but not limited to Acts of God, breakdown of internet services or other computer services, war, strikes, lock-outs and industrial disputes.
4. Modifications to FG web site
FG reserves the right at any time and from time to time to modify or discontinue temporarily or permanently, the FG web site (or a part thereof) with or without notice. FG shall not be liable to the User or any third party for any modification, suspension or discontinuance of the FG web site.
5. Assignment
FG reserves the right to assign or subcontract any or all of its rights and obligations under this Agreement.
6. Privacy Policy
At Find A Grind Ltd (FG), privacy is very important. FG treats the User's personal information with the
highest standards of safety, security and confidentiality. As part of the normal operation of FG's services it
collects and, in some cases, discloses information about the User. This Privacy Policy describes the information
FG collects and how that information is used.


A Special Note About Children


The nature of the service means that children are possibly the end-users of this service.
Children, however, are not eligible to use the service. FG does not knowingly solicit or collect
information from children who are 18 years or younger and asks that minors (under the age of 18)
do not submit any personal information. If the User is a minor, he/she can use this service only
in co-operation with his/her parents or guardians. Adults may register for children by submitting their own
personal details on behalf of the child. Kindly ensure that children never give out their name or other personal
information on-line without the permission of an adult or guardian.


Information Gathered


FG's main objective in collecting personal information is to provide a smooth, efficient, and customised experience. To register as an FG Member the User must choose a Username and a Password to enable him/her to check the status of their listings at any time ie. their account. The User is required to enter his/her first name, surname, address, phone number and e-mail address.
FG's software allows it to automatically track certain information based upon the User's behaviour on the web site. This information may include the URL that the User just came from (whether this URL is on FG's web site or not), which URL the User next goes to, what browser he/she is using, and his/her IP address. FG sometimes uses this information to solve problems with its server. It also uses this information to determine the most popular pages on its web site.


Modifying/Changing Personal Information


The Tutor can access, review, modify, or delete his/her account information anytime. Just go to 'My Account' button and select the 'Modify Info' button, view all the personal registered Tutor details and modify/change them if required or delete the account at any time, or request FG to deactivate the account.
What FG Does With Information
The Tutor's personal information allows FG to process and display educational tuition listings on its web site and to keep the Tutor up to date on his/her account activity. FG uses information in the file it maintains about the Tutor, and other information it obtains from his/her current and past activities on the web site to troubleshoot problems, provide service support, and to conduct internal analysis.
If FG has questions about a Tutor's listing, it may contact the Tutor by email or phone.


Disclosure of Information


FG is not involved in the provision of educational tuition listed and accepts no responsibility or liability whatsoever for any decision or course of action taken in reliance on the information on this web site.
FG does not share information with unrelated third parties without prior permission. It may disclose aggregate customer information (in a non-personally identifiable manner, such as number of visits or average listing amounts) to advertisers or other third parties. In these situations it does not disclose to these entities any information that could be used to identify the Tutor personally.
FG may release customer account or other information if it is advised that release is necessary to comply with the law, or to protect the rights, property and safety of FG, its customers or others. This may include the exchange of information with companies and organisations or law enforcement for loss prevention and credit risk reduction.


Data Security


FG secures information from unauthorised access, use or disclosure. It uses industry standard practices to safeguard the confidentiality of personal identifiable information, including 'firewalls' and Secure Socket Layers (SSL). SSL encryption scrambles personal and credit card information as it travels over the internet during the process of buying details of educational tuition. This encryption makes it impossible for anyone to read information in transit.


The Use of Cookies


FG uses 'cookies' on certain pages of its web site. 'Cookies' are small text files placed on the User's hard drive that help FG identify the User when he/she visits the web site again. Cookies cannot be used to run programs or deliver viruses.
The purpose of a cookie is to tell the web server that the User has returned to a specific page. For example, if the Tutor registers with FG's web site, a cookie helps FG to recall his/her specific information on subsequent visits. This simplifies the process of recording personal information, such as Password, billing addresses etc.
The User is always free to decline the cookies if his/her browser permits by setting its options so that it lets the User know when he/she receives a new cookie, or turn off the cookies completely. If the cookies feature is turned off however, the User will not be able to utilise all the special features FG offers.


Changes to this Policy


FG may change this Privacy Policy from time to time based on comments received and its need to accurately reflect its data collection and disclosure practices.


USER'S WARRANTIES


1. The User hereby warrants and agrees to indemnify and keep indemnified FG its respective directors, officers, employees and agents from and against any and all liability, damages, losses, claims (including reasonable legal fees) resulting in any way from his/her use of the information and material posted on this web site or resulting from any breach of this Agreement whether such breach is carried out by the User, his/her use of the FG web site, his/her connection to the FG web site or his/her violation of any third party rights.
2. Furthermore, the User hereby acknowledges that any material downloaded or otherwise obtained through the use of the FG web site is done at his/her own discretion and risk and that he/she waives any right to bring any claim or action against FG or its successors, assigns, directors, officers, employees and agents for any loss, damage or injury arising from access to or use of the FG web site.
3. The User hereby acknowledges and warrants to FG that it will not use the FG web site for any purpose that is unlawful or prohibited by these terms and conditions, or in any manner which would damage, disable, overburden or impair the FG web site or interfere with any other party's use and enjoyment of the FG web site. The User may not obtain or attempt to obtain any material or information through any means not intentionally made available or provided for through the FG web site.
4. The User hereby agrees and warrants that he/she will not publish, post, upload, distribute or disseminate any books, material or information on the FG web site that infringes any copyright or intellectual property rights of FG or any third party or does or would constitute a defamation or invasion of the rights of privacy or publicity of any kind of any third party or contains any images or content that is in any way unlawful, harmful, threatening, defamatory, obscene, harassing or racially, ethically or otherwise objectionable and facilitates or promotes illegal activity, depicts pornographic or sexually explicit images or promotes violence or discrimination.
5. The User hereby agrees to indemnify and keep indemnified FG its successors and assigns and each of its respective directors, officers, employees and agents from and against any and all liability, damages, losses, claims (including reasonable legal fees) resulting in any way from any such publication, posting, uploading, distribution or dissemination of any such material or information on the FG web site.
6. The User's correspondence or dealings with, or participation in promotions and/or advertisers found on or through the FG web site are solely between him/her and such advertiser. FG is not responsible or liable for any loss or damage of any sort incurred as the result of any such dealings.
7. The User hereby warrants and acknowledges all intellectual property to include, but not limited to, copyright, moral rights, patents, trade marks, trade names, service marks, designs (software or otherwise), data base rights, whether registered or unregistered generally present and future belongs, and shall belong exclusively to, FG and that he/she will not infringe such intellectual property rights in any way.



ENTIRE AGREEMENT


This Agreement constitutes the entire Agreement between the User and FG and supersedes any prior agreements, arrangements, statements and understandings between the parties.


WAIVER


A waiver by FG of any breach by the User of any of the terms, provisions or conditions of this Agreement or the acquiescence of FG to any act (whether of commission or omission) which but for such acquiescence would be a breach as aforesaid shall not constitute a general waiver of such term, provision or condition or of any subsequent act contrary thereto.


INVALIDITY

If at any time any one or more provisions of this Agreement shall be held to be invalid, illegal or unenforceable, the validity, legality and enforceability of the remaining provisions of this Agreement shall continue in full force and effect.


DISSATISFACTION


If the User is dissatisfied with the FG web site or any information posted thereon, or with any term or condition of this Agreement, his/her sole and exclusive remedy is to discontinue using the FG web site.

GOVERNING LAW


This Agreement shall be governed by the law of the Republic of Ireland and the Courts of the Republic of Ireland shall have sole and exclusive jurisdiction.


</textarea>

</table>

<form action= "<?php echo $_SERVER['PHP_SELF'];?>" method="post">

<p align="center">

I agree<input type="radio" name="terms" id= "agree" value="<?php if(isset($_POST['agree']));?>"/>

I do not agree<input type="radio" name="terms" id= "not_agree" value="not_agree"/>
</p>



</br>
</br>
<input type="submit" name="submit" value="Continue" class="btn"/>
</br>
</br>



</div><!-- End of Content -->


<?php
// Include the footer file
include_once('includes/footer.html');
?>
 
Here's the problem as I see it.

The first time, the script runs, $_POST['agree'] has no value. So on that first run, this line of the script:

I agree<input type="radio" name="terms" id= "agree" value="<?php if(isset($_POST['agree']));?>"/>

Evaluates to:

I agree<input type="radio" name="terms" id= "agree" value=""/>

Thus when the script is submitted, the form element, if selected, submits a value of "".

When the form is submitted back to the script that originally produced the script, $_POST['agree'] is set, but has a value of "". So on the second run, this section of your script:

if (isset($_POST['submit']))
{ // Check if the form has been submitted
$test = $_POST['agree'];
echo"$test";

}

correctly outputs a zero-length string.

There is a difference between an unset variable and a set variable that contains a zero-length string.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Ok I think i understand but how can I fix this problem

I would have thought that if i click the radio button and

then submit the value would be set. How can I set the

variable so that it is set on submit

Cheers
 
Oh, yeah, and another thing. Only JavaScript can reference an element's value by its id. In PHP, you must reference a value by the field's name.

Also, with a radio button, you preselect a value by setting its "checked" attribute.

I'm not sure what you're trying to do, but here is a test script I just threw together:

Code:
<?php
print '<html><body>
blah blah blah

<form action="' . $_SERVER['PHP_SELF'] . '" method="post">
Agree <input type="radio" name="terms" value="1"';
   
if (isset($_POST['terms']))
{
	if ($_POST['terms'] == 1)
	{
		print ' checked';
	}
}

print '><br>
Not agree <input type="radio" name="terms" value="0"';

if (isset($_POST['terms']))
{
	if ($_POST['terms'] == 0)
	{
		print ' checked';
	}
}

print '><br>
<input type="submit"></form></body></html>';
?>

The first time the script runs, neither button is checked. After a button is checked and the form submitted, the form is rerendered with the previous button checked still selected.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Tks TANSTAAF

Got it working , your a legend !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top