Results 1 to 8 of 8

Thread: how do I get button click on PHP page?

  1. #1
    Join Date
    May 2011
    Posts
    470

    how do I get button click on PHP page?

    Hello friend my just a beginner to PHP and I have decided to learn it completely I have been learning it theoretically I have basic knowledge and I got a problem in beginning. And my question is not at all tuff for PHP users who have been using it from some time also so my question is I have declared a global variable in PHP now what the problem is I want to know how to declare a button or a hyperlink or an input form element such that it can change the assignment of this variable. Even if anyone can suggest me by any code regarding buttons on PHP page with by module or anything matching to it I will try to make out how can they help me so just share your codes and please suggest me something .

  2. #2
    Join Date
    Apr 2009
    Posts
    569

    Re: how do I get button click on PHP page?

    Well dude I don’t have been working through something same like what you are asking for and I think I can help you by a code which I have been using and I don’t know would it help you exactly but just go through it and see if you are been helped with it.
    Code:
    <?php 
    $var='something' // global variable 
    if (isset($_GET['change']) && $_GET['change']=="something Else")// check if ancor is clicked which pass through URL variable change 
    { 
    $var = "other value";// if ancor is clicked set global variable on some value 
    } 
    if (isset($_POST["button"]))// check if submit button is clicked 
    { 
    $var="something else"; // if button is clicked assign value to var 
    } 
    ?> 
    <html> 
    <body> 
    <a href="same_page.php?change=somethingElse" >Click to change var</a> 
    <form  action="same_page.php" method="post"> 
    <button type="submit" name="button"> Click </button> 
    </form> 
    
    </body> 
    </html>

  3. #3
    Join Date
    Mar 2010
    Posts
    145

    Re: how do I get button click on PHP page?

    Friend I don’t know much of this php coding as I am new to it too but can help you with my suggestion lets see if it can drag you out of your problem so basically what I have done is I have used some modules cant help you with a long codes but would provide you with a basic and simple code which you tell you what more you can do so just go through this
    Code:
    action_SomeAction() { 
      // write the php code here 
      header("Location: index.php?module={$_REQUEST['return_module']}&action={$_REQUEST['return_action']}&record={$_REQUEST['return_id']}"); 
    }
    With this also go through with the definition of ConvertLead button write the above code in on click event and also add code: this.form.action.value="Some Action"; Hope you get this.

  4. #4
    Join Date
    May 2009
    Posts
    637

    Re: how do I get button click on PHP page?

    If you have declared a global variable and you are working with it are you sure just a click button onphp page code would help you in anyways and I think you need more coding with this but as I don’t know the coding which you have been asking to change the variable or pass the variable value am participating in helping you because you said you can make out something with just a button click code also so I have a small button click code for php page here it is, But I have done it in JavaScript and that’s the best way to do
    Code:
    <script language="JavaScript">
    function check()
    {
    str=document.f.t1.value;
    if(str=="")
    {
    alert("You cant leave this space empty ");
    return false ;
    }
    }
    </script>
    <form action="a.php" method="post" name="f">
    Name <input type="text" name="t1">
    <br>
    <input type="submit" value="submit" on Click="return check();">
    </form>

  5. #5
    Join Date
    May 2009
    Posts
    543

    Re: how do I get button click on PHP page?

    I have made a form in php which had some input controls like input text box and the user would be inserting some values in this text box and this form would have a button and as the button is submitted the on click event would be invoked and it would store the data in the given link. I am sharing it just see If it is helping you out it is like
    Code:
    <?php
    if ($_POST) {
        echo '<pre>';
        echo htmlspecialchars(print_r($_POST, true));
        echo '</pre>';
    }
    ?>
    <form action="" method="post">
        Name:  <input type="text" name="personal[name]" /><br />
        Email: <input type="text" name="personal[email]" /><br />
        Beer: <br />
        <select multiple name="beer[]">
            <option value="warthog">Warthog</option>
            <option value="guinness">Guinness</option>
            <option value="stuttgarter">Stuttgarter Schwabenbräu</option>
        </select><br />
        <input type="submit" value="submit me!" />
    </form> Hope it works.

  6. #6
    Join Date
    May 2009
    Posts
    527

    Re: how do I get button click on PHP page?

    Friend if you want a help according to having a button click on php page then you just have to write a very simple code and actually I dint got what changing variables you are talking about I think you need to clear you question to some of your friends who can view your code and check what exactly you have done and what you have to do next or I think you must contact to some of the professors around you to get it done I think its to tuff to explain codes by net there are many people who would comment a right solution but it wont be viewed as you want because of the naming you are using and what he might have used so just get a proper help from someone around you . If you want some simple codes then you can search anywhere you want.

  7. #7
    Join Date
    Apr 2009
    Posts
    488

    Re: how do I get button click on PHP page?

    Ok working in php you can do this coding in java script or also with html either way you like to go with I think is go through with a book know as php anthology and you would find all the solutions asking a codes over net is not a good idea until you are capable of making out which part is saying what I mean until you know how to edit which part to by edited so that the given code by others would work for you these codes won’t help you in anyways rather getting convinced you would be confused which way to go but as I have a simple code for button on php page here it is
    <input type="button" name="submit other page" value="Other page" on click="window.location.href = 'otherpage.php'"/> I don’t know this would help you or no best of luck.

  8. #8
    Join Date
    Mar 2010
    Posts
    154

    Re: how do I get button click on PHP page?

    I have been dealing with something different but may this help you out so my coding was for I had a variable named $round now when this would be invoked the page has to refresh and it has to update so I think this would help you as you want to change your variable too so lets see if this helps you out and for this my code was
    Code:
    $round = (isset($_GET['round']))?$_GET['rou¬ nd']:1;
    That works nicely for the initial setting of $round. I've then made my "Next" and "Previous" links a URL variable - like this:
    Code:
    $roundnext = $round +1;
    $roundprevious = $round -1;
    if ($roundprevious >= 1) {
    echo '<a href="', $_SERVER['PHP_SELF'], '?round=' . $roundprevious . '">Previous Round</a> | ';
    }
    if ($roundnext <= 25) {
    echo '<a href="', $_SERVER['PHP_SELF'], '?round=' . $roundnext . '">Next Round</a>';
    }

Similar Threads

  1. I want to re-enable the right click button of my mouse.
    By Dhulipala in forum Hardware Peripherals
    Replies: 3
    Last Post: 02-03-2012, 10:36 AM
  2. Right click button is not working in Asus Eee PC 900
    By Marquise in forum Hardware Peripherals
    Replies: 5
    Last Post: 08-08-2011, 10:28 AM
  3. Android Spinner on button click
    By Robert Chandler in forum Software Development
    Replies: 1
    Last Post: 20-04-2011, 12:51 PM
  4. left click button behaves like a right one
    By iris_777 in forum Windows Software
    Replies: 2
    Last Post: 02-11-2010, 03:31 AM
  5. To simulate button click in C#
    By SunilKumar in forum Software Development
    Replies: 2
    Last Post: 02-02-2009, 11:56 PM

Tags for this Thread

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
  •  
Page generated in 1,751,751,204.21806 seconds with 16 queries