473,587 Members | 2,580 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'];
  3.  
  4. if (isset ($_POST['agree'])) {
  5.  
  6.     echo "<h3>You agree to our terms</h3>";
  7.     header('Refresh: 10; URL=searcher.php');
  8.  
  9. } else echo "<h3>You Disagree, you must agree before using our database</h3>";
  10.  
  11.  
I have also tried

Expand|Select|Wrap|Line Numbers
  1. $submit = $_POST['submit'];
  2. $agree = $_POST['agree'];
  3.  
  4. if (isset ($_POST['agree'])) {
  5.  
  6.     echo "<h3>You agree to our terms</h3>";
  7.     header('Location: searcher.php');
  8.  
  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 5797
Sudaraka
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" />
  4.  
  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'])) {
  2.  
  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
Sudaraka
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:
search.php
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" />
  5.  
  6. <input type="submit" name="submit" id="submit" value=" Agree " />
  7. </form>
termscond.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(empty($_POST['agree'])) {
  3.  
  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
Sudaraka
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
Sudaraka
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
Sudaraka
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

5
3592
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...
4
3437
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...
2
3181
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...
2
1259
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...
11
16319
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
1
1277
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...
2
1325
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">
1
3723
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,...
6
1581
djsjm
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...
2
1331
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
0
7918
marktang
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...
0
7843
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...
0
8206
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7967
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
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...
0
6621
agi2029
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...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2353
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.