Skip to content
Advertisement

Query string keeps appending but it shouldn’t

So my problem is when i send an email with a link to reset the password the query string gets appended each time. For example:

99cb65f44c7acf7f80610e92358ca7ce006b852fb9d7be716154c0fe5a954867b87a4b281a7b42f5208dbbbac0a6d3de7444575b41b6a307a2fdd00e3b6d2cae <= First query string as i want to have it

Then when i send a new email with a new token the variable will append the old value to the new one like this:

350527f600af41b3333ac73b0cab8592ad36d6cf57556e6e8dfe8d7f1640345503c98ce691651d1b8e7c85ab9fd963efda1a0b5c754abc2855f43e5d11ffd2ab99cb65f44c7acf7f80610e92358ca7ce006b852fb9d7be716154c0fe5a954867b87a4b281a7b42f5208dbbbac0a6d3de7444575b41b6a307a2fdd00e3b6d2cae <= Second query string that is wrong and shouldnt get appended

And this continues all the time.

So here is my html form:

JavaScript

Now when I press the search button it will get through an ajax. Thats the ajax code:

JavaScript

After that it will go to the php file with this code:

JavaScript

So now you see there the $hashed variable. When i echo it, it gives me right optut that i want to have (example at the top). But when i send again an email the variable will append the previous value to the new one and the query string will get longer and longer and becouse of the appending i cant find the value in my mysql database. I checked also my PasswordReset.html file but there is nothing wrong with it.

Advertisement

Answer

So what’s happening is you’ve got PasswordReset.html that presumably has some HTML like

JavaScript

You’re then overwriting that to include a link so it ends up something like

JavaScript

And then next time you do this, you then do the same replace, and rewrite the file, so each time you’re going to be adding the hash, and possibly duplicating the link (without seeing exactly what PasswordReset.html is, and what you’re inserting for the link, it’s hard to diagnose exactly).

Stop rewriting the file each time, you’ve already got the content you need in your variable $f. Instead of

JavaScript

do

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement