Newbie needs help with php form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Etess
Forum Newbie
Posts: 4
Joined: Wed Apr 20, 2011 8:32 am

Newbie needs help with php form

Post by Etess »

Hello
I've generated a PHP form using PHP Generator. The form is working fine with one exception. I would like to exclude "0" values from the confirmation. I have three files, the form, a process.php and a global.inc.php.

Here is the link to the form.http://www.elainetessier.com/form/use/M ... form1.html Can this form be modifed to exclude all zero values?

Elaine
zyntrax
Forum Commoner
Posts: 32
Joined: Wed Apr 13, 2011 2:23 am
Location: Sweden

Re: Newbie needs help with php form

Post by zyntrax »

Can you show us process.php within tags?
Etess
Forum Newbie
Posts: 4
Joined: Wed Apr 20, 2011 8:32 am

Re: Newbie needs help with php form

Post by Etess »

<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','FarclarCottage');
pt_register('POST','Friends');
pt_register('POST','Holsteins');
pt_register('POST','HummingbirdandColumbine');
pt_register('POST','March');
pt_register('POST','MarkandTanyaGarden');
pt_register('POST','OrientalPoppies');
pt_register('POST','PutoutforSpring');
pt_register('POST','QuietMorningonPenLake');
pt_register('POST','RedDaylilies');
pt_register('POST','SiberianIrises');
pt_register('POST','StillAugustDay');
pt_register('POST','SummerBlessing');
pt_register('POST','SummerSplendour');
pt_register('POST','TheGeorgeFarm');
pt_register('POST','Tranquility');
pt_register('POST','ValeriesGarden');
pt_register('POST','WinterLight');
pt_register('POST','WoodlandTango');
pt_register('POST','EmailAddress');
pt_register('POST','MailingAddress');
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$EmailAddress)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Farclar Cottage: ".$FarclarCottage."
Friends: ".$Friends."
Holsteins: ".$Holsteins."
Hummingbird and Columbine: ".$HummingbirdandColumbine."
March: ".$March."
Mark and Tanya Garden: ".$MarkandTanyaGarden."
Oriental Poppies: ".$OrientalPoppies."
Put out for Spring: ".$PutoutforSpring."
Quiet Morning on Pen Lake: ".$QuietMorningonPenLake."
Red Daylilies: ".$RedDaylilies."
Siberian Irises: ".$SiberianIrises."
Still August Day: ".$StillAugustDay."
Summer Blessing: ".$SummerBlessing."
Summer Splendour: ".$SummerSplendour."
The George Farm: ".$TheGeorgeFarm."
Tranquility: ".$Tranquility."
Valeries Garden: ".$ValeriesGarden."
Winter Light: ".$WinterLight."
Woodland Tango: ".$WoodlandTango."
Email Address: ".$EmailAddress."
Mailing Address: ".$MailingAddress."
";
$message = stripslashes($message);
mail("elainetessier@gmail.com","Form Submitted at your website",$message,"From: phpFormGenerator");
?>


<!-- This is the content of the Thank you page, be careful while changing it -->

<h2>Thank you!</h2>

<table width=50%>
<tr><td>Farclar Cottage: </td><td> <?php echo $FarclarCottage; ?> </td></tr>
<tr><td>Friends: </td><td> <?php echo $Friends; ?> </td></tr>
<tr><td>Holsteins: </td><td> <?php echo $Holsteins; ?> </td></tr>
<tr><td>Hummingbird and Columbine: </td><td> <?php echo $HummingbirdandColumbine; ?> </td></tr>
<tr><td>March: </td><td> <?php echo $March; ?> </td></tr>
<tr><td>Mark and Tanya Garden: </td><td> <?php echo $MarkandTanyaGarden; ?> </td></tr>
<tr><td>Oriental Poppies: </td><td> <?php echo $OrientalPoppies; ?> </td></tr>
<tr><td>Put out for Spring: </td><td> <?php echo $PutoutforSpring; ?> </td></tr>
<tr><td>Quiet Morning on Pen Lake: </td><td> <?php echo $QuietMorningonPenLake; ?> </td></tr>
<tr><td>Red Daylilies: </td><td> <?php echo $RedDaylilies; ?> </td></tr>
<tr><td>Siberian Irises: </td><td> <?php echo $SiberianIrises; ?> </td></tr>
<tr><td>Still August Day: </td><td> <?php echo $StillAugustDay; ?> </td></tr>
<tr><td>Summer Blessing: </td><td> <?php echo $SummerBlessing; ?> </td></tr>
<tr><td>Summer Splendour: </td><td> <?php echo $SummerSplendour; ?> </td></tr>
<tr><td>The George Farm: </td><td> <?php echo $TheGeorgeFarm; ?> </td></tr>
<tr><td>Tranquility: </td><td> <?php echo $Tranquility; ?> </td></tr>
<tr><td>Valeries Garden: </td><td> <?php echo $ValeriesGarden; ?> </td></tr>
<tr><td>Winter Light: </td><td> <?php echo $WinterLight; ?> </td></tr>
<tr><td>Woodland Tango: </td><td> <?php echo $WoodlandTango; ?> </td></tr>
<tr><td>Email Address: </td><td> <?php echo $EmailAddress; ?> </td></tr>
<tr><td>Mailing Address: </td><td> <?php echo $MailingAddress; ?> </td></tr>
</table>
<!-- Do not change anything below this line -->

