Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Can I set $_GET[] without "Submit"?

Can I set $_GET[] without "Submit"?

Can I set $_GET[] without "Submit"?

Hi everyone,
I have a form in "test.php" which I want to process in "test1.php".
test.php is the following:


<!DOCTYPE html>
  <title>Update Records In MYSQL Database Using PHP</title>
  <!--connecting to database-->
      while($row = mysqli_fetch_array($records))
        echo "<tr><form action = 'test1.php' method = 'GET'>";
        echo "<td><input type = 'text' name = 'mkt_id' value = '".$row['id']."'></td>";
        echo "<td><input type = 'text' name = 'mkt_name' value = '".$row['name']."'></td>";
        echo "<td><a href='test1.php?edit_task=".$row['id']."'>edit</a></td>";
        echo "</form></tr>";
I can change the data in test's text boxes as I wish but do the changes take place?
Because "test1.php" when activated by clicking the link, shows the original values !


  echo $_GET["edit_task"];
I think that if I sent data wherby a "Submit" button' changes would take place but I try to do it without a Submit button.
Is that possible ? How?
Thanks !

RE: Can I set $_GET[] without "Submit"?

I see, a continuation. Good idea to start a new thread, though.

You have to understand your browser does not know anything about the PHP code that created the HTML it received, so the link you se in your PHP code, that both the link you create with the edit_taks URL parameter and the input named 'mkt_id' get their initial value from $row]id].

But that $row]id}is a PHP variable. The browser doesn't get hands on the PHP process and its memory, PHP ended already, it has generated the HTML code that has some specific value , eg 1 put into both places, so your input element starts off as <input type = 'text' name = 'mkt_id' value = '1'> and the link href attribute is as in <a href='test1.php?edit_task=1'>edit</a>.

The browser gets the 1 in both places, but just like two letters e in any text. There is no relation or dependency or link or binding between these two 1s. What you edit in HTML is the value of the input element, and only that value, you don't change the URL parameter at the same time just because that 1 once was in a PHP variable not at all existing an more.

And that's why I said in your other thread434-1789092: PHP Sending parameter to sub procedure a link within a form that targets another script is unusual and unintuitive.
All you want is the edited values and so you don't need a link the user clicks on, you need a submit button. And you define the HTML form action to call test1.php if you first want to keep the code of generating the form and processing the edited values separated.

What you experience and haven't wrapped your head around yet is that the server side PHP script generating HTML and the browser rendering it run sequentially and not at the same time and totally independent from each other. The PHP code has ended and the initial request of test.php is done when the HTML form is shown.

Bye, Olaf.

Olaf Doschke Software Engineering

RE: Can I set $_GET[] without "Submit"?

Thank you so much Olaf for allocating of your time to make things clearer for me.
I'll do as you suggested.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close