0

userfile.php:

<form action="userrename.php" method="get">
      <input type="hidden" name="rename" value="<?= $filecode?>">
      <input type="submit" name="rename" id="bdelete" value="Rename"><br><br>
</form>

When I click rename button it is get: userrename.php?rename=pev8nERsJolwrCHyfQZujI1QHMDQHQX6V0ZMtQhsDi1aRgPeJsR&rename=rename

username.php:

<?php 
if(empty($_GET['rename'])) 
    echo "No GET variables"; 
else 
    echo $_GET['rename']; //here result is : rename
?> 

I must get only this pev8nERsJolwrCHyfQZujI1QHMDQHQX6V0ZMtQhsDi1aRgPeJsR not rename in if statement. How I can do that any one has idei or know I am confused about that

3 Answers 3

4

remove name of

<input type="submit" name="rename" id="bdelete" value="Rename">

or change its name to name="xxxx"

Sign up to request clarification or add additional context in comments.

Comments

1

Both your input for elements use same name (name="rename"), easiest solution is to change name of your submit input. If you have only 1 submit button on your form you can just remove the name attribute completely. Only elements with a name attribute will have their values passed when submitting a form, so if you remove it it is still a valid HTML and it's value won't be submitted..

Comments

0

You can use following to have the filecode in GET and the rename value in POST:

<form action="userrename.php?rename=<?= $filecode?>" method="POST">
     <input type="submit" name="rename" id="bdelete" value="Rename"><br><br>
</form>

1 Comment

The reason the value is not coming through is that the hidden input and the submit button have the same name! You are circumventing it by creating both a GET and a POST value of the same name - that's not good! Especially if the name of the submit button doesn't matter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.