• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 134
  • Last Modified:

Is my logic wrong for this form??

Upon landing on this page, there should be no value for 'send'.  I thought my form should only allow the part that says 'if send=2, then do this', should only appear if the value for send is 2 (which it would only be if the form was not filled out entirely), but it is also appearing if send has no value.

Any ideas??
<?php include ("header_contact.php") ?>	
	
				</td>
    			<td width="550" valign="top">
					<table width="95%" border="0" cellspacing="0" cellpadding="3" class="maintext" align="center">
  						<tr>
    						<td valign="top"> <div id="main" /><h1>Contact</h1><br /><br />
							
							

							<br /><br />All required fields on this page are designated by an <font color="red">*</font>.<br />
						
						<?PHP if ($_GET[send] < 1) { ?>
						<?PHP echo $_GET[send];?>
<?php include "appformdd.php";?>


							</td>
  						</tr>
					</table>

				</td>
    			
  			</tr>
		</table>
	</td>
    <td width="5" bgcolor="#FF5903">
	</td>
	</tr>
</table>
<?php include ("footer.php") ?>


<?PHP } 
if ($_GET[send] == 1) 

include ("securimage/securimage.php");

$securimage = new Securimage();

{
        if ($_POST[NAME] == $nil || $_POST[COMPANY] == $nil || $_POST[PHONE] == $nil || $_POST[EMAIL] == $nil || $securimage->check($_POST['captcha_code']) == false)
$_GET[send] = 2;

}

if ($_GET[send] == 1) {

//$to="info@domain.com";
$to="john@domain.com";
$headers.= "MIME-Version: 1.0\n";
$headers.= "Content-type: text/html; ";
$headers.= "charset=iso-8859-1\n";
$headers.= "From: Contact Form <info@domain.com>\r\n"; 
$subject = "Contact Request - Online Form";

$body = "<HTML><BODY>
<b>Name:</b> $_POST[NAME]<br />
<b>Company:</b> $_POST[COMPANY]<br />
<b>Phone:</b> $_POST[PHONE]<br />
<b>Email:</b> $_POST[EMAIL]<br />
<b>Contact Method:</b> $_POST[CONTACTMETHOD]<br />
<b>Reason for Request:</b> $_POST[COMMENT]<br />

</BODY></HTML>
";

mail($to,$subject,$body,$headers);

?>
<center><h3>&nbsp;Your request has been submitted!</h3><br />
A company representative will contact you as soon as possible. Thank you.<br /><br /></center>


<?PHP } 
if ($_GET[send] == 2) {
?>
<br /><center><font color="red">Please complete all the required fields.  Required fields are marked with an *.</font>
</center>
<BR>
<?php include "appformdd.php"; ?>





							</td>
  						</tr>
					</table>

				</td>
    			
  			</tr>
		</table>
	</td>
    <td width="5" bgcolor="#FF5903">
	</td>
	</tr>
</table>
<?php include ("footer.php"); } ?>

Open in new window

0
tru504187211
Asked:
tru504187211
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
Two important things about your code.

#1: Array keys should be quoted or they may be mistaken for constants.  $_GET[send] should be $_GET["send"].  All the rest like $_POST[NAME] should be changed also.  See Array do's and don'ts on this page http://us2.php.net/manual/en/language.types.array.php

#2: Since PHP is a loosely typed language, sometimes you need to be aware of what it 'thinks' you're doing.  All data from a POST or GET comes in as Text.  Text needs to be quoted while numbers are not.  Your comparison if ($_GET[send] < 1) isnt' working because PHP sees the character '1' in $_GET[send] which is a number value of 49 which is obviously much larger than the number 1 in your code.  Your comparison might work if you wrote if ($_GET["send"] < "1") which will compare the value to the character '1', not the number 1 as you currently have.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now