| | |
Don't display an empty form field?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Dec 2004
Posts: 38
Reputation:
Solved Threads: 0
I'm using a PHP script called rwf_mail.php (http://www.robertswebforge.com/scripts/rwf_mail.shtml).
It creates a form that can be emailed. It consists of the php file and a plain html file to display the form.
So in the HTML page, I have code similar to:
The PHP script pulls the $fields{"NAME"} and gets the user input from the form on the HTML page.
It then takes all of the fields defined in the PHP script and emails the field name and the form input.
What happens though is if a field is empty, it still emails the field name.
If the input from the form is blank, I don't want it to email the field name either. Basically just email me the field names with their values.
I believe this is the section of code that creates the message to email:
What would I have to do to make this possible?
It creates a form that can be emailed. It consists of the php file and a plain html file to display the form.
So in the HTML page, I have code similar to:
HTML Syntax (Toggle Plain Text)
<input size=50 name="NAME"><br>
The PHP script pulls the $fields{"NAME"} and gets the user input from the form on the HTML page.
It then takes all of the fields defined in the PHP script and emails the field name and the form input.
What happens though is if a field is empty, it still emails the field name.
If the input from the form is blank, I don't want it to email the field name either. Basically just email me the field names with their values.
I believe this is the section of code that creates the message to email:
php Syntax (Toggle Plain Text)
$message = "The following was submitted:\n\n"; foreach($fields as $f => $v){ $message .= sprintf("%20s: %s\n",$v,$_REQUEST[$f]); }
What would I have to do to make this possible?
So [php]$message = "The following was submitted:\n\n";
foreach($fields as $f => $v)
{
if ($v)
$message .= sprintf("%20s: %s\n",$v,$_REQUEST[$f]);
}[/php]?
foreach($fields as $f => $v)
{
if ($v)
$message .= sprintf("%20s: %s\n",$v,$_REQUEST[$f]);
}[/php]?
•
•
Join Date: Aug 2006
Posts: 138
Reputation:
Solved Threads: 2
•
•
•
•
So [php]$message = "The following was submitted:\n\n";
foreach($fields as $f => $v)
{
if ($v)
$message .= sprintf("%20s: %s\n",$v,$_REQUEST[$f]);
}[/php]?
php Syntax (Toggle Plain Text)
if ($v!=="")
![]() |
Similar Threads
- how to display images in a form in access 2003 (MS Access and FileMaker Pro)
- Help with asp form will not display contact information (ASP)
- Please help with email form script (PHP)
- Loing authentication fields from 2 tables? (ASP)
Other Threads in the PHP Forum
- Previous Thread: Get video file total time of playing using php
- Next Thread: Who can help me get this scripts????
| Thread Tools | Search this Thread |
apache api archive array autocomplete beginner binary broken cakephp checkbox class cms code cron curl database dataentry date display duplicates dynamic ebooks echo email emptydisplayvalue error execute explodefunction file files firstoptioninphpdroplist folder form forms function functions google href htaccess html image include insert ip javasciptvalidation javascript joomla keywords limit link login mail matching mediawiki menu mlm multiple mysql number oop paypal pdf php phpincludeissue problem query radio random recursion recursive remote script search server sessions shot sms source sp space speed sql subdomain subscription syntax system table tag tutorial tutorials update upload url validator variable vbulletin video web white youtube





