genabit
12-10-2005, 06:26 AM
I'm new to programming and I can't seem to get the syntax right to add a second condition, what I want to do is check a variable coming from a form and if the user enters one field then the second field is left blank I need to give them an error message that they left out some information.
I want to add the following to process.php
if ($productcpt=="cpt" || $cptusers==""){
$errors=1;
$error.="<li>You did not enter the number of users. Please go back and try again.";
}
when I add it in I get a blank page not an error message...I'm probably putting it in the wrong place, can anyone help me out? I really would appreciate constructive help!
process.php
<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','name');
pt_register('POST','title');
pt_register('POST','company');
pt_register('POST','typeOrg');
pt_register('POST','textfieldName');
pt_register('POST','address');
pt_register('POST','city');
pt_register('POST','state');
pt_register('POST','zip');
pt_register('POST','phone');
pt_register('POST','fax');
pt_register('POST','productcpt');
pt_register('POST','licensegroup1');
pt_register('POST','cptusers');
pt_register('POST','producticd');
pt_register('POST','licensegroup2');
pt_register('POST','icdusers');
pt_register('POST','producthcpcs');
pt_register('POST','licensegroup3');
pt_register('POST','hcpcsusers');
pt_register('POST','producthcpcsfees');
pt_register('POST','licensegroup4');
pt_register('POST','hcpcsfeesusers');
pt_register('POST','q1');
$q1=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $q1);pt_register('POST','q2');
pt_register('POST','Q2group');
$q2=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $q2);pt_register('POST','date');
pt_register('POST','textfieldNameb');
pt_register('POST','checkbox');
if($name=="" || $title=="" || $company=="" || $typeOrg=="" || $address=="" || $city=="" || $state=="" || $zip=="" || $phone=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="name: ".$name."
title: ".$title."
company: ".$company."
Org type: ".$typeOrg."
if other: ".$textfieldName."
address: ".$address."
city: ".$city."
state: ".$state."
zip: ".$zip."
phone: ".$phone."
fax: ".$fax."
product cpt: ".$productcpt."
cpt license type: ".$licensegroup1."
number of cpt users: ".$cptusers."
product icd: ".$producticd."
icd license type: ".$licensegroup2."
number of icd users: ".$icdusers."
producthcpcs: ".$producthcpcs."
hcpcs license type: ".$licensegroup3."
number of hcpcs users: ".$hcpcsusers."
product hcpcsfees: ".$producthcpcsfees."
hcpcsfees license type: ".$licensegroup4."
number of hcpcsfees users: ".$hcpcsfeesusers."
Data use details: ".$q1."
If yes please describe or name the software application: ".$Q2group."
software application useage: ".$q2."
Accept date: ".$date."
Accept Initials: ".$textfieldNameb."
Accept Check: ".$checkbox."
";
$message = stripslashes($message);
mail("me@genabit.com","Profile Form Submitted at genabit",$message,"From: genabit");
$make=fopen("admin/data.dat","a");
$to_put="";
$to_put .= $name."|".$title."|".$company."|".$typeOrg."|".$textfieldName."|".$address."|".$city."|".$state."|".$zip."|".$phone."|".$fax."|".$productcpt."|".$licensegroup1."|".$cptusers."|".$producticd."|".$licensegroup2."|".$icdusers."|".$producthcpcs."|".$licensegroup3."|".$hcpcsusers."|".$producthcpcsfees."|".$licensegroup4."|".$hcpcsfeesusers."|".$q1."|".$q2."|".$Q2group."|".$date."|".$textfieldNameb."|".$checkbox."
";
fwrite($make,$to_put);
?>
<!-- This is the content of the Thank you page, be careful while changing it -->
<h2>Thank you!</h2>
<table width=50%>
<tr><td>name: </td><td> <?php echo $name; ?> </td></tr>
<tr><td>title: </td><td> <?php echo $title; ?> </td></tr>
<tr><td>company: </td><td> <?php echo $company; ?> </td></tr>
<tr><td>Org Type: </td><td> <?php echo $typeOrg; ?> </td></tr>
<tr><td>If Other: </td><td> <?php echo $textfieldName; ?> </td></tr>
<tr><td>Address: </td><td> <?php echo $address; ?> </td></tr>
<tr><td>City: </td><td> <?php echo $city; ?> </td></tr>
<tr><td>State: </td><td> <?php echo $state; ?> </td></tr>
<tr><td>Zip: </td><td> <?php echo $zip; ?> </td></tr>
<tr><td>Phone: </td><td> <?php echo $phone; ?> </td></tr>
<tr><td>Fax: </td><td> <?php echo $fax; ?> </td></tr>
<tr><td>product cpt: </td><td> <?php echo $productcpt; ?> </td></tr>
<tr><td>Cpt license type: </td><td> <?php echo $licensegroup1; ?> </td></tr>
<tr><td>Number of cpt users: </td><td> <?php echo $cptusers; ?> </td></tr>
<tr><td>product icd: </td><td> <?php echo $producticd; ?> </td></tr>
<tr><td>ICD License Type: </td><td> <?php echo $licensegroup2; ?> </td></tr>
<tr><td>Number of icd users: </td><td> <?php echo $icdusers; ?> </td></tr>
<tr><td>product hcpcs: </td><td> <?php echo $producthcpcs; ?> </td></tr>
<tr><td>hcpcs license type: </td><td> <?php echo $licensegroup3; ?> </td></tr>
<tr><td>number of hcpcs users: </td><td> <?php echo $hcpcsusers; ?> </td></tr>
<tr><td>product hcpcsfees: </td><td> <?php echo $producthcpcsfees; ?> </td></tr>
<tr><td>hcpcsfees license type: </td><td> <?php echo $licensegroup4; ?> </td></tr>
<tr><td>Number of hcpcsfees users: </td><td> <?php echo $hcpcsfeesusers; ?> </td></tr>
<tr><td>Describe Usage: </td><td> <?php echo $q1; ?> </td></tr>
<tr><td>Will the data be used as part of a software/application?: </td><td> <?php echo $Q2group; ?> </td></tr>
<tr><td>If yes please describe or name the software application: </td><td> <?php echo $q2; ?> </td></tr>
<tr><td>Accept date: </td><td> <?php echo $date; ?> </td></tr>
<tr><td>Accept initials: </td><td> <?php echo $textfieldNameb; ?> </td></tr>
<tr><td>Accept check: </td><td> <?php echo $checkbox; ?> </td></tr>
</table>
<!-- Do not change anything below this line -->
<?php
}
?>
I want to add the following to process.php
if ($productcpt=="cpt" || $cptusers==""){
$errors=1;
$error.="<li>You did not enter the number of users. Please go back and try again.";
}
when I add it in I get a blank page not an error message...I'm probably putting it in the wrong place, can anyone help me out? I really would appreciate constructive help!
process.php
<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','name');
pt_register('POST','title');
pt_register('POST','company');
pt_register('POST','typeOrg');
pt_register('POST','textfieldName');
pt_register('POST','address');
pt_register('POST','city');
pt_register('POST','state');
pt_register('POST','zip');
pt_register('POST','phone');
pt_register('POST','fax');
pt_register('POST','productcpt');
pt_register('POST','licensegroup1');
pt_register('POST','cptusers');
pt_register('POST','producticd');
pt_register('POST','licensegroup2');
pt_register('POST','icdusers');
pt_register('POST','producthcpcs');
pt_register('POST','licensegroup3');
pt_register('POST','hcpcsusers');
pt_register('POST','producthcpcsfees');
pt_register('POST','licensegroup4');
pt_register('POST','hcpcsfeesusers');
pt_register('POST','q1');
$q1=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $q1);pt_register('POST','q2');
pt_register('POST','Q2group');
$q2=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $q2);pt_register('POST','date');
pt_register('POST','textfieldNameb');
pt_register('POST','checkbox');
if($name=="" || $title=="" || $company=="" || $typeOrg=="" || $address=="" || $city=="" || $state=="" || $zip=="" || $phone=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="name: ".$name."
title: ".$title."
company: ".$company."
Org type: ".$typeOrg."
if other: ".$textfieldName."
address: ".$address."
city: ".$city."
state: ".$state."
zip: ".$zip."
phone: ".$phone."
fax: ".$fax."
product cpt: ".$productcpt."
cpt license type: ".$licensegroup1."
number of cpt users: ".$cptusers."
product icd: ".$producticd."
icd license type: ".$licensegroup2."
number of icd users: ".$icdusers."
producthcpcs: ".$producthcpcs."
hcpcs license type: ".$licensegroup3."
number of hcpcs users: ".$hcpcsusers."
product hcpcsfees: ".$producthcpcsfees."
hcpcsfees license type: ".$licensegroup4."
number of hcpcsfees users: ".$hcpcsfeesusers."
Data use details: ".$q1."
If yes please describe or name the software application: ".$Q2group."
software application useage: ".$q2."
Accept date: ".$date."
Accept Initials: ".$textfieldNameb."
Accept Check: ".$checkbox."
";
$message = stripslashes($message);
mail("me@genabit.com","Profile Form Submitted at genabit",$message,"From: genabit");
$make=fopen("admin/data.dat","a");
$to_put="";
$to_put .= $name."|".$title."|".$company."|".$typeOrg."|".$textfieldName."|".$address."|".$city."|".$state."|".$zip."|".$phone."|".$fax."|".$productcpt."|".$licensegroup1."|".$cptusers."|".$producticd."|".$licensegroup2."|".$icdusers."|".$producthcpcs."|".$licensegroup3."|".$hcpcsusers."|".$producthcpcsfees."|".$licensegroup4."|".$hcpcsfeesusers."|".$q1."|".$q2."|".$Q2group."|".$date."|".$textfieldNameb."|".$checkbox."
";
fwrite($make,$to_put);
?>
<!-- This is the content of the Thank you page, be careful while changing it -->
<h2>Thank you!</h2>
<table width=50%>
<tr><td>name: </td><td> <?php echo $name; ?> </td></tr>
<tr><td>title: </td><td> <?php echo $title; ?> </td></tr>
<tr><td>company: </td><td> <?php echo $company; ?> </td></tr>
<tr><td>Org Type: </td><td> <?php echo $typeOrg; ?> </td></tr>
<tr><td>If Other: </td><td> <?php echo $textfieldName; ?> </td></tr>
<tr><td>Address: </td><td> <?php echo $address; ?> </td></tr>
<tr><td>City: </td><td> <?php echo $city; ?> </td></tr>
<tr><td>State: </td><td> <?php echo $state; ?> </td></tr>
<tr><td>Zip: </td><td> <?php echo $zip; ?> </td></tr>
<tr><td>Phone: </td><td> <?php echo $phone; ?> </td></tr>
<tr><td>Fax: </td><td> <?php echo $fax; ?> </td></tr>
<tr><td>product cpt: </td><td> <?php echo $productcpt; ?> </td></tr>
<tr><td>Cpt license type: </td><td> <?php echo $licensegroup1; ?> </td></tr>
<tr><td>Number of cpt users: </td><td> <?php echo $cptusers; ?> </td></tr>
<tr><td>product icd: </td><td> <?php echo $producticd; ?> </td></tr>
<tr><td>ICD License Type: </td><td> <?php echo $licensegroup2; ?> </td></tr>
<tr><td>Number of icd users: </td><td> <?php echo $icdusers; ?> </td></tr>
<tr><td>product hcpcs: </td><td> <?php echo $producthcpcs; ?> </td></tr>
<tr><td>hcpcs license type: </td><td> <?php echo $licensegroup3; ?> </td></tr>
<tr><td>number of hcpcs users: </td><td> <?php echo $hcpcsusers; ?> </td></tr>
<tr><td>product hcpcsfees: </td><td> <?php echo $producthcpcsfees; ?> </td></tr>
<tr><td>hcpcsfees license type: </td><td> <?php echo $licensegroup4; ?> </td></tr>
<tr><td>Number of hcpcsfees users: </td><td> <?php echo $hcpcsfeesusers; ?> </td></tr>
<tr><td>Describe Usage: </td><td> <?php echo $q1; ?> </td></tr>
<tr><td>Will the data be used as part of a software/application?: </td><td> <?php echo $Q2group; ?> </td></tr>
<tr><td>If yes please describe or name the software application: </td><td> <?php echo $q2; ?> </td></tr>
<tr><td>Accept date: </td><td> <?php echo $date; ?> </td></tr>
<tr><td>Accept initials: </td><td> <?php echo $textfieldNameb; ?> </td></tr>
<tr><td>Accept check: </td><td> <?php echo $checkbox; ?> </td></tr>
</table>
<!-- Do not change anything below this line -->
<?php
}
?>