Jump to content


New Members
  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

spoiledgoods's Achievements


Newbie (1/5)



  1. Well, I've managed to integrate what Psycho had posted into my existing form, and today all of the testing worked well. I haven't fully secured the form as I'm still trying to wrap my head around this bit, but it has not yet gone "live" so I still have some time. Thanks again everyone for pointing me in the right direction.
  2. Thanks for the quick responses guys! @Psycho: I'll try to implement what you've posted and post back with the results. I'm just leaving work now so it may not be until tomorrow before I can have something to test. @coded4u: Ideally, we would run this internally over our server (assuming it supports PHP ), but I'll have to look into securing it for sure. Thanks for the heads up. Cheers.
  3. Let me start by apologizing ahead of time for my complete and utter lack of knowledge with respect to PHP coding. I've been tasked with creating a timesheet that office employees would fill out at the end of each day for time tracking purposes. This form would then be sent electronically to be input into our accounting software. The form is as follows: I've used a little javascript to validate the form to ensure certain fields have been entered correctly. If everything checks out, the PHP script is supposed to kick in and email the contents (of only filled in fields) to the desired address. My goal here is to to have the end message looks something like this: ...but, if fields are blank, I would like to have them omitted. That is to say, if no OT/DT was worked on the first job, don't send that field in the message. Or, if only one job was worked that day, don't send the other seven rows. This is what I've got so far: $replyemail="accounting email"; $thesubject = "Daily Timesheet Submission"; $yourname = $_POST["yourname"]; $date = $_POST["date"]; $jb1 = $_POST["jb1"]; $ds1 = $_POST["ds1"]; $st1 = $_POST["st1"]; $ot1 = $_POST["ot1"]; $dt1 = $_POST["dt1"]; <!---SNIP---> $jb8 = $_POST["jb8"]; $ds8 = $_POST["ds8"]; $st8 = $_POST["st8"]; $ot8 = $_POST["ot8"]; $dt8 = $_POST["dt8"]; $themessage = "Name: $yourname \nDate: $date \nJob: $jb1 - $ds1 - $st1 hrs - $ot1 hrs - $dt1 hrs <!---SNIP---> \nJob: $jb8 - $ds8 - $st8 hrs - $ot8 hrs - $dt8 hrs"; mail("$replyemail", "$thesubject", "$themessage", "From: $yourname\nReply-To: $yourname"); header("Location: index.html"); exit(); It sends the message just fine, but the Job: - - hrs - hrs - hrs displays for all eight rows. I've found this little bit of code on this site (thanks gizmola): $subject = 'Daily Timesheet Submission'; $replyemail = 'accounting email'; $message = "$date timesheet for $yourname\n\n"; foreach ($_POST as $key => $value) { $value = trim(strip_tags($value)); if (!empty($value)) { $message .= "$value\n"; } } mail("$replyemail", "$subject", "$message", "From: $yourname\nReply-To: $yourname"); header("Location: index.html"); exit(); But it pushes all data onto a new line. I'd like to keep a similar layout within the email as is shown in the form itself. I feel this is an easy problem to solve; however, my lack of knowledge leaves me feeling a little embarrassed. Any help or insight into this matter would be greatly appreciated. Cheers.
  • 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.