how to call a function when somebody click a link?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yangsuli@gmail.com

    how to call a function when somebody click a link?

    i want to creat a link
    when somebody click the link
    the php script calls a function,then display itself :)

    i have tried
    <a href=<? funtion(); echo=$_server['php_self'] ?>text</a>
    but it will call the function whether i click the link


    then i tried this (using forms)
    <form action="<?php function(); echo "<script>"; echo
    "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
    <input type="submit" value="text" /></form>
    but it didnot work either.
    my browser said there were parse errors,T_STRING expected or
    something....:(


    now i am thinking using a flag,say,$funct ioncall,
    href=$_server[request_url]&functioncal l=1
    then if functioncall==1 ,call that function
    but is it right?
    is there some way simple to do that?


    any suggestion is appreciated :)

  • Mateusz Markowski

    #2
    Re: how to call a function when somebody click a link?


    yangsuli@gmail. com napisal(a):
    i want to creat a link
    when somebody click the link
    the php script calls a function,then display itself :)
    >
    i have tried
    <a href=<? funtion(); echo=$_server['php_self'] ?>text</a>
    but it will call the function whether i click the link
    >
    >
    then i tried this (using forms)
    <form action="<?php function(); echo "<script>"; echo
    "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
    <input type="submit" value="text" /></form>
    but it didnot work either.
    my browser said there were parse errors,T_STRING expected or
    something....:(
    >
    >
    now i am thinking using a flag,say,$funct ioncall,
    href=$_server[request_url]&functioncal l=1
    then if functioncall==1 ,call that function
    but is it right?
    is there some way simple to do that?
    >
    PHP works on a server, not in your browser, so it can't just call
    function when you click a link. You have to send a request to the
    server which will cause your script to call this function. Your last
    example is good way to do it. So you have such link:
    script.php?call =helloworld

    and in your file script.php such code:

    if ($_GET['call'] == 'helloworld') {
    echo 'Hello world!';
    }

    Then after clicking the link your browser sends a request, PHP decides
    what to do, then server sends you a appropriate response.

    Comment

    • yangsuli@gmail.com

      #3
      Re: how to call a function when somebody click a link?

      the problem is that i donnot want some script.php
      i want to redirect the users back on the page they were just on,with
      calling a function in advance :)
      you think the flag thing is the best way to do it?

      Mateusz Markowski wrote:
      yangsuli@gmail. com napisal(a):
      i want to creat a link
      when somebody click the link
      the php script calls a function,then display itself :)

      i have tried
      <a href=<? funtion(); echo=$_server['php_self'] ?>text</a>
      but it will call the function whether i click the link


      then i tried this (using forms)
      <form action="<?php function(); echo "<script>"; echo
      "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
      <input type="submit" value="text" /></form>
      but it didnot work either.
      my browser said there were parse errors,T_STRING expected or
      something....:(


      now i am thinking using a flag,say,$funct ioncall,
      href=$_server[request_url]&functioncal l=1
      then if functioncall==1 ,call that function
      but is it right?
      is there some way simple to do that?
      >
      PHP works on a server, not in your browser, so it can't just call
      function when you click a link. You have to send a request to the
      server which will cause your script to call this function. Your last
      example is good way to do it. So you have such link:
      script.php?call =helloworld
      >
      and in your file script.php such code:
      >
      if ($_GET['call'] == 'helloworld') {
      echo 'Hello world!';
      }
      >
      Then after clicking the link your browser sends a request, PHP decides
      what to do, then server sends you a appropriate response.

      Comment

      • Mateusz Markowski

        #4
        Re: how to call a function when somebody click a link?

        Yes, I think so.

        yangsuli@gmail. com napisal(a):
        the problem is that i donnot want some script.php
        i want to redirect the users back on the page they were just on,with
        calling a function in advance :)
        you think the flag thing is the best way to do it?
        >
        Mateusz Markowski wrote:
        yangsuli@gmail. com napisal(a):
        i want to creat a link
        when somebody click the link
        the php script calls a function,then display itself :)
        >
        i have tried
        <a href=<? funtion(); echo=$_server['php_self'] ?>text</a>
        but it will call the function whether i click the link
        >
        >
        then i tried this (using forms)
        <form action="<?php function(); echo "<script>"; echo
        "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
        <input type="submit" value="text" /></form>
        but it didnot work either.
        my browser said there were parse errors,T_STRING expected or
        something....:(
        >
        >
        now i am thinking using a flag,say,$funct ioncall,
        href=$_server[request_url]&functioncal l=1
        then if functioncall==1 ,call that function
        but is it right?
        is there some way simple to do that?
        >
        PHP works on a server, not in your browser, so it can't just call
        function when you click a link. You have to send a request to the
        server which will cause your script to call this function. Your last
        example is good way to do it. So you have such link:
        script.php?call =helloworld

        and in your file script.php such code:

        if ($_GET['call'] == 'helloworld') {
        echo 'Hello world!';
        }

        Then after clicking the link your browser sends a request, PHP decides
        what to do, then server sends you a appropriate response.

        Comment

        • yangsuli@gmail.com

          #5
          Re: how to call a function when somebody click a link?

          but why the second way didnot work out.......
          i donot get where did the parse error come from :(
          55555555555

          Mateusz Markowski wrote:
          Yes, I think so.
          >
          yangsuli@gmail. com napisal(a):
          the problem is that i donnot want some script.php
          i want to redirect the users back on the page they were just on,with
          calling a function in advance :)
          you think the flag thing is the best way to do it?

          Mateusz Markowski wrote:
          yangsuli@gmail. com napisal(a):
          i want to creat a link
          when somebody click the link
          the php script calls a function,then display itself :)

          i have tried
          <a href=<? funtion(); echo=$_server['php_self'] ?>text</a>
          but it will call the function whether i click the link


          then i tried this (using forms)
          <form action="<?php function(); echo "<script>"; echo
          "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
          <input type="submit" value="text" /></form>
          but it didnot work either.
          my browser said there were parse errors,T_STRING expected or
          something....:(


          now i am thinking using a flag,say,$funct ioncall,
          href=$_server[request_url]&functioncal l=1
          then if functioncall==1 ,call that function
          but is it right?
          is there some way simple to do that?

          >
          PHP works on a server, not in your browser, so it can't just call
          function when you click a link. You have to send a request to the
          server which will cause your script to call this function. Your last
          example is good way to do it. So you have such link:
          script.php?call =helloworld
          >
          and in your file script.php such code:
          >
          if ($_GET['call'] == 'helloworld') {
          echo 'Hello world!';
          }
          >
          Then after clicking the link your browser sends a request, PHP decides
          what to do, then server sends you a appropriate response.

          Comment

          • Mateusz Markowski

            #6
            Re: how to call a function when somebody click a link?

            Paste the code that you think may give parse error.

            yangsuli@gmail. com napisal(a):
            but why the second way didnot work out.......
            i donot get where did the parse error come from :(
            55555555555
            >
            Mateusz Markowski wrote:
            Yes, I think so.

            yangsuli@gmail. com napisal(a):
            the problem is that i donnot want some script.php
            i want to redirect the users back on the page they were just on,with
            calling a function in advance :)
            you think the flag thing is the best way to do it?
            >
            Mateusz Markowski wrote:
            yangsuli@gmail. com napisal(a):
            i want to creat a link
            when somebody click the link
            the php script calls a function,then display itself :)
            >
            i have tried
            <a href=<? funtion(); echo=$_server['php_self'] ?>text</a>
            but it will call the function whether i click the link
            >
            >
            then i tried this (using forms)
            <form action="<?php function(); echo "<script>"; echo
            "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
            <input type="submit" value="text" /></form>
            but it didnot work either.
            my browser said there were parse errors,T_STRING expected or
            something....:(
            >
            >
            now i am thinking using a flag,say,$funct ioncall,
            href=$_server[request_url]&functioncal l=1
            then if functioncall==1 ,call that function
            but is it right?
            is there some way simple to do that?
            >

            PHP works on a server, not in your browser, so it can't just call
            function when you click a link. You have to send a request to the
            server which will cause your script to call this function. Your last
            example is good way to do it. So you have such link:
            script.php?call =helloworld

            and in your file script.php such code:

            if ($_GET['call'] == 'helloworld') {
            echo 'Hello world!';
            }

            Then after clicking the link your browser sends a request, PHP decides
            what to do, then server sends you a appropriate response.

            Comment

            • yangsuli@gmail.com

              #7
              Re: how to call a function when somebody click a link?

              the code is like this
              <form action="<?php dec_msgnum($coo kie["usernum"]); echo "<script>";
              echo "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
              <input type="submit" value="忽略" /></form>

              i also tried
              <form action="<?php dec_msgnum($coo kie["usernum"]);
              header(default: $_SERVER['PHP_SELF'];';?>"<input type="submit"
              value="忽略" /></form>

              it didnot work either :(

              but this works perfectly well
              <form action="<?php dec_msgnum($coo kie["usernum"]); ';?>"<input
              type="submit" value="忽略" /></form>

              do you think it is caused by some arguements missing?( may be it shoule
              be $_SERVER['REQUEST_URI'] or $_SERVER['PHP_SELF']?xxxx=xxxxxx or
              something)
              Mateusz Markowski wrote:
              Paste the code that you think may give parse error.
              >
              yangsuli@gmail. com napisal(a):
              but why the second way didnot work out.......
              i donot get where did the parse error come from :(
              55555555555

              Mateusz Markowski wrote:
              Yes, I think so.
              >
              yangsuli@gmail. com napisal(a):
              the problem is that i donnot want some script.php
              i want to redirect the users back on the page they were just on,with
              calling a function in advance :)
              you think the flag thing is the best way to do it?

              Mateusz Markowski wrote:
              yangsuli@gmail. com napisal(a):
              i want to creat a link
              when somebody click the link
              the php script calls a function,then display itself :)

              i have tried
              <a href=<? funtion(); echo=$_server['php_self'] ?>text</a>
              but it will call the function whether i click the link


              then i tried this (using forms)
              <form action="<?php function(); echo "<script>"; echo
              "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
              <input type="submit" value="text" /></form>
              but it didnot work either.
              my browser said there were parse errors,T_STRING expected or
              something....:(


              now i am thinking using a flag,say,$funct ioncall,
              href=$_server[request_url]&functioncal l=1
              then if functioncall==1 ,call that function
              but is it right?
              is there some way simple to do that?

              >
              PHP works on a server, not in your browser, so it can't just call
              function when you click a link. You have to send a request to the
              server which will cause your script to call this function. Your last
              example is good way to do it. So you have such link:
              script.php?call =helloworld
              >
              and in your file script.php such code:
              >
              if ($_GET['call'] == 'helloworld') {
              echo 'Hello world!';
              }
              >
              Then after clicking the link your browser sends a request, PHP decides
              what to do, then server sends you a appropriate response.

              Comment

              • Mateusz Markowski

                #8
                Re: how to call a function when somebody click a link?

                You should write:
                echo "window.locatio n.href={$_SERVE R['PHP_SELF']}";

                But it won't work in your browser. Why do you want to put script tags
                as action?

                yangsuli@gmail. com napisał(a):
                the code is like this
                <form action="<?php dec_msgnum($coo kie["usernum"]); echo "<script>";
                echo "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
                <input type="submit" value="忽略" /></form>
                >
                i also tried
                <form action="<?php dec_msgnum($coo kie["usernum"]);
                header(default: $_SERVER['PHP_SELF'];';?>"<input type="submit"
                value="忽略" /></form>
                >
                it didnot work either :(
                >
                but this works perfectly well
                <form action="<?php dec_msgnum($coo kie["usernum"]); ';?>"<input
                type="submit" value="忽略" /></form>
                >
                do you think it is caused by some arguements missing?( may be it shoule
                be $_SERVER['REQUEST_URI'] or $_SERVER['PHP_SELF']?xxxx=xxxxxx or
                something)
                Mateusz Markowski wrote:
                Paste the code that you think may give parse error.

                yangsuli@gmail. com napisal(a):
                but why the second way didnot work out.......
                i donot get where did the parse error come from :(
                55555555555
                >
                Mateusz Markowski wrote:
                Yes, I think so.

                yangsuli@gmail. com napisal(a):
                the problem is that i donnot want some script.php
                i want to redirect the users back on the page they were just on,with
                calling a function in advance :)
                you think the flag thing is the best way to do it?
                >
                Mateusz Markowski wrote:
                yangsuli@gmail. com napisal(a):
                i want to creat a link
                when somebody click the link
                the php script calls a function,then display itself :)
                >
                i have tried
                <a href=<? funtion(); echo=$_server['php_self'] ?>text</a>
                but it will call the function whether i click the link
                >
                >
                then i tried this (using forms)
                <form action="<?php function(); echo "<script>"; echo
                "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
                <input type="submit" value="text" /></form>
                but it didnot work either.
                my browser said there were parse errors,T_STRING expected or
                something....:(
                >
                >
                now i am thinking using a flag,say,$funct ioncall,
                href=$_server[request_url]&functioncal l=1
                then if functioncall==1 ,call that function
                but is it right?
                is there some way simple to do that?
                >

                PHP works on a server, not in your browser, so it can't just call
                function when you click a link. You have to send a request to the
                server which will cause your script to call this function. Yourlast
                example is good way to do it. So you have such link:
                script.php?call =helloworld

                and in your file script.php such code:

                if ($_GET['call'] == 'helloworld') {
                echo 'Hello world!';
                }

                Then after clicking the link your browser sends a request, PHP decides
                what to do, then server sends you a appropriate response.

                Comment

                • yangsuli@gmail.com

                  #9
                  Re: how to call a function when somebody click a link?

                  so i missed {}
                  is that the problem?

                  the browser will recognize it as a javascript and display it only by
                  the script tag.......
                  you donot think i shoud put the script tag?

                  errrrr
                  why the header() didnot work either?
                  Mateusz Markowski wrote:
                  You should write:
                  echo "window.locatio n.href={$_SERVE R['PHP_SELF']}";
                  >
                  But it won't work in your browser. Why do you want to put script tags
                  as action?
                  >
                  yangsuli@gmail. com napisał(a):
                  the code is like this
                  <form action="<?php dec_msgnum($coo kie["usernum"]); echo "<script>";
                  echo "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
                  <input type="submit" value="忽略" /></form>

                  i also tried
                  <form action="<?php dec_msgnum($coo kie["usernum"]);
                  header(default: $_SERVER['PHP_SELF'];';?>"<input type="submit"
                  value="忽略" /></form>

                  it didnot work either :(

                  but this works perfectly well
                  <form action="<?php dec_msgnum($coo kie["usernum"]); ';?>"<input
                  type="submit" value="忽略" /></form>

                  do you think it is caused by some arguements missing?( may be it shoule
                  be $_SERVER['REQUEST_URI'] or $_SERVER['PHP_SELF']?xxxx=xxxxxx or
                  something)
                  Mateusz Markowski wrote:
                  Paste the code that you think may give parse error.
                  >
                  yangsuli@gmail. com napisal(a):
                  but why the second way didnot work out.......
                  i donot get where did the parse error come from :(
                  55555555555

                  Mateusz Markowski wrote:
                  Yes, I think so.
                  >
                  yangsuli@gmail. com napisal(a):
                  the problem is that i donnot want some script.php
                  i want to redirect the users back on the page they were just on,with
                  calling a function in advance :)
                  you think the flag thing is the best way to do it?

                  Mateusz Markowski wrote:
                  yangsuli@gmail. com napisal(a):
                  i want to creat a link
                  when somebody click the link
                  the php script calls a function,then display itself :)

                  i have tried
                  <a href=<? funtion(); echo=$_server['php_self'] ?>text</a>
                  but it will call the function whether i click the link


                  then i tried this (using forms)
                  <form action="<?php function(); echo "<script>"; echo
                  "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
                  <input type="submit" value="text" /></form>
                  but it didnot work either.
                  my browser said there were parse errors,T_STRING expected or
                  something....:(


                  now i am thinking using a flag,say,$funct ioncall,
                  href=$_server[request_url]&functioncal l=1
                  then if functioncall==1 ,call that function
                  but is it right?
                  is there some way simple to do that?

                  >
                  PHP works on a server, not in your browser, so it can't just call
                  function when you click a link. You have to send a request tothe
                  server which will cause your script to call this function. Your last
                  example is good way to do it. So you have such link:
                  script.php?call =helloworld
                  >
                  and in your file script.php such code:
                  >
                  if ($_GET['call'] == 'helloworld') {
                  echo 'Hello world!';
                  }
                  >
                  Then after clicking the link your browser sends a request, PHP decides
                  what to do, then server sends you a appropriate response.

                  Comment

                  • no@emails.thx

                    #10
                    Re: how to call a function when somebody click a link?

                    [Taking a step back]

                    I think it'd help if the OP says why they want to do all this. If I
                    ever have trouble doing something I usually find that I am trying to
                    fit a square peg in a round hole and I need to approach the problem in
                    a different way.

                    But, given what we know, it looks like the OP needs one HTML page with
                    some PHP at the top. Like:

                    HTML headers
                    <?php
                    if (isset($_REQUES T['dofunction'])) {
                    function();
                    }
                    ?>
                    rest of the HTML page including:
                    <a href="<?php echo $_SERVER['PHP_SELF'].'?dofunction'; ?>">click
                    here</a>




                    On 4 Nov 2006 02:45:15 -0800, "Mateusz Markowski"
                    <mateusz@bsdmai l.orgwrote:
                    >Paste the code that you think may give parse error.
                    >
                    >yangsuli@gmail .com napisal(a):
                    >but why the second way didnot work out.......
                    >i donot get where did the parse error come from :(
                    >55555555555
                    >>
                    >Mateusz Markowski wrote:
                    Yes, I think so.
                    >
                    yangsuli@gmail. com napisal(a):
                    the problem is that i donnot want some script.php
                    i want to redirect the users back on the page they were just on,with
                    calling a function in advance :)
                    you think the flag thing is the best way to do it?
                    >
                    Mateusz Markowski wrote:
                    yangsuli@gmail. com napisal(a):
                    i want to creat a link
                    when somebody click the link
                    the php script calls a function,then display itself :)
                    >
                    i have tried
                    <a href=<? funtion(); echo=$_server['php_self'] ?>text</a>
                    but it will call the function whether i click the link
                    >
                    >
                    then i tried this (using forms)
                    <form action="<?php function(); echo "<script>"; echo
                    "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
                    <input type="submit" value="text" /></form>
                    but it didnot work either.
                    my browser said there were parse errors,T_STRING expected or
                    something....:(
                    >
                    >
                    now i am thinking using a flag,say,$funct ioncall,
                    href=$_server[request_url]&functioncal l=1
                    then if functioncall==1 ,call that function
                    but is it right?
                    is there some way simple to do that?
                    >

                    PHP works on a server, not in your browser, so it can't just call
                    function when you click a link. You have to send a request to the
                    server which will cause your script to call this function. Your last
                    example is good way to do it. So you have such link:
                    script.php?call =helloworld

                    and in your file script.php such code:

                    if ($_GET['call'] == 'helloworld') {
                    echo 'Hello world!';
                    }

                    Then after clicking the link your browser sends a request, PHP decides
                    what to do, then server sends you a appropriate response.

                    Comment

                    • Mateusz Markowski

                      #11
                      Re: how to call a function when somebody click a link?

                      You are trying to do something very simple in a quite convoluted way.
                      You want to give user a link which goes to page that they had visited
                      before visiting other page. Try this:

                      //page that client visited before
                      $page = $_SERVER['HTTP_REFERER']; //let's assume that it's:


                      //we want user to go on this page and to add a flag which cause PHP to
                      call function
                      $newurl = $page . '?call=ourfunct ion';// result is:


                      //we send a link
                      echo '<a href="'.$newurl .'">click here</a>';

                      Is this what you want to do?


                      yangsuli@gmail. com napisał(a):
                      so i missed {}
                      is that the problem?
                      >
                      the browser will recognize it as a javascript and display it only by
                      the script tag.......
                      you donot think i shoud put the script tag?
                      >
                      errrrr
                      why the header() didnot work either?
                      Header in your example doesn't work becuase before callling it you have
                      already sent some data to client. But header must be called before any
                      data's been sent to client's browser.
                      Mateusz Markowski wrote:
                      You should write:
                      echo "window.locatio n.href={$_SERVE R['PHP_SELF']}";

                      But it won't work in your browser. Why do you want to put script tags
                      as action?

                      yangsuli@gmail. com napisał(a):
                      the code is like this
                      <form action="<?php dec_msgnum($coo kie["usernum"]); echo "<script>";
                      echo "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
                      <input type="submit" value="忽略" /></form>
                      >
                      i also tried
                      <form action="<?php dec_msgnum($coo kie["usernum"]);
                      header(default: $_SERVER['PHP_SELF'];';?>"<input type="submit"
                      value="忽略" /></form>
                      >
                      it didnot work either :(
                      >
                      but this works perfectly well
                      <form action="<?php dec_msgnum($coo kie["usernum"]); ';?>"<input
                      type="submit" value="忽略" /></form>
                      >
                      do you think it is caused by some arguements missing?( may be it shoule
                      be $_SERVER['REQUEST_URI'] or $_SERVER['PHP_SELF']?xxxx=xxxxxx or
                      something)
                      Mateusz Markowski wrote:
                      Paste the code that you think may give parse error.

                      yangsuli@gmail. com napisal(a):
                      but why the second way didnot work out.......
                      i donot get where did the parse error come from :(
                      55555555555
                      >
                      Mateusz Markowski wrote:
                      Yes, I think so.

                      yangsuli@gmail. com napisal(a):
                      the problem is that i donnot want some script.php
                      i want to redirect the users back on the page they were just on,with
                      calling a function in advance :)
                      you think the flag thing is the best way to do it?
                      >
                      Mateusz Markowski wrote:
                      yangsuli@gmail. com napisal(a):
                      i want to creat a link
                      when somebody click the link
                      the php script calls a function,then display itself :)
                      >
                      i have tried
                      <a href=<? funtion(); echo=$_server['php_self'] ?>text</a>
                      but it will call the function whether i click the link
                      >
                      >
                      then i tried this (using forms)
                      <form action="<?php function(); echo "<script>"; echo
                      "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
                      <input type="submit" value="text" /></form>
                      but it didnot work either.
                      my browser said there were parse errors,T_STRING expectedor
                      something....:(
                      >
                      >
                      now i am thinking using a flag,say,$funct ioncall,
                      href=$_server[request_url]&functioncal l=1
                      then if functioncall==1 ,call that function
                      but is it right?
                      is there some way simple to do that?
                      >

                      PHP works on a server, not in your browser, so it can't just call
                      function when you click a link. You have to send a request to the
                      server which will cause your script to call this function. Your last
                      example is good way to do it. So you have such link:
                      script.php?call =helloworld

                      and in your file script.php such code:

                      if ($_GET['call'] == 'helloworld') {
                      echo 'Hello world!';
                      }

                      Then after clicking the link your browser sends a request, PHP decides
                      what to do, then server sends you a appropriate response.

                      Comment

                      • yangsuli@gmail.com

                        #12
                        Re: how to call a function when somebody click a link?

                        thanks and kiss all
                        you guys help a lot....:)

                        i managed it by setting up a flag : msgignoreflag
                        when usr click the link,the href is linked to
                        $_server[request]&msgignorefl ag
                        and the php script call the function only if the flag is set :)


                        my code is like this
                        with msgignoreflag being the flag and the dec_msgnum the function i
                        would like to call
                        function print_body($nom sg = 0) {

                        global $cookie;
                        ?<body bgproperties="f ixed"<?php
                        // if(isset($_GET["msgignoref lag"]) {
                        if($_GET["msgignoref lag"]==1) {
                        dec_msgnum($coo kie["usernum"]);
                        }
                        if( $msgnum = get_msgnum($coo kie["usernum"]) && !$nomsg) {

                        $msg = get_msg($cookie["id"], $msgnum);
                        ?><table width=100% bgcolor=lightye llow>
                        <tr>
                        <td valign="top" nowrap="nowrap" width=25%><font
                        color="green">< ?php echo $msg["id"]; ?></font(<?php
                        echo ctime2($msg["time"]); ?>): </td>
                        <td align="left" valign="top" width=50%><?php echo
                        stripansi($msg["msg"]); ?></td>
                        <td align="right" valign="top" nowrap="nowrap"
                        width=15%>
                        <a href="<?php echo BBSCGI;
                        ?>/bbssndmsg.php?r eply=1&uid=<?ph p echo $msg["id"]; ?>">[回讯息]</a>
                        </td>
                        <td align="right" valign="top" nowrap="nowrap"
                        width=10%>
                        <a href="<?php echo $_SERVER['REQUEST_URI'];
                        ?>&msgignorefla g=1">[忽略]</a>
                        </td>
                        </tr></table><?php
                        }
                        }

                        thanks all you guys again
                        i appriciate your efforts to help me
                        kisssssssssss :)
                        Mateusz Markowski 写道:
                        You are trying to do something very simple in a quite convoluted way.
                        You want to give user a link which goes to page that they had visited
                        before visiting other page. Try this:
                        >
                        //page that client visited before
                        $page = $_SERVER['HTTP_REFERER']; //let's assume that it's:

                        >
                        //we want user to go on this page and to add a flag which cause PHP to
                        call function
                        $newurl = $page . '?call=ourfunct ion';// result is:

                        >
                        //we send a link
                        echo '<a href="'.$newurl .'">click here</a>';
                        >
                        Is this what you want to do?
                        >
                        >
                        yangsuli@gmail. com napisał(a):
                        so i missed {}
                        is that the problem?

                        the browser will recognize it as a javascript and display it only by
                        the script tag.......
                        you donot think i shoud put the script tag?

                        errrrr
                        why the header() didnot work either?
                        >
                        Header in your example doesn't work becuase before callling it you have
                        already sent some data to client. But header must be called before any
                        data's been sent to client's browser.
                        >
                        Mateusz Markowski wrote:
                        You should write:
                        echo "window.locatio n.href={$_SERVE R['PHP_SELF']}";
                        >
                        But it won't work in your browser. Why do you want to put script tags
                        as action?
                        >
                        yangsuli@gmail. com napisał(a):
                        the code is like this
                        <form action="<?php dec_msgnum($coo kie["usernum"]); echo "<script>";
                        echo "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
                        <input type="submit" value="忽略" /></form>

                        i also tried
                        <form action="<?php dec_msgnum($coo kie["usernum"]);
                        header(default: $_SERVER['PHP_SELF'];';?>"<input type="submit"
                        value="忽略" /></form>

                        it didnot work either :(

                        but this works perfectly well
                        <form action="<?php dec_msgnum($coo kie["usernum"]); ';?>"<input
                        type="submit" value="忽略" /></form>

                        do you think it is caused by some arguements missing?( may be it shoule
                        be $_SERVER['REQUEST_URI'] or $_SERVER['PHP_SELF']?xxxx=xxxxxx or
                        something)
                        Mateusz Markowski wrote:
                        Paste the code that you think may give parse error.
                        >
                        yangsuli@gmail. com napisal(a):
                        but why the second way didnot work out.......
                        i donot get where did the parse error come from :(
                        55555555555

                        Mateusz Markowski wrote:
                        Yes, I think so.
                        >
                        yangsuli@gmail. com napisal(a):
                        the problem is that i donnot want some script.php
                        i want to redirect the users back on the page they were just on,with
                        calling a function in advance :)
                        you think the flag thing is the best way to do it?

                        Mateusz Markowski wrote:
                        yangsuli@gmail. com napisal(a):
                        i want to creat a link
                        when somebody click the link
                        the php script calls a function,then display itself :)

                        i have tried
                        <a href=<? funtion(); echo=$_server['php_self'] ?>text</a>
                        but it will call the function whether i click the link


                        then i tried this (using forms)
                        <form action="<?php function(); echo "<script>"; echo
                        "window.locatio n.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
                        <input type="submit" value="text" /></form>
                        but it didnot work either.
                        my browser said there were parse errors,T_STRING expected or
                        something....:(


                        now i am thinking using a flag,say,$funct ioncall,
                        href=$_server[request_url]&functioncal l=1
                        then if functioncall==1 ,call that function
                        but is it right?
                        is there some way simple to do that?

                        >
                        PHP works on a server, not in your browser, so it can't just call
                        function when you click a link. You have to send a request to the
                        server which will cause your script to call this function.. Your last
                        example is good way to do it. So you have such link:
                        script.php?call =helloworld
                        >
                        and in your file script.php such code:
                        >
                        if ($_GET['call'] == 'helloworld') {
                        echo 'Hello world!';
                        }
                        >
                        Then after clicking the link your browser sends a request, PHP decides
                        what to do, then server sends you a appropriate response.

                        Comment

                        Working...