Question

I tried to get 2 url parameters from this url:

http://flying-change.eu/flyingchange/detail.html?id=gXpzX09kyF&stadt=Regensburg&Checkout=true

with the $_GET and $_REQUEST method like this:

$objektid = $_GET['id'];
$stadt = $_GET['stadt'];

Now I got the following error:

Notice: Undefined index: id in /mnt/webb/a2/87/53907487/htdocs/flyingchange/src/checkout.php on line 10

Notice: Undefined index: stadt in /mnt/webb/a2/87/53907487/htdocs/flyingchange/src/checkout.php on line 11

I'm fairly new to php so I would really appreciate some help on this. I can't find the error myself.

Was it helpful?

Solution

These are not actual errors. They are just notices. You're getting these notices because there's no value assigned to them initially. A quick fix to suppress these notices is by using the mute operator. See below:

$objektid = @$_GET['id'];
$stadt = @$_GET['stadt'];

OTHER TIPS

Your page has html extension. So there is the mistake, only pages with php extension are analyzed using php... You must rewrite Your URL's to detail.php and change the extension to php. Hope it helps :).

UPDATE: In that case, you need:

/flyingchange/detail.php?id=gXpzX09kyF&stadt=Regensburg&Checkout=true

And detail.php:

<?php
    $stadt = isset($_GET['stadt']) ? $_GET['stadt'] : 'default_stadt';
    $id = isset($_GET['id']) ? $_GET['id'] : 'default_id';
    print_r($id);
    echo '<br>';
    print_r($stadt);
?>

Remember also to be sure that your links are to address on localhost until You are workin on localhost... :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top