$array = array('foo' => 'bar');
$key = 'foo';
echo $array[$key]; // outputs 'bar'
That's what you're trying to do there, which obviously doesn't work because $url
is not a defined variable. In fact, since the name value doesn't have a key in the URL it's associated with, you can't get it that way from $_GET
at all.
The simplest solution for you is to add a key in the URL:
header('Location: events.php?name=' . urlencode($_POST['name']));
^^^^^
and get the value by key:
$name = $_GET['name'];
It's odd though to use a user-entered name as is for a primary id to something in the database. You should rather use the autoincrementing numeric id of the record in the database.