franknu Posted June 22, 2007 Share Posted June 22, 2007 Ok, I have to question in one code the first is. i have this code that at soon as the visitor goes to the page it sent a message i one want them to send a message if the submit the code for some reason, it is not doing that and the other question is how do i insert actual date and time in the page when the user hit submit here is my code $from = addslashes($_POST['from']); $status= addslashes($_POST['status']); $subject= addslashes($_POST['subject']); $message= addslashes($_POST['message']); $BusinessName= $_SESSION['BusinessName']; if(Submit) { $query = "INSERT INTO `messages` (`BusinessName`,`date`,`from`,`status`,`subject`,`message`) VALUES ('".$_SESSION['BusinessName']."','".$date."','".$from."', '".$status."','".$subject."', '".$message."')"; $result = mysql_query($query); echo mysql_error(); } if($result) { echo " Your Message have been sent. We will get back to you. <br>"; } ?> Link to comment https://forums.phpfreaks.com/topic/56713-inserting-questions/ Share on other sites More sharing options...
supanoob Posted June 22, 2007 Share Posted June 22, 2007 the date insert is just NOW() Link to comment https://forums.phpfreaks.com/topic/56713-inserting-questions/#findComment-280107 Share on other sites More sharing options...
franknu Posted June 22, 2007 Author Share Posted June 22, 2007 so i have to do date=NOW(); Link to comment https://forums.phpfreaks.com/topic/56713-inserting-questions/#findComment-280110 Share on other sites More sharing options...
franknu Posted June 22, 2007 Author Share Posted June 22, 2007 any idea how to set it up, i really dont know how to set it up because it did date=NOW(); and i am getting an error Link to comment https://forums.phpfreaks.com/topic/56713-inserting-questions/#findComment-280114 Share on other sites More sharing options...
pikemsu28 Posted June 22, 2007 Share Posted June 22, 2007 $query = "INSERT INTO `messages` (`BusinessName`,`date`,`from`,`status`,`subject`,`message`) VALUES ('".$_SESSION['BusinessName']."',now(),'".$from."', '".$status."','".$subject."', '".$message."')"; now() will insert a timestamp into your database as 'YYYY-MM-DD HH:MM:SS' set your database field 'date' as a DATETIME datatype Link to comment https://forums.phpfreaks.com/topic/56713-inserting-questions/#findComment-280118 Share on other sites More sharing options...
franknu Posted June 22, 2007 Author Share Posted June 22, 2007 ok that works but it only giving me the date, i also want the time on the same input Link to comment https://forums.phpfreaks.com/topic/56713-inserting-questions/#findComment-280135 Share on other sites More sharing options...
pikemsu28 Posted June 22, 2007 Share Posted June 22, 2007 is your date field set as a DATETIME datatype? if it's just set as DATE, it will not include the time stamp Link to comment https://forums.phpfreaks.com/topic/56713-inserting-questions/#findComment-280148 Share on other sites More sharing options...
franknu Posted June 22, 2007 Author Share Posted June 22, 2007 ok, thank u Link to comment https://forums.phpfreaks.com/topic/56713-inserting-questions/#findComment-280152 Share on other sites More sharing options...
pikemsu28 Posted June 22, 2007 Share Posted June 22, 2007 no problem Link to comment https://forums.phpfreaks.com/topic/56713-inserting-questions/#findComment-280153 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.