Hi,
I am trying to figure out how I can submit a form to a php page just by clicking a link...

<form action="submit.php" method="post">
<a href="SOMETHING?"><? print($myvariable); ?></a>

Hard to describe... but rather than having a submit button for the form, I would like it to submit the form by clicking the link, where the link text is a printed variable from php.

Cheers

    i use it as radio button...

    <input type='radio' name='score' value='4' onClick='this.form.submit()'/>

    you can use it as a href

    <a href="#" onClick='this.form.submit()'>Submit!</a>

      <form action="test2.php" method="post" name="the_form">
        <p>
          <input type="text" name="input" size="10" maxlength="10">
          <script type="text/javascript">
            document.write('<a href="" onclick="javascript:document.the_form.submit();return false;">Click Me<\/a>');
          </script>
          <noscript>
            <input type="submit" value="Click Me" 
      style="border:none;background-color:transparent;color:blue;text-decoration:underline">
          </noscript>
        </p>
      </form>
      

        Thank you.

        Would doing the follow work?

        <a href="test.php?variable=abc">abc</a>
        

        ... Meaning, is it possible to do something like this as an equivalent to $_POST?

        Thanks

          its name is GET

          you reach that variable, in test.php as

          $_GET["variable"]

          but if you have the chance use POST... Biggest data you could send with that, and cleaner than store data in URL.

            What? I want to call that link such that in test.php the value for "variable" becomes abc.

              If you submit that link, then in file test.php the super-global array element $_GET['variable'] will have a value of "abc".

                what you store in textfield, you will send that with POST, but a link is your submit "button"...

                you can store fix values in hidden field as well, or store that in database or Session variables..

                and store in URL site ID only, not personal data(username&password&email&mail-body)

                so i don't know what's your aim with your question.

                If its needed to store something in url,

                use the <form method="POST" action="form_to.php?variable1=1&variable2=2">
                ....

                and then you can use normal submit button

                  Basically all i want to do is generate a link in a page that will call a php page and have the value of variable become "abc" so that I can use it in other lines of that php script.

                    have you heard sessions before?

                    $_SESSION["generated_code"]="abc";

                    another page:
                    <?
                    session_start();

                    if(isset($SESSION["generated_code"]))
                    print $
                    SESSION["generated_code"]." is the generated code";
                    else
                    header("Location: code_generator.php");
                    ?>

                      As I stated above, all you need is a link to something like filename.php?var=abc and then when clicked, in script filename.php access the value via the $_GET['var'] variable. What else do you need that that does not do for you? 😕

                        Write a Reply...