0

I am using the following form to take input and then set an action

 <form action="" method="post">
        <select name="page_option">
        <option value="go1">Go 1</option>
        <option value="go2">Go 2</option>
        </select>
        <input type="submit" value="Change home.php" />
        </form>

Instead of this I want to have two buttons side by side,one button has text GO1 while other has GO2 and when user click GO1 and GO2 it will serve the same purpose as this above form Also when Go1 button is clicked the page will display below the buttons "GO1 is on" and when Go2 is clicked it will display below "GO2 is on"

any help ?

Edited by ska_defender

3
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by rotten69
2

Ok. The steps are as follows:
1- Open any text editor and make a file and call page or whatever name .php so this will be page.php

2-Take the snippet below and paste in there.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
   <title> I am checking the values for the options chosen in the form </title>
</head>

<body>


         <form name="myForm" action="check.php" method="POST">

             Choose one of these values: &nbsp; 
                 <input type="submit" name="go" value="Go 1" /> &nbsp;
                 <input type="submit" name="go" value="Go 2" /> 

              <?php echo " <p style='background-color:red; width: 5%;'>" .@$_GET['text'] ."</p> "; ?> 


         </form>


</body>
</html>

3- Make another file and call it this name check.php if you want to change the name of the file, then you will have to change the name in the action attribute as well.

4- Take the snippet below and paste it in there

<?php

    $go = $_POST["go"];


        // here we're checking if there is a value for the variable "go" AND the value equals to "Go 1"

        if( (isset($go)) AND ($go1 == "Go 1") ){    
            header("Location:checking.php?text=Go 1 is on");

        }else if(  (isset($go)) AND ($go1 == "Go 2") ){ 
        // here we're checking if there is a value for the variable "go" AND the value equals to "Go 2"

            header("Location:checking.php?text=Go 2 is on");
        } 
?>

Please mark this thread as solved if your problem is fixed. And also, Don't forget to give me a rep on the right hand side.

Edited by rotten69

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.