Jump to content

Recommended Posts

I have the following code in a html page and I need to know how to code the

line starting <a href="events.php"....... to get it to work rather than call the onclick="submit_click() on the line above.

The submit_click is obviously a JavaScript function that I do not want to run when the Back button is clicked.

<input type=button value="Update" onclick="submit_click()">
<a href="events.php?EventID=0"><BUTTON TYPE="submit">Back</BUTTON></a>

Link to comment
https://forums.phpfreaks.com/topic/157228-script-called-when-it-is-not-needed/
Share on other sites

Well it does that already as you can see. The back button wouldn't trigger the JavaScript again. Does your PHP page redirect the user after it finishes its task? If so, then the back button goes back to the PHP page so it seems like the UPDATE button got ran again when really it didn't. An onclick function doesn't execute itself.

 

Can you explain more about the issue if the above-mentioned is not the case?

Yesterday I watched a user click the Back button only to end up getting the database updated.

Just as if they had clicked the Update button.

I checked the database before the click of the Back button & after and the record had been altered.

No, it would take them back to the PHP page. o.O

 

Example -

1. I'm on index.php and I click submit.

2. The form redirect me to process.php that inserts data to the DB.

3. process.php then redirects me back to index.php

 

If I press the back button after #3, I go back to #2, which runs the script again!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.