c alling a function with a button click

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • chris

    c alling a function with a button click

    hi all

    im relativly new to PHP but loving it - its fantastic isnt it (reminds me a
    lot of BASIC on steroids)

    my question is this

    how do i call a function from a button using php??

    Thanks






  • Savut

    #2
    Re: c alling a function with a button click

    You can't do that with PHP, this is not a kind of stuff that PHP because it is server side. You need to use Javascript for that.

    Savut

    "chris" <someone@here.c om> a écrit dans le message de news:3fd887a3$1 @funnel.arach.n et.au...[color=blue]
    > hi all
    >
    > im relativly new to PHP but loving it - its fantastic isnt it (reminds me a
    > lot of BASIC on steroids)
    >
    > my question is this
    >
    > how do i call a function from a button using php??
    >
    > Thanks
    >
    >
    >
    >
    >
    >[/color]


    Comment

    • Robert Downes

      #3
      Re: c alling a function with a button click

      chris wrote:[color=blue]
      > im relativly new to PHP but loving it - its fantastic isnt it (reminds me a
      > lot of BASIC on steroids)
      >
      > my question is this
      >
      > how do i call a function from a button using php??[/color]

      You could call a PHP script using

      <form action='phpscri pt.php' method='post'>
      <input type='hidden' name='varname' value='somethin g' />
      <input type='text' name='uservarna me' />
      <input type='submit' value='click me' />
      </form>

      and then, in phpscript.php you can get the value of the hidden field by
      referring to $_POST['varname'], and you can see the value that the user
      typed into the text field by refferring to $_POST['uservarname'].

      E.g.

      echo "<p>Hello there. You typed ".$_POST['uservarname']."</p>";

      That will cause things to happen when a user presses a form submission
      button on a PHP script, and you can add the value of the POST variables
      to a database, or vary the output of the script using if statements
      based on the variables.

      However, Savut is right. You may be thinking of instant response without
      loading another PHP page. That is client-side scripting, using, most
      often, the hideous JavaScript. JavaScript is utterly foul. Avoid it at
      all costs. If you must have pretty, irritating, 'interactive' bits and
      pieces on your site, think about using Flash. It costs money (boo!) but
      at least it is a fixed standard (due to monopoly, albeit) and it works.
      JavaScript makes even the most expensive corporate pages fail and look
      poorly produced.
      --
      Bob
      London, UK
      echo Mail fefsensmrrjyahe eoceoq\! | tr "jefroq\!" "@obe.uk"

      Comment

      Working...