tiingshii
08-31-2009, 03:29 AM
hi ppl
anyone know how to set textfield when its empty to N/A?
thanks
anyone know how to set textfield when its empty to N/A?
thanks
|
||||
show N/A when a textfield is empty(form)tiingshii 08-31-2009, 03:29 AM hi ppl anyone know how to set textfield when its empty to N/A? thanks mlseim 08-31-2009, 04:42 AM Which one of these? <input type="textbox"> <input type="select"> <input type="textarea"> And do you mean after they click submit and the form is processed by a PHP script? Is that where it should look for the empty "textfield"? I don't think I'm understanding it correctly? tiingshii 08-31-2009, 05:43 AM ya you are right when i receive the email i want the blank field to show N/A for <input type="text" =) any idea how to do it? abduraooft 08-31-2009, 06:46 AM ya you are right when i receive the email i want the blank field to show N/A Could you post the script used to send emails? Phil Jackson 08-31-2009, 08:33 AM if(empty($_POST['nameOfElement'])) { $variable = "N/A"; } else { $variable = $_POST['nameOfElement']; } tiingshii 08-31-2009, 11:34 AM where do i place the if statement? send email script <?php //define the receiver of the email $to = "szething@pddesignstudio.com"; //define the subject of the email $subject = 'CKC CONTACT FORM'; //create a boundary string. It must be unique //so we use the MD5 algorithm to generate a random hash $random_hash = md5(date('r', time())); //define the headers we want passed. Note that they are separated with \r\n $headers = "From: "; $headers .= $_POST["email"]; $headers .= "\r\n"; $headers .= "Reply-To: "; $headers .= $_POST["email"]; //add boundary string and mime type specification $headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\""; //define the body of the message. ob_start(); //Turn on output buffering ?> --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Error: Your e-mail client is unable to process HTML messages. Please use a compatible e-mail client that is able to process HTML messages. --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo $subject; ?></title> <style type="text/css"> <!-- .style4 { font-family: Arial, Helvetica, sans-serif; font-size: 14px; color: #FFFFFF; } .style5 {font-family: Arial, Helvetica, sans-serif; font-size: 14px; color: #000000; } .style6 {font-size: 11px} .style7 {font-family: Arial, Helvetica, sans-serif; font-size: 11px; color: #000000; } .style22 {font-size: 12px; } .style24 { color: #000000; font-size: 14px; } --> </style> </head> <body> <table width="61%" border="0" cellpadding="8" cellspacing="0"> <tr> <td colspan="2" class="style5"> </td> </tr> <tr> <th colspan="2" bgcolor="#FFFFFF" class="style4" scope="row"><div align="left" class="style24 style5">CKC Contact Form</div></th> </tr> <tr bgcolor="#f0f0f0"> <th width="19%" bgcolor="#FFFFFF" class="style5" scope="row"><div align="left" class="style25 style27">Full Name :</div></th> <td width="81%" bgcolor="#FFFFFF" class="style7 style22 style24"><?php echo $_POST["name"]; ?></td> </tr> <tr bgcolor="#f0f0f0"> <th bgcolor="#FFFFFF" class="style5" scope="row"><div align="left" class="style25 style28">School Name :</div></th> <td bgcolor="#FFFFFF" class="style7 style22 style24"><?php echo $_POST["school"]; ?></td> </tr> <tr bgcolor="#f0f0f0"> <th bgcolor="#FFFFFF" class="style5" scope="row"><div align="left" class="style25 style29">Email Address :</div></th> <td bgcolor="#FFFFFF" class="style7 style22 style24"><?php echo $_POST["email"]; ?></td> </tr> <tr bgcolor="#f0f0f0"> <th bgcolor="#FFFFFF" class="style5" scope="row"><div align="left" class="style25">Mailing Address :</div></th> <td bgcolor="#FFFFFF" class="style7 style22 style24"><?php echo $_POST["address"]; ?></td> </tr> <tr bgcolor="#f0f0f0"> <th bgcolor="#FFFFFF" class="style5" scope="row"><div align="left" class="style25">Phone Number :</div></th> <td bgcolor="#FFFFFF" class="style7 style22 style24"><?php echo $_POST["phone"]; ?></td> </tr> <tr bgcolor="#f0f0f0"> <th bgcolor="#FFFFFF" class="style5" scope="row"><div align="left" class="style25">Fax Number :</div></th> <td bgcolor="#FFFFFF" class="style7 style22 style24"><?php echo $_POST["fax"]; ?></td> </tr> <tr bgcolor="#2d79b2"> <th colspan="2" bgcolor="#FFFFFF" class="style4" scope="row"><div align="left" class="style24">Message</div></th> </tr> <tr> <td colspan="2" class="style7 style22 style24"><?php echo $_POST["message"]; ?></td> </tr> </table> </body> </html> --PHP-alt-<?php echo $random_hash; ?>-- <? //copy current buffer contents into $message variable and delete current output buffer $message = ob_get_clean(); //send the email $mail_sent = @mail( $to, $subject, $message, $headers ); //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" echo $mail_sent ? "Your message has been sent." : "Mail failed"; ?> </div> djm0219 08-31-2009, 12:10 PM On the page with the form that has the text area you want to default to N/A if it is blank. I don't see any input fields in what you posted so can't be more specific. Scriptet 08-31-2009, 01:43 PM One option is to loop through all submitted post fields, and if an empty value exists, assign N/A to it like so: foreach($_POST as $key => $value){ if(empty($value)){ $value = "N/A"; } } |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum