Jump to content

I Need HELP!!! PHP code for a form...


paulm

Recommended Posts

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
Share on other sites

<?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
Share on other sites

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
Share on other sites

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. ;D. Thanks again!! I'll try to incorporate everyone's advice into this tomorrow.

 

Paul

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.