How can I pass multiple values ​​to another page in a url

As the title explains, how can I pass multiple values ​​to the antoher page in the url. I've used the method before, but with only one value, I can't get it to work with multiple. I know you should place the ampersand and glue the variables together.

Currently this is my code:

<a href='update.php?del=$id?name=$loginname' class='sexybutton'>Print Bon</a>

      

I am getting $ id, however I cannot get $ loginname for some reason.

This is the code i am using to get data from url

include 'dbconnect.php';

     // Get name
     $loginname = $_GET['name'];
     $sql1 = "SELECT * FROM users WHERE name='$name' ";    
     if ($conn->query($sql1) === TRUE) {   
    {       
    $name = $row['name'];
    echo $name; //Outputs: 2
     }

     // Get ID
     $id = $_GET['del'];
     // Update database
     $sql = "UPDATE wp_wppizza_orders SET printed='1' WHERE id='$id' ";
     if ($conn->query($sql) === TRUE) {
     echo " ";
     } else {
     echo "Error updating record: " . $conn->error;
}

      

As I mentioned, ID GET works, but name GET doesn't work.

it gives 3 separate warnings

Note: Undefined index: name in C: \ xampp \ htdocs \ login \ update.php on line 5

Note: Undefined variable: name in C: \ xampp \ htdocs \ login \ update.php on line 6

Warning: mysql_fetch_array () expects parameter 1 to be resource, boolean specified in C: \ xampp \ htdocs \ login \ update.php on line 7

+3


source to share


2 answers


update.php?del=$id?name=$loginname

      

to



update.php?del=$id&name=$loginname

      

The first parameter is checked ?

, all the following parameters are separated by the symbol&

+4


source


You only need to change one line code



<a href='update.php?del=$id&name=$loginname' class='sexybutton'>Print Bon</a>

      

+1


source







All Articles