<?php
}
?>
zyntrax
Forum Commoner
Posts: 32
Joined: Wed Apr 13, 2011 2:23 am
Location: Sweden

Re: Newbie needs help with php form

Post by zyntrax »

Something like this:

<table width=50%>

<?php
if($FarclarCottage != 0)
{
echo "<tr><td>Farclar Cottage: </td><td> <?php echo $FarclarCottage; ?> </td></tr>";
}
if($Friends != 0)
{
echo "<tr><td>Friends: </td><td> <?php echo $Friends; ?> </td></tr>";
}

and so on :)
Etess
Forum Newbie
Posts: 4
Joined: Wed Apr 20, 2011 8:32 am

Re: Newbie needs help with php form

Post by Etess »

Hi Again.

I tried the above, and it didn't resolve the issue. Perhaps I didn't go about it the right way. Am I to replace the line with the above, or add to it. ???

E
Etess
Forum Newbie
Posts: 4
Joined: Wed Apr 20, 2011 8:32 am

Re: Newbie needs help with php form

Post by Etess »

zyntrax
Forum Commoner
Posts: 32
Joined: Wed Apr 13, 2011 2:23 am
Location: Sweden

Re: Newbie needs help with php form

Post by zyntrax »

Yes replace this part:

<table width=50%>
<tr><td>Farclar Cottage: </td><td> <?php echo $FarclarCottage; ?> </td></tr>
<tr><td>Friends: </td><td> <?php echo $Friends; ?> </td></tr>
<tr><td>Holsteins: </td><td> <?php echo $Holsteins; ?> </td></tr>
<tr><td>Hummingbird and Columbine: </td><td> <?php echo $HummingbirdandColumbine; ?> </td></tr>
<tr><td>March: </td><td> <?php echo $March; ?> </td></tr>
<tr><td>Mark and Tanya Garden: </td><td> <?php echo $MarkandTanyaGarden; ?> </td></tr>
<tr><td>Oriental Poppies: </td><td> <?php echo $OrientalPoppies; ?> </td></tr>
<tr><td>Put out for Spring: </td><td> <?php echo $PutoutforSpring; ?> </td></tr>
<tr><td>Quiet Morning on Pen Lake: </td><td> <?php echo $QuietMorningonPenLake; ?> </td></tr>
<tr><td>Red Daylilies: </td><td> <?php echo $RedDaylilies; ?> </td></tr>
<tr><td>Siberian Irises: </td><td> <?php echo $SiberianIrises; ?> </td></tr>
<tr><td>Still August Day: </td><td> <?php echo $StillAugustDay; ?> </td></tr>
<tr><td>Summer Blessing: </td><td> <?php echo $SummerBlessing; ?> </td></tr>
<tr><td>Summer Splendour: </td><td> <?php echo $SummerSplendour; ?> </td></tr>
<tr><td>The George Farm: </td><td> <?php echo $TheGeorgeFarm; ?> </td></tr>
<tr><td>Tranquility: </td><td> <?php echo $Tranquility; ?> </td></tr>
<tr><td>Valeries Garden: </td><td> <?php echo $ValeriesGarden; ?> </td></tr>
<tr><td>Winter Light: </td><td> <?php echo $WinterLight; ?> </td></tr>
<tr><td>Woodland Tango: </td><td> <?php echo $WoodlandTango; ?> </td></tr>
<tr><td>Email Address: </td><td> <?php echo $EmailAddress; ?> </td></tr>
<tr><td>Mailing Address: </td><td> <?php echo $MailingAddress; ?> </td></tr>
</table>

It should work, if it doesn't i'll try myself and see.
Post Reply