473,835 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Terms and Conditions Form, 1 Checkbox redirect to another page

9 New Member
Hi I have a basic form, all it has on it is a checkbox with terms and conditions, the user has to check the box to say I agree, the problem I am having is the page is echoing the correct information out but is not redirecting the user if they check the box.

The Php code is in include statement in the form page which is layed out via css etc etc.

The code I have is

Expand|Select|Wrap|Line Numbers
  1. $submit = $_POST['submit'];
  2. $agree = $_POST['agree'];
  4. if (isset ($_POST['agree'])) {
  6.     echo "<h3>You agree to our terms</h3>";
  7.     header('Refresh: 10; URL=searcher.php');
  9. } else echo "<h3>You Disagree, you must agree before using our database</h3>";
I have also tried

Expand|Select|Wrap|Line Numbers
  1. $submit = $_POST['submit'];
  2. $agree = $_POST['agree'];
  4. if (isset ($_POST['agree'])) {
  6.     echo "<h3>You agree to our terms</h3>";
  7.     header('Location: searcher.php');
  9. } else echo "<h3>You Disagree, you must agree before using our database</h3>";
I have tried using the variables set but nothing works when I do

Can anyone tell me where I am going wrong?

Be grateful for some help as I am getting nowhere fast with this.

Thanks in advance.
Mar 12 '11 #1
16 5834
55 New Member
  1. Make sure your form is set to submit using HTTP POST, not GET. (method="post")
  2. Make sure you checkbox is named "agree" (name="agree") and have some non-empty value (value="AGREED" )
  3. In the back-end code check if the value is empty or not.

Expand|Select|Wrap|Line Numbers
  1. if(empty($_POST['agree'])) {
  2.     //Not agreed
  3. }
  4. else {
  5.     //Agreed
  6. }
Mar 13 '11 #2
david ashby
9 New Member
Thanks for the reply but I am missing something, what you have given me is half working i9n that it redirects to the page required but it also redirects if checkbox not ticked, what have I missed?

Expand|Select|Wrap|Line Numbers
  1. <form id="form1" name="form1" method="post" action="search.php">
  2. <label for="agree">Agree</label>
  3.           <input type="checkbox" name="agree" id="agree" />
  5. <input type="submit" name="submit" id="submit" value=" Agree " />
The page with the form is search.php so it is posting back to itself

the php script included in the form is

Expand|Select|Wrap|Line Numbers
  1. <?php include 'php/termscond.php'; ?>
and the script is as follows now

Expand|Select|Wrap|Line Numbers
  1. if(empty($_POST['agree'])) {
  3.     echo "<h3>You must agree before accessing our database</h3>";
  4. }
  5. else {
  6.     header('Location: searcher.php');
  7. }
The header is not working although the search.php and searcher.php are at same level in directory in same folder.

Thanks in advance for your help
Mar 13 '11 #3
55 New Member
Code you have posted above works fine. Maybe some other part of the code is interfering with the redirection.

Here's what I tested:
Expand|Select|Wrap|Line Numbers
  1. <?php include 'termscond.php'; ?>
  2. <form id="form1" name="form1" method="post" action="search.php">
  3. <label for="agree">Agree</label>
  4.           <input type="checkbox" name="agree" id="agree" />
  6. <input type="submit" name="submit" id="submit" value=" Agree " />
  7. </form>
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(empty($_POST['agree'])) {
  4.     echo "<h3>You must agree before accessing our database</h3>";
  5. }
  6. else {
  7.     header('Location: searcher.php');
  8. }
Mar 13 '11 #4
david ashby
9 New Member
So in your test when you did not check the box you were advised to check or you could not use the search facility but you were kept on the terms page?

When you checked the box you were redirected?
Mar 13 '11 #5
55 New Member
yes, it only goes to the searcher.php if the checkbox is checked.
Mar 13 '11 #6
david ashby
9 New Member
Would it be possible for you to just have a quick look at the pages concerned, to see if you can spot why it is not working for me then please?
Mar 13 '11 #7
55 New Member
Sure, Please post the complete and latest code you are trying out.
Mar 13 '11 #8
david ashby
9 New Member
Link to search page

The php code is exactly what you suggested earlier, I just cannot seem to work out why I cannot get it working especially as you have said it worked for you.
Mar 13 '11 #9
55 New Member
Your HTML form seems to be ok. I think the problem might be in http://www.da-ict.co.uk/php/termscond.php
Please post the complete PHP code of that file.
Mar 13 '11 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Nazir | last post by:
I am trying to do something pretty simple - but can't see how it can be done in ASP.NET. I have an aspx web page with a form which opens up a new window. The web page uses code behind to build the new window. There is simple validation on the form. However, after the form page validates and opens the new window, I want it to redirect to another page (or stop displaying the form).
by: Andrea De Santi | last post by:
How can I redirect to another page with form data? In asp Classic I write: <form ... action="filename">...</form> and in then target page I write <%=request.form("fieldname")%> ..... but in ASP.NET 1.1 'action' does not exist how can I send form data to another page?... and how can I read a form values (same of ASP classic with request.form("fielsname")?)
by: KFactor | last post by:
Is it possible to pass form variables to a page on another server using response.redirect? Or is there a secure way of passing sensitive information from one site to another such as a userID? I would like to avoid using the querystring. This is what I would like to do: When a user clicks on the link, I need to add them to the database and then
by: Luongo | last post by:
Hi, I have a form that, when submitted, needs to be processed by one file (survey.php) but have another page (thankyou.php) displayed. Because I don't have access to the former, I can't combine the two which would obviously be the best thing. What's the best way therefore to accomplish this? Would a meta-refresh do the trick or would that simply redirect to the thankyou page without processing? Thanks for your help....
by: dkate777 | last post by:
Hi, Is anybody know how to pass textbox input value to another page. I am using document.secondform.fieldname.value=document.firstformname.fieldname.value but it's not working Thanks
by: mentor | last post by:
in first page, <form id="form1" runat="server" action="page2.aspx"> <TEXTAREA id="txt1" runat=server></TEXTAREA> <INPUT type=submit value=submit name=rev_submit> in second page(c#) string str = Request.Form; In this way, data can be posted to second page. But I found when the first page is posted back, the content in browser is still that of first page, not second page. How to jump to page2.aspx, while using the data in fomr1 ...
by: Hamayun Khan | last post by:
Hi I have Two pages Default.aspx and Default2.aspx Default.aspx has the following code <%@ Page Language="VB" MasterPageFile="~/Main.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
by: Wolfman | last post by:
Hi gang! I've been searching for a solution to this problem extensively but nothing really hits the mark. I have a descriptive popup page that contains a PayPal order button. The normal PayPal form fields allow for the item description, fee, etc. I'd like the fee field to be variable based upon which hyperlink launched the popup. So, HREF click sets a variable INPUT TYPE (hidden) named "amount" equals the variable
by: djsjm | last post by:
Hi there, Beg of your forgiveness if this is too basic or the question has already been answered somewhere... I'm still learning my way around php and this site. I have a form on page 1 which is sent to be displayed on page 2. Is there a way to do this while also sending an email to me with the information that was submitted? I know how to do both individually, just not simultaneously, and google isn't helping (wait, why am I still...
by: ssmeshack85 | last post by:
Hai there, Im using ASP .NET C#. Here I have a few checkboxes in page 1. When hit the next button that link to page2, I want checkboxes that checked send it's details to the textbox in page 2. Can it be done? any comments about it, please. Thanks, Meshack
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
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.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.