Form Redirect | Sololearn: Learn to code for FREE!

+3

Form Redirect

Sorry for the dumb question, but i wanna know that, I'm creating a form. It has a submit button too. So i wanna to redirect to a specific website on submit. Elaboration ~~~ like if i submit <#GYJ20QVJ>.It'll redirect to <clashforever.online/coc_cf/clan.php?tag=#GYJ20QVJ>. Or if i type <#Y0JCGJUU> In put, and on submit it'll redirect to <clashforever.online/coc_cf/clan.php?tag=#Y0JCGJUU>..help me please with a example.

11/14/2020 5:39:27 AM

simple boii

12 Answers

New Answer

+3

🙂King😉 Check this example https://code.sololearn.com/WcYSaxO4YG25/?ref=app You'll have to modify it with something like this <form action="https://clashforever.online/coc_cf/clan.php" method="GET"> <input type="text "name="tag" value="#GYJ20QVJ"> <button type="submit">Send</button> </form>

+3

Thank you very very much... You're very helpful🙂😄😄

+2

Didn't get that from, can you please show that with a example here. It'll be helpful🙂☺️Tibor Santa

+2

Show your code, please. It would be easier to debug.

+2

You can remove the value (it is just a default that the user can override) But the name atrribute is important

+1

Here is a full guide to forms. https://developer.mozilla.org/en-US/docs/Learn/Forms/Sending_and_retrieving_form_data Check the example about the GET method. It should give you an idea, how to set the attributes of the form and input fields, that is similar to your question.

+1

Your code is semantically incorrect, and you did not even follow the example I gave you. Your opening FORM tag is missing and it should have an action attribute pointing to the root url, and method=GET Then you should probably get rid of the javascript part, form submit works fine without any fancy JS too. And I suggest to use the <button> tag instead of <input> at the end. Just check my example again.

+1

Ok i followed you example. See here https://code.sololearn.com/WaIASr94EaJ4/?ref=app Tibor Santa . Read the comment on the code to understand what i meant and enter the tag "GYJ20QVJ" too.

+1

You are almost there. Some small changes: <form action="http://clashforever.xyz/coc_cf/clan.php" method="GET"> <input type="text" name="tag" value="GYJ20QVJ"> <button type="submit">Submit</button> </form> Try it.

+1

Tibor Santa yeah right, but you've entered a value there. But i want that if anyone enters any value in the "input". Here i have to change value in the code everytime...... How to avoid this?

0

Tibor Santa i see that the action url is <http://clashforever.xyz/clan.php?tag=<{The input entered in the form}>. It's correct, but when I'm redirecting it, it's included a extra "+", i mean the redirecting url becomes <http://clashforever.xyz/coc_cf/clan.php?tag=<{entered input} +>. So i can't understand why it's including the extra "+", the url is becoming incorrect of this🤔. Please help if you can☺️

0

https://code.sololearn.com/WZmmWTyeniP4/?ref=app Here it is.