| | |
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 |
.htaccess alexa apache api array beginner beneath binary broadband broken cakephp checkbox class cms code convert cron curl database date display dynamic echo email emptydisplayvalue encode error fcc file files folder form forms function functions google howtowriteathesis href htaccess html image images include insert ip javascript joomla key keywords limit link login mail mail() memberships menu mlm multiple multipletables mysql mysql_real_escape_string network oop open passwords paypal pdf php provider query radio random redirect remote rss script search securephp server sessions smtp source space sql strip_tags syntax system table template tutorial update upload url user validator variable video voteup web youtube





