<?php
require_once("includes/SQLConnect.php");
require_once("includes/user_data.php");


if(isset($_POST['ID']) && (int)$_POST['ID']>0){
	$event_ID = (int)$_POST['ID'];
	$user_ID = (int)$user_data['ID'];

	$result = mysql_query("SELECT * FROM Events WHERE ID = ".$event_ID." LIMIT 1");
	$event = mysql_fetch_assoc($result);
	
	if(mysql_query("INSERT INTO Events_RSVP(event_ID,user_ID) VALUES($event_ID,$user_ID)"))
		header("Location:events_browse.php?success=RSVPed to ".stripslashes($event['title'])." successfully.");
	else
		header("Location:events_browse.php?error = Your request to RSVP didn't succeed, probably because you've already RSVPed.");
}


include_once("includes/header.php");
?>


<?php
include_once("includes/footer.php");
?>