Jump to content

checkbox validation with 2 pages.


WesleyA

Recommended Posts

Can someone give an example of a php script that lets a form with checkbox input choose between 2 different pages when it is checked or not.

 

Actually the dilemma is that the action attribute is sending form data to another pages (2 pages) - but dont know what code to use - .

 

So if the checkbox isnt checked a third page should load in the browser.

Link to comment
Share on other sites

put the code for each page in its own include, and then use the value of the checkbox to include the appropriate code:

if (!empty($_POST['mycheckbox'])){   include '../page1.inc';}else{    include '../page2.inc';}  

Or just resolve the page that that should be loaded client side and alter the action with javascript.

Link to comment
Share on other sites

So you want the user to have the ability to open two pages in different tabs/windows or both in one page? which the checkbox would be the correct input type to use, OR give the user the ability to select one or the other where input type radio should be used where also the third page could be the default.If you use cobol PHP method i should check if file exits before attempting to include.

Link to comment
Share on other sites

Yeah my idea is that 2 pages are a good solution.

 

I tried to add the code with include but it doesnt open the pages in a new window or new tab which I would rather have.

 

( I heard of COBOL as a very old programming language as I'm born in the sixties and COBOL is from that period or so, but now I program PHP, as far as I know I only use the most common library of instructions. I now have WAMP installed I dont use tools or API's, dialect etc. at the moment.)

Edited by WesleyA
Link to comment
Share on other sites

 

When i said cobol i was refering to COBOLdinosaur.

 

 

:rofl: Its Okay I am actually older than COBOL and I even beat the introduction of ENIAC by a little bit.

Link to comment
Share on other sites

AaaaarrrggggghhhThe user has the option with two checkboxes to select ALL, i.e BOTH!Is that what you want?IF YESDo you want the user to have the ability to open two pages in DIFFERENT tabs/windows/pages or BOTH in same one page?IF NOthen you should be using radio buttons where only one page can be selected.

Link to comment
Share on other sites

Im looking for a solution to direct the visitor to a page so they can have a message that the checkbox should be checked.

 

Submit action offers the possibility to direct someone to one page. (or am i wrong?)

 

The idea is that the decision whether the checkbox is checked has to be made in advance. If checked it shoud go on using the submit action

 

(if this is the only solution ???)

 

It works like this: the user gets a list of several choices (taken from a list of mysql database tables) and they have to check. Only 1 is allowed to be chosen. You have to choose one (not 2 or 5 but 1) else the parser gives an error and/or nothing will be added to the database. If the checkbox is chosen the user can add records to the table.

 

What I want is actually free and is also a matter of possibilties there are with HTML/PHP (not javascript). So they can be sent to an error_page and the completed page was one option. Maybe its also an option to have it echoed on the same page but it depends on what is possible and how that is done.

 

What is the difference in approach between these 2 different pieces of script?

Edited by WesleyA
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...