i tried a lot of things and it dosnt work (it saves the other data on db but not time or date).
here is the code:
Code: Select all
<?php
session_start();
if (isset($_SESSION['user']))
{
$user=$_SESSION['user'];
}
else
{
echo "Not Logged in <br><br> <A href='login.php'>Login</a>";
exit;
}
include 'connect.php';
//get user id so php will know under which user id to put it in the second block
$id_user=$_SESSION['id'];
if(isset($_POST['create_event'])){
$name=$_POST["name"];
$content=$_POST["content"];
$time=$_POST["time"];
$date=$_POST["date"];
//chack date
//Check the length of the entered Date value
if((strlen($date)<10)OR(strlen($date)>10)){
echo("Enter the date in 'dd/mm/yyyy' format");
}
//$date2 = strtotime($date);
//$date2 = date('y-m-d', );
//exit($date2 );
//$date = date("Y-m-d", );
//insert to events
$sql = "INSERT into event(name,content,date,time) VALUES ('$name','$content','$date','$time')";
//exit($sql);
$result = mysql_query($sql);
$topicid = mysql_insert_id();
$relations="INSERT into relations (id_user,id_event) VALUES ('$id_user','$topicid')";
$do=mysql_query($relations);
if(!$result) {
echo"bad sql query";
}
else{ echo 'You have successfully created <a href="events2.php'. '">your new event</a>.';}
}
?>