Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
947 views
in Technique[技术] by (71.8m points)

php - Form Submit URL Formatting

I have a form which when submitted goes to the url "signup.php?username=xx" where xx is an input field. Instead of this I was wondering if I could get it to go to the following url "signup/xx" where xx is taken from the input field.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to use Javascript and some type of .htaccess for that. But why don't you use POST instead of GET?

I don't want singup?username=sawny&password=1234 in my history.

EDIT:

I had done something like this:

$(document).ready(function() {
    $("submit[name='foo']").live('submit', function() {

        var usr = $("form input[name='user']").val();
        $("form input[name='user']").remove(); //Else it will be singup/usr?user=

        $("form[name='bar']").attr("action", "singup/"+ usr);
    });
});

and then the regexp @zero posted in a .htaccess file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.7k users

...