Romulus Romulus - 3 months ago 7
PHP Question

PHP, given two inputs, make a link

I want to make a we page with 2 inputs. The user enters "John" and "Smith" into the inputs and clicks submit.

I want the submit to act like a link that looks like http://www.example.com/Smith/John

Is this possible?

Answer

At a very basic level, you can use the header() function and the get/post variables from the form submission like so:

header('Location: http://www.example.com/'.$_POST["input1"].'/'.$_POST["input2"]);

This will redirect the user to http://www.example.com/Smith/John upon submission.