paulm Posted May 3, 2007 Author Share Posted May 3, 2007 Yeah, I'd like to eliminate those blank fields. I also get similar readings in my guestbook.txt, so it is recording the entries, which is a good thing. :-) At least the main purpose of the guestbook is taken care of. Link to comment https://forums.phpfreaks.com/topic/49297-i-need-help-php-code-for-a-form/page/2/#findComment-244002 Share on other sites More sharing options...
corbin Posted May 3, 2007 Share Posted May 3, 2007 <?php function pecho($field, $val) { //this is mainly my laziness right here ;p if(strlen($val) > 0) { echo $field . " " . $val . "<br />"; } return true; } $fp=fopen("guestbook.txt","a") or die("Technical error. Please try later"); $write = $_POST["full_name"] . "\t" . $_POST["primary_phone"] . "\t" . $_POST['secondary_phone'] . "\t" . $_POST['primary_email'] . "\t" . $_POST['secondary_email'] . "\t" . $_POST['form_comments'] . "\r\n"; @fwrite($fp, $write); fclose($fp); $file = file("guestbook.txt"); foreach($file as $line) { $pieces=explode("\t",$line); pecho("Name:", $pieces[0]); pecho("Primary Phone:", $pieces[1]); pecho("Secondary Phone:", $pieces[2]); pecho("Primary Email:", $pieces[3]); pecho("Secondary Email:", $pieces[4]); pecho("Comments:", $pieces[5]); echo "<hr>"; } ?> After so much file manipulation, I bet you can tell what that does, but if you can't I'm up for questions (once I get back from takin a shower ;p). Link to comment https://forums.phpfreaks.com/topic/49297-i-need-help-php-code-for-a-form/page/2/#findComment-244004 Share on other sites More sharing options...
paulm Posted May 3, 2007 Author Share Posted May 3, 2007 I met with my instructor on Monday and he said everything looked perfect. H e said all I need now to eliminate the blank fields from showing up is to use an 'if' statement. But I've tried so many different things and nothing has worked. I've been emailing my teacher with questions and I'm getting no responses. You have no idea how long I've been going crazy with this. Link to comment https://forums.phpfreaks.com/topic/49297-i-need-help-php-code-for-a-form/page/2/#findComment-244006 Share on other sites More sharing options...
paulm Posted May 3, 2007 Author Share Posted May 3, 2007 I thank all of you for all the help. I appreciate your time and patience. I need to get to bed. Have to get up early with the kids. I will be on tomorrow with more questions to your last post, Corbin. . Thanks again!! I'll try to incorporate everyone's advice into this tomorrow. Paul Link to comment https://forums.phpfreaks.com/topic/49297-i-need-help-php-code-for-a-form/page/2/#findComment-244024 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.