Jump to content

Form Input Submit Sends $_Get Request


nodirtyrockstar

Recommended Posts

I think I know the answer to this, but am hoping someone can help me.

 

Here is the button code:

 

<form action='writing.php' method='get'><input type='submit' class='sbmt' value='Journalism' name='lnk' /></form>

 

I want the button value to be "Journalism," but I would like it if the text sent in the $_GET request was shortened to four letters, for example 'jour'. I have other links like this one that have spaces in the text and I don't want that in my links.

 

My goal is to have a link that loads a new script and specifies a single four letter variable. I could use $_POST, but thought I would check with the experts and see if anyone had a suggestion that would work given the current set up.

 

Can anyone think of a way to make that happen?

Link to comment
https://forums.phpfreaks.com/topic/271520-form-input-submit-sends-_get-request/
Share on other sites

You'd need to use a JS that intercepted the POST, and rewrote the value.

Though, that said I don't see how this could ever be considered a good thing to do. You're only adding complexity to the whole process, and making it a lot more error prone. What happens if someone has deactivated, or cannot run JS, for example?

 

Far better to handle this on the server-side, and leave the URL as is, if you ask me.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.