code_noob
code_noob

Reputation: 9

Passing a variable inside a button in PHP

I'm trying to pass a variable in a back button, I'm trying to pass back the value from the previous form. Is the format I use correct to pass a variable inside a button in PHP?

<?php
    if (isset($_GET['id']))
    {
        $id = $_GET['id'];
        strval($id);

        echo "<a name='btn_edit' href=\"view_order.php?id='$id'\">Back</a>";
    }
?>

is this the correct format

Upvotes: 1

Views: 34

Answers (1)

Faesal
Faesal

Reputation: 823

Try this:

echo "<a name='btn_edit' href=\"view_order.php?id={$id}\">Back</a>";

Upvotes: 1

Related Questions