Jump to content

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


paulm

Recommended Posts

<?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).

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. :)

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.