开发者

Sending a review via the url

I have a form that is on a PHP Page and consists of 2 elements.

and a submit button.

I want to place the content of these two into the URL, how do I do this?

An example would be:

example.php?rating=4&comment=asdasdasda%20asdasdas%20

The form is:

   <form action="" method="get"> 
        <label>Rating:</label> 
        <select class="form_input"> 
            <option value="1">1</option> 
            <option value="2">2</option> 
            <option value="3">3</option> 
            <option value="4">4</option> 
            <option value="5">5</option> 
        </select><br /> 
        <label>Comments:</label> 
        <textarea class="form_textarea"></textarea> 
        <input type="submit" class="form_submit_right" value="Submit" /> 
        </form> 


If you want to put the values that you entered into the drop-down and the text input into the URL like ?dropdown_name=dropdown_value&textbox_name=textbox_value then you need to specify GET as the form method in your form opening tag:

<form action="" method="get">
   ...
</form>

EDIT: The reason the form isn't working if because your controls (the select and textarea) need to have name attributes. The name defines the key in the key=value pair.

Your form should look like:

<form action="" method="get"> 
    <label>Rating:</label> 
    <select name="rating" class="form_input"> 
        <option value="1">1</option> 
        <option value="2">2</option> 
        <option value="3">3</option> 
        <option value="4">4</option> 
        <option value="5">5</option> 
    </select><br /> 
    <label>Comments:</label> 
    <textarea name="comment" class="form_textarea"></textarea> 
    <input type="submit" class="form_submit_right" value="Submit" /> 
</form>


Send it with the GET method, like

<form action="{$PHP_SELF}" method="get">

Or you can use a bit of Javascript to dynamically create the link.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