Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Radio buttons and confirmation buttons...

  • 22-01-2007 4:56pm
    #1
    Registered Users, Registered Users 2 Posts: 304 ✭✭


    For my website I need to create a confirmation page for people to give consent, they have to click the correct radio button in order to proceed to the next page. Does anyone know where I can get the code for this? Or what type of programming language I need to use?

    I need it so that when user presses on the confirmation button, that depending on whether or not they give consent, it directs them to either the next page in the site, or away from the website if they have selected the 'do not give consent' radio button.

    Anyone know what I'm talking about?


Comments

  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Depends and what language your website is written in. If its just static HTML then it would help to know what type of webserver it's being hosted on, then we'll know what languages are supported.


  • Registered Users, Registered Users 2 Posts: 304 ✭✭Smiley012


    Its html and php, and I'm with bravehost, on a paid account, I hear they support all languages, well majority of them anyway!


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Here you are, a basic example:

    [php]<?php

    if(isset($_POST)){

    if(!$_POST){

    echo "You didn't select an answer";

    }

    if($_POST == "yes"){

    echo "You selected yes";
    //instead of the echo here you will want to redirect presumably? if so, delete the echo... line and uncomment the next line, replacing the location with your own
    //header("Location: sucess.htm");


    }

    if($_POST == "no"){

    echo "You selected no";
    //header("Location: fail.htm");

    }

    }

    ?>

    <html>
    <head>
    <title>Untitled Document</title>
    </head>

    <body>
    <form action="" method="post" name="frmLogin" id="frmLogin">
    <table width="400" border="1" align="center" cellpadding="2" cellspacing="2">
    <tr>
    <td width="150">Yes</td>
    <td><input name="group" type="radio" value="yes"></td>
    </tr>
    <tr>
    <td width="150">No</td>
    <td><input name="group" type="radio" value="no"></td>
    </tr>
    <tr>
    <td width="150"> </td>
    <td><input name="submit" type="submit" value="Submit"></td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    [/php]


  • Registered Users, Registered Users 2 Posts: 304 ✭✭Smiley012


    Hey man, thanks a million for that, I'll be putting in a thank u to you in my acknowledgements section! :)


  • Registered Users, Registered Users 2 Posts: 304 ✭✭Smiley012


    I think I'm being stupid, but do I type this for the location part?:
    if($_POST['group'] == "yes"){
    
    
        Location: sucess.htm;
    
    
    }
    
    if($_POST['group'] == "no"){
    
      Location: fail.htm;
    
    }
    
    }
      
    ?>
    


  • Advertisement
  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Not quite, you've got to use the brackets and inverted commas too i.e.

    [php]header("Location: success.htm");[/php]


  • Registered Users, Registered Users 2 Posts: 304 ✭✭Smiley012


    i changed them but now I'm getting this error:

    Warning: Cannot modify header information - headers already sent by (output started at /misc/25/000/102/320/6/user/web/edate.bravehost.com/consent.php:9) in /misc/25/000/102/320/6/user/web/edate.bravehost.com/consent.php on line 22


    any idea?


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    I'm assuming your code looks like this:

    [php]
    <?php

    if(isset($_POST)){

    if(!$_POST){

    echo "You didn't select an answer";

    }

    if($_POST == "yes"){

    header("Location: success.htm");

    }

    if($_POST == "no"){

    header("Location: fail.htm");

    }

    }

    ?>
    [/php]

    Have you added anything?


  • Registered Users, Registered Users 2 Posts: 304 ✭✭Smiley012


    No I haven't changed anything except my file names, and I'm still getting an error!!
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <?php
    
    
    if(isset($_POST['submit'])){
    
        if(!$_POST['group']){
    
            echo "You didn't select an answer";
    
        }
    
    if($_POST['group'] == "yes"){
    
        header("Location: instruct.htm");
    
    }
    
    if($_POST['group'] == "no"){
    
        header("Location: error.htm");
    
    }
    
    }
      
    ?>
    
    </body>
    </html>
    

    Any idea??


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Yes, its because you've got
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    

    before the php code. You can't output any information to the browser before calling the header function in php.


  • Advertisement
Advertisement