473,322 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

PHP Simple Mailer Help

Ok so I am mr.Knownothing when it comes to scripting...

I am trying to modify this script to omit fields that are not filled in. I have checkboxes and text fields.

Here is my current script:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.  
  4.     $request_method = $_SERVER["REQUEST_METHOD"];
  5.     if($request_method == "GET"){
  6.       $query_vars = $_GET;
  7.     } elseif ($request_method == "POST"){
  8.       $query_vars = $_POST;
  9.     }
  10.     reset($query_vars);
  11.     $t = date("U");
  12.  
  13.     $file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t;
  14.     $fp = fopen($file,"w");
  15.     while (list ($key, $val) = each ($query_vars)) {
  16.      fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
  17.      fputs($fp,"$val\n");
  18.      fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");
  19.      if ($key == "redirect") { $landing_page = $val;}
  20.     }
  21.     fclose($fp);
  22.     if ($landing_page != ""){
  23.     header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
  24.     } else {
  25.     header("Location: http://".$_SERVER["HTTP_HOST"]."/");
  26.     }
  27.  
  28.  
  29.  
  30. ?>
  31.  
  32. Here is what I think I have to add to it:
  33.  
  34. if (is_array($val)) {
  35. for ($z=0;$z<count($val);$z++) {
  36.  
  37. if(strlen($val[$z])>0) // If the length of your value is greater than
  38. zero, then include it
  39. { $content .= "$key: $val[$z]\n"; }
  40.  
  41. }
  42. } else {
  43. $content .= "$key: $val\n";
  44. }
  45.  
I am not sure if that is correct or how to add it into the script. Sorry for such an ignorant question.

-Todd
Aug 7 '07 #1
2 1249
kovik
1,044 Expert 1GB
Maybe empty() would be of interest to you.
Aug 8 '07 #2
pbmods
5,821 Expert 4TB
Heya, Todd. Welcome to TSDN!

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.
Aug 8 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Raphael Gluck | last post by:
Hi all I am still finding my feet creating a website in ASP, and i'm trying to get to grips with users providing feeback to my site. my webhosts have the dundas mailer installed, and i am trying...
2
by: John Davis | last post by:
What is the **MOST** obvious reason why will this will fail (it's not syntax or anything specific to the object)? Function Mail(MailerProgram, Message, Subject, Format, FromEmail, ToEmail,...
10
by: Flopper | last post by:
Hey can anyone help me with a WORKING anonymous mailer php script. I've looked on the net but only find non working one's. Greetings Floppie
1
by: Beyza | last post by:
Hi, I have a problem. One of my customer used to use php mailer in her web page. But when i changed something in the system (php packages) , it was broken. If she use php-mailer in her system,...
4
by: =?Utf-8?B?TWlrZSBI?= | last post by:
I'm using a block of ASP to allow a user to send a form via e-mail. However, someone keeps sending me spam through this form and they're using a bogus return address. I'm testing for a successful...
2
by: kind1one | last post by:
I am green to PHP and trying to create outside PHP mailer for html form ,i found the script i need but I can't get it to upload more than one file ,since i do not know exactly where to place script...
0
by: askzda | last post by:
Hi, Can somebody pls help to solve above problem. I have used dundas mailer for my mailing part in my asp script, but the an error occured during sending the mail. Error that is prompted out just...
4
by: patrickinminneapolis | last post by:
Hi guys, I'm trying to write an emailer, but I can't manage to construct the object properly. Here's what I've got: #!/usr/local/bin/perl -w use Net::SMTP; $smtp =...
6
by: Dave Kelly | last post by:
Sorry for the long post, it is easier to discard information than to have to wait for it to arrive. So here goes: This code worked perfectly when I was an Earthlink customer. Sprint decided...
9
by: neovantage | last post by:
hey geeks, I have a small mail script which will cause a PHP script to send a receipt upon clicking the submit button, by an HTML mail. This mail contains special characters, namely 'å', 'ä' and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.