SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Buttons

  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Buttons

    Hello!

    Um... I'm kinda new to this stuff and I just wrote a page with buttons that go to an new page here's my code:

    <form method="post" action="home.php">
    <table width=100% align="center">
    <tr>
    <td><center><button name="past" value="past" type="option"><img src="Clouds.jpg"

    align="absmiddle">Go To The <font color="black"><b>Past</b></font></button></center>
    </td>
    <td><center><button name="present" value="present" type="option"><img src="Sunset.jpg"

    align="absmiddle">Go To The <font color="black"><b>Present</b></font></button></center>
    </td>
    </tr>
    </table>
    </form>

    Here's the code to my PHP file:

    <?
    if( isset( $_REQUEST['past'] ))
    {
    header("Location: CS04.html");
    }

    if( isset( $_REQUEST['present'] ))
    {
    header("Location: CS05.html");
    }
    ?>


    Although when I click on the button the page doesn't change the new page. It just stays on the original page... Some one help me please. Thanks in advance!!

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    South Africa
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?
    if( isset( $_POST['past'] )) 

    header("Location: CS04.html"); 


    if( isset( 
    $_POST['present'] )) 

    header("Location: CS05.html");

    ?>
    Should work?
    If you found this post helpful, click rep!

    PLAY Design Solutions

    Designs :: Reseller :: Shared

  3. #3
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Hum....?

    Hum I changed the code like you told me but it still doesnt change pages... any other ideas?? Sorry, but I really do appreciate your effort.

  4. #4
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Lviv, Ukraine
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When You click the button, the button doesn?t "know" what to do.
    You should write for Your tag <button> event onClick and script for if.

    <button name="present" value="present" type="option" onClick='document.forms[0].submit();'></button>

    P.S.: You should better use the tag <input type='button'>

  5. #5
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    If you want to use this as a form, use the correct html syntax as described by nahaylo
    <input type="button">

    or if you just want to pass the variable using your image as a button, use
    Code:
    <a href="home.php?action=past"><img src="Clouds.jpg" align="absmiddle"></a>
    Then on your php page...
    PHP Code:
    if($_GET['action'] == 'past'

    header("Location: CS04.html"); 

    etc theough your choices.

    SpikeZ
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •