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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.