Jump to content

Inserting Questions


franknu

Recommended Posts

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

$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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.