I'm having an issue that's been driving me crazy for a while now because I just can't figure it out.
I want to echo something like "succeed" if the user creates a post from a form.
This is what i got so far in my db-querys file:
if ($_REQUEST) {
$name = $_REQUEST['name'];
$price = $_REQUEST['price'];
$dateofevent = $_REQUEST['dateofevent'];
$time = $_REQUEST['time'];
$textinfo = $_REQUEST['textinfo'];
$leg = $_REQUEST['leg'];
$sql= $dbh->prepare("INSERT INTO events(name, dateofevent, time, price, leg, textinfo)
VALUE (:name, :dateofevent, :time, :price, :leg, :textinfo)");
$sql->bindParam(':name', $name);
$sql->bindParam(':dateofevent', $dateofevent);
$sql->bindParam(':time', $time);
$sql->bindParam(':price', $price);
$sql->bindParam(':leg', $leg);
$sql->bindParam(':textinfo', $textinfo);
$sql->execute();
$url = $_POST['name'];
header('Location: events.php?'.$url);
}
Then I've tried using $_GET
to echo out something if the url is correct.
This is the code in my view-file so far:
if(isset($_GET[$url])) {
echo "success";
}
Here I get undefined variable $url and the echo doesn't work, nothing shows.
I've also tried something like:
$url = 'path/to/event.php';
if (!$_SERVER['REQUEST_URI'] == $_SERVER[$url]) {
echo "success";
}
And here I get undefined index path/to/event.php and the echo doesn't work aswell, nothing shows.
Can anyone please help me with my problem? I'm new in php so can't get any further with this, I'm stuck.