Jump to content

gatoruss

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

gatoruss's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Bump.. ...thought it would be okay to "bump" since it had slipped to page 21... if that was bad form, I apologize...
  2. Thank you. I think that I understand this better now.
  3. Yes, I saw that. The purpose of my question was to understand why empty($_POST['name']) did not work with a multidimensional array. I guess to better understand how empty() worked? Note - I have been searching (with Google) for an answer to my question, but have not been able to find something that helped explain how/if you could use empty() with multidimensional array. Thanks. Russ
  4. I have a for with multiple test input fields. Specifically the user submits multiple names and ages. The form is submitted using the POST method. Here is a code snippet: <form action = {$_SERVER['PHP_SELF']} method = 'post' > for($i=1; $i<=10; $i++){ <input type = 'text' name = 'name[]' size ='25' maxlength = '50' /> <input type = 'text' name = 'age[]' size ='25' maxlength = '50' /> } <input type="submit" /> </form> I want to check if the user clicks submits without entering values in the text fields. I have tried this: if(empty($_POST['name']) && empty($_POST['age'])){ echo "All the entries were blank, please enter name(s) and age(s) on the left and click submit. Thank you."; } However, this doesn't parse as "true" when I click submit with the fields empty. Is it not possible to use "empty()" with arrays and/or multidimensional arrays?
  5. I have a question about setting email headers when using mail() in a php script. When I send an email from an email account set up domain (using, for example, xxx@MyDomain.net) and then view the header in the email that was received by the recipient account, the "Received:" header reads, in part, as follows: However, when I send an email using a script that I am working on that uses the mail() function, I set the "From:" and "Return-path" to an email address I have for my domain (YYY@MyDomain.net). When I look at the header in the email that was received by the recipient account, the "Received:" header has my CPanel user name in it - and that kind of makes me nervous (as my host preaches not to disclose that to anyone). In particular, here is what the "Received:" header looks like: Here is the code snippet I am using to send email and set headers: //Some additional email headers $add_headers = 'From: YYY@MyDomain.net' . "\r\n". "Return-path: YYY@MyDomain.net" . "\r\n"; mail('XXX@MyDomain.net', $subject , $message , $add_headers, "-f YYY@MyDomain.net"); I have tried to modify the "Received:" header by adding some text to the header via the mail() function (for example, "Received: SOME TEST]"), but it doesn't change the "Received:" header. Please note, I don't want to make the header fraudulent, but I would prefer not to disclose my cPanel username. I would just like the "Received:" header to resemble the first one quoted above. I have checked with my host's help desk, they suggested it was not a server issue, but a scripting issue. They suggested I try their scripting forum for assistance. I posted there, but no one there has shed any light on this yet. So, I thought that I would try here. I tried researching this on the Internet, and thus far I have not found any info on how to successfully modify "Received:" header with mail(). Info I have come across seems to suggest that this is a server issue and not something that can be changed via a script (at least via a script using mail()). If that is the case, I am thinking I should stop looking for a solution using mail(), and take a different approach. Any suggestions? Thanks Russ
  6. I have been digging around some more, I think that I figured out what my issue had been. Thought I should post a description in case some noobie like me comes across a similar issue. I had been following a tutorial at the following site http://evolt.org/incoming_mail_and_php?from=0&comments_per_page=50, and I had copied & pasted some code from that webpage into notepad. I subsequently edited the file in notepad++. Since the file I created (when I saved the script) was done in windows, newlines (and blank lines) were indicated in Notepad and Notepad++ by a CRLF. So when I upload to my server, which was Linux, there was a CR character at the end of each line - apparently, Linux indicates a newline (or a blank line) with LF. So the problem was that every line had an extra character (CR), which was causing errors with the script. I had been editing the script file online thru cPanel, to remove the blank line referenced above and when I saved the file via the cPanel editor, the file was converted to Linux format - removing all of the CR characters. Therefore, while it seemed like removing the blank line was fixing the issue, what really fixed the issue was saving the file in Linus format and thereby removing the CR characters!
  7. It was my understanding that my script was running as from the command line. So I was looking at information on http://us.php.net/manual/en/features.commandline.php. Interestingly, in an example for a script that runs from the command line, the following was given: That example has the same blank line after the opening tags. I reviewed the various user comments and sample code on th epage, and some had the white space and others did not. But I could find no mention of the issue, or whether the white space would or could be an issue.
  8. Thank you. I had considered that, but I thought that the "-q" argument in the hashbang turned of the header output of the php script? I will read further on "Headers" starting with the link you suggested. Thanks again.
  9. I am writing a script to which I am piping to an email. The script reads the email as STDIN and parses the email - saveing headers and body to different variables. Then to show it worked, the script sends an email back to me with info from the piped email. I am doing this as a learning exercise. I have run into the following issue (that I have solved), but do not understand why it was a problem...tried researching on net and haven't found something on point that explains issue. With that back ground, here goes: My code is as follows: #!/usr/local/bin/php -q <?php // read from stdin $fd = fopen("php://stdin", "r"); $email = ""; while (!feof($fd)) { $email .= fread($fd, 1024); } fclose($fd); // handle email $lines = explode("\n", $email); // empty vars $from = ""; $subject = ""; $headers = ""; $message = ""; $splittingheaders = true; for ($i=0; $i < count($lines); $i++) { if ($splittingheaders) { // this is a header $headers .= $lines[$i]."\n"; // look out for special headers if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) { $subject = $matches[1]; } if (preg_match("/^From: (.*)/", $lines[$i], $matches)) { $from = $matches[1]; } } else { // not a header, but message $message .= $lines[$i]."\n"; } if (trim($lines[$i])=="") { // empty line, header section has ended $splittingheaders = false; } } mail('ABCABC@XYZXYZ.net', $subject , $message); ?> When I sent an email to the piped email address, the script did not run and I received an error/bounce back email stating: However, if I remove the white space immediately after the opening php tag (<?php), the script ran as designed. I am confused, because I thought that white spaces before or after the tags (i.e., outside of tags) was the issue, and that white spaces inside the tags was fine? Can someone help out this Noobie and steer me toward an explanation? Thanks!
×
×
  • 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.