Page 1 of 1

help on verifying

Posted: Thu Feb 20, 2003 12:15 pm
by node
ok this is what i have:

Code: Select all

function CheckFields(){

$domain = $_POSTї'domain'];
$company = $_POSTї'company'];
$FirstName = $_POSTї'FirstName'];
$LastName = $_POSTї'LastName'];
$addr = $_POSTї'addr'];
$zip = $_POSTї'zip'];
$state = $_POSTї'state'];
$email = $_POSTї'email'];
$phone = $_POSTї'phone'];
$fax = $_POSTї'fax'];
$uname = $_POSTї'uname'];
$passwd = $_POSTї'passwd'];

if($$domain || $$company || $$FirstName || $$LastName || $$addr || $$zip || $$state || $$email || $$phone || $$fax || $$uname || $$passwd = "")
{
    echo("One or more fields are not filled in correctly. Please go back and make sure all fields are filled.
          If you don't have a fax number just use your home phone.");
} 
else 
{
    header("location: final.php");
}
}

if($submit){  //if user clicked the submit button call CheckFields function

    CheckFields();
    exit();
} else {

echo($head);

?>
When i run it on my server i get the error "Warning: Missing argument 1 for checkfields() on line 32." That comes up 12 times for each field. What am I doing wrong? And obviously im a newb...and thanks in advance for the help. :D

- node

Posted: Thu Feb 20, 2003 1:04 pm
by daven
for this bit of code:
if($$domain || $$company || $$FirstName || $$LastName || $$addr || $$zip || $$state || $$email || $$phone || $$fax || $$uname || $$passwd = "")
1. You should be using a single '$', not a double (ex: $domain, not $$domain). Two '$'s creates a variable variable, which you are not using here.
2. Each part of the if statement should be a complete condition. Revised statement is below:

Code: Select all

if($domain = "" || $company = "" || $FirstName = "" || $LastName = "" || $addr = "" || $zip = "" || $state = "" || $email = "" || $phone = "" || $fax = "" || $uname = "" || $passwd = "")

Posted: Thu Feb 20, 2003 1:32 pm
by node
that didnt work man, but thanks for the quick reply :D

Posted: Thu Feb 20, 2003 2:15 pm
by daven
One small error I just noticed: you do not have a closing } after your last else (the line with "echo ($head)"). Put it in and see if you still get the same error. PHP does funky things when you forget curly braces.

If you are still getting the same problem, try the verification without using a function (since it says you are missing arguments for the function)

Code: Select all

if($submit){  //if user clicked the submit button call CheckFields function
    
$domain = $_POSTї'domain'];
$company = $_POSTї'company'];
$FirstName = $_POSTї'FirstName'];
$LastName = $_POSTї'LastName'];
$addr = $_POSTї'addr'];
$zip = $_POSTї'zip'];
$state = $_POSTї'state'];
$email = $_POSTї'email'];
$phone = $_POSTї'phone'];
$fax = $_POSTї'fax'];
$uname = $_POSTї'uname'];
$passwd = $_POSTї'passwd'];
if($domain = "" || $company = "" || $FirstName = "" || $LastName = "" || $addr = "" || $zip = "" || $state = "" || $email = "" || $phone = "" || $fax = "" || $uname = "" || $passwd = ""){
echo("One or more fields are not filled in correctly. Please go back and make sure all fields are filled.
          If you don't have a fax number just use your home phone.");
}
else
{
    header("location: final.php");
}
exit();
} 
else {echo($head); }

Posted: Thu Feb 20, 2003 3:13 pm
by node
alright check it out....this is the entire page, lol. i end the else at the bottom.

Code: Select all

$head = "<html><head><link rel="STYLESHEET" type="text/css" href="./style.css">".
        "<title></title></head>".
        "<body color="#ffffff" text="#000000">";

$tail = "</body></html>";

$font ="<font face="verdana" size="2">";

if($submit)&#123;  //if user clicked the submit button call CheckFields function

$domain = $_POST&#1111;'domain'];
$company = $_POST&#1111;'company'];
$FirstName = $_POST&#1111;'FirstName'];
$LastName = $_POST&#1111;'LastName'];
$addr = $_POST&#1111;'addr'];
$zip = $_POST&#1111;'zip'];
$state = $_POST&#1111;'state'];
$email = $_POST&#1111;'email'];
$phone = $_POST&#1111;'phone'];
$fax = $_POST&#1111;'fax'];
$uname = $_POST&#1111;'uname'];
$passwd = $_POST&#1111;'passwd'];

if($domain = "" || $company = "" || $FirstName = "" || $LastName = "" || $addr = "" || $zip = "" || $state = "" || $email = "" || $phone = "" || $fax = "" || $uname = "" || $passwd = "")&#123;
echo("One or more fields are not filled in correctly. Please go back and make sure all fields are filled.
          If you don't have a fax number just use your home phone.");
&#125;
else
&#123;
    header("location: final.php");
&#125;
exit();
&#125;
else &#123;echo($head);



?>
<table align="center" border="0" cellpadding="0" cellspacing="0">
  <tr bgcolor="#cccccc">
    <td align="center">
    <font face="verdana" size="4">AristaCOM Order Form<BR></font>
    <font face="verdana" size="2" color="red">* All fields required *</font>
    </td>
  </tr>
  <tr>
  <td>
<table align="left" border="0" cellpadding="5" cellspacing="0">
   <tr bgcolor="#cccccc">
      <td align="center" valign="top">
      <form action="<?php echo $_SERVER&#1111;'PHP_SELF'] ?>" method="POST">
      <input type="radio" name="radio" value="bronze" />
      </td>
      <td align="left" valign="top">
      <B><? echo($font) ?>Bronze VServer Package</B><p>
      &nbsp;&nbsp;Complete Virtual Server with up<BR>
      &nbsp;&nbsp;to 50+ websites with 500MB storage,<BR>
      &nbsp;&nbsp;unmetered data transfer, and <BR>
      &nbsp;&nbsp;unlimited users & mail boxes.<p>
      &nbsp;Monthly: $24.99 / Annually: $249.90</B>
      <hr color="#000000">
   <tr bgcolor="#cccccc">
      <td align="center" valign="top">
      <input type="radio" name="radio" value="silver" />
      </td>
      <td align="left" valign="top">
      <B><? echo($font) ?>Silver VServer Package</B><p>
      &nbsp;&nbsp;Complete Virtual Server with up<BR>
      &nbsp;&nbsp;to 100+ websites with 1GB storage,<BR>
      &nbsp;&nbsp;unmetered data transfer, and <BR>
      &nbsp;&nbsp;unlimited users & mail boxes.<p>
      &nbsp;Monthly: $49.99 / Annually: $499.90</B>
      <hr color="#000000">
   <tr bgcolor="#cccccc">
      <td align="left" valign="top">
      <input type="radio" name="radio" value="gold" />
      </td>
      <td align="left" valign="top">
      <B><? echo($font) ?>Gold VServer Package</B><p>
      &nbsp;&nbsp;Complete Virtual Server with up<BR>
      &nbsp;&nbsp;to 150-200+ websites with 2GB storage,<BR>
      &nbsp;&nbsp;unmetered data transfer, <BR>
      &nbsp;&nbsp;unlimited users & mail boxes,<br>
      &nbsp;&nbsp;as well as your own name servers.<br>
      &nbsp;&nbsp;eg:<br>
      &nbsp;&nbsp;ns1.domain.com & ns2.domain.com<p>
      &nbsp;Monthly: $79.99 / Annually: $799.90</B>
      <hr color="#000000">
   <tr bgcolor="#cccccc">
      <td align="left" valign="top">
      <input type="radio" name="radio" value="gold" />
      </td>
      <td align="left" valign="top">
      <B><? echo($font) ?>Platinum VServer Package</B><p>
      &nbsp;&nbsp;Complete Virtual Server with up<BR>
      &nbsp;&nbsp;to 300+ websites with 4GB storage,<BR>
      &nbsp;&nbsp;unmetered data transfer, <BR>
      &nbsp;&nbsp;unlimited users & mail boxes,<br>
      &nbsp;&nbsp;as well as your own name servers.<br>
      &nbsp;&nbsp;eg:<br>
      &nbsp;&nbsp;ns1.domain.com & ns2.domain.com<p>
      &nbsp;Monthly: $99.99 / Annually: $999.90</B>
      <hr color="#000000">
      </td>
   </tr>
</table>
<P><P>
<table align="right" border="0" cellpadding="5" cellspacing="0">
   <tr bgcolor="#cccccc">
     <td align="left" colspan="2">
     <? echo $font ?><B>Primary Domain on Account</B></td>
   </tr>
   <tr bgcolor="#ffffff">
     <td align="left" valign="center">
     <? echo $font ?>Primary Domain:
     </td>
     <td align="left" valign="middle">
     <input type="text" name="domain" size="20" value="<? echo($domain) ?>" maxlength="254" class="box" /><? echo($font) ?> (eg: domain.com)<p>
     <? echo $font ?>Register Domain?<input type="checkbox" name="reg_domain" value="domain">
     </td>
   </tr>
   <tr bgcolor="#cccccc">
     <td align="left" colspan="2">
     <? echo $font ?><B>Billing/Owner Information</B>
     </td>
   </tr>
   <tr bgcolor="#ffffff">
     <td align="left" valign="top">
     <? echo $font ?>
     Company/Organization Name:
     </td>
     <td align="left" valign="top">
     <input type="text" name="company" size="20" value="<? echo($company) ?>" maxlength="254" class="box" /><P>
     </td>
   </tr>
   <tr bgcolor="#ffffff">
     <td align="left" valign="top">
     <? echo $font ?>
     Salutation:
     </td>
     <td align="left" valign="top">
     <select name="sal"><option value="mr" checked>Mr.<option value="ms">Ms.<option value="mrs">Mrs.</select name="sal" /><P>
     </td>
   </tr>
   <tr bgcolor="#ffffff">
     <td align="left" valign="top">
     <? echo $font ?>
     First Name:
     </td>
     <td align="left" valign="top">
     <input type="text" name="FirstName" size="20" value="<? echo($FirstName) ?>" maxlength="100" class="box" /><P>
     </td>
   </tr>
   <tr bgcolor="#ffffff">
     <td align="left" valign="top">
     <? echo $font ?>
     Last Name:
     </td>
     <td align="left" valign="top">
     <input type="text" name="LastName" size="20" value="<? echo($LastName) ?>" maxlength="100" class="box" /><P>
     </td>
   </tr>
   <tr bgcolor="#ffffff">
     <td align="left" valign="top">
     <? echo $font ?>
     Street Address:
     </td>
     <td align="left" valign="top">
     <input type="text" name="addr" size="20" value="<? echo($addr) ?>" maxlength="100" class="box" /><P>
     </td>
   </tr>
   <tr bgcolor="#ffffff">
     <td align="left" valign="top">
     <? echo $font ?>
     Zip Code:
     </td>
     <td align="left" valign="top">
     <input type="text" name="zip" size="20" value="<? echo($zip) ?>" maxlength="10" class="box" /><P>
     </td>
   </tr>
   <tr bgcolor="#ffffff">
     <td align="left" valign="top">
     <? echo $font ?>
     State:
     </td>
     <td align="left" valign="top">
     <input type="text" name="state" size="20" value="<? echo($state) ?>" maxlength="2" class="box" /><? echo($font) ?> (eg: Texas = TX)<P>
     </td>
   </tr>
   <tr bgcolor="#ffffff">
     <td align="left" valign="top">
     <? echo $font ?>
     Country:
     </td>
     <td align="left" valign="top">
     <select name="country"><OPTION>&#1111; Choose One ]
<!-- Admin Edit: Massive list of options, removed because it made the script push the page out load -->
</select name="country"><P>
     </td>
   </tr>
   <tr bgcolor="#ffffff">
     <td align="left" valign="top">
     <? echo $font ?>
     Email:
     </td>
     <td align="left" valign="top">
     <input type="text" name="email" size="20" value="<? echo($email) ?>" maxlength="75" class="box" /><P>
     </td>
   </tr>
   <tr bgcolor="#ffffff">
     <td align="left" valign="top">
     <? echo $font ?>
     Phone Number:
     </td>
     <td align="left" valign="top">
     <input type="text" name="phone" size="20" value="<? echo($phone) ?>" maxlength="12" class="box" /><? echo($font) ?> (eg: 555-555-5555)<P>
     </td>
   </tr>
   <tr bgcolor="#ffffff">
     <td align="left" valign="top">
     <? echo $font ?>
     Fax Number:
     </td>
     <td align="left" valign="top">
     <input type="text" name="fax" size="20" value="<? echo($fax) ?>" maxlength="12" class="box" /><BR><BR><BR></font>
     </td>
   </tr>
   <tr bgcolor="#cccccc">
     <td align="left" colspan="2">
     <? echo $font ?><B>Choose Username</B></td>
   </tr>
   <tr bgcolor="#ffffff">
     <td align="left" valign="top">
     <? echo $font ?>
     Username:
     </td>
     <td align="left" valign="top">
     <input type="text" name="uname" size="20" value="<? echo($uname) ?>" maxlength="15" class="box" /><? echo($font) ?> (15 char max)<P>
     </td>
   </tr>
   <tr bgcolor="#ffffff">
     <td align="left" valign="top">
     <? echo $font ?>
     Password:
     </td>
     <td align="left" valign="top">
     <input type="password" name="passwd" size="20" value="<? echo($passwd) ?>" maxlength="12" class="box" /><? echo($font) ?> (12 char max)<P>
     </font>
     </td>
   </tr>
</table>
<P><P>
</tr>
</td>
</table><P><P>
<center> <input type="submit" name="submit" class="button" value=" Continue >> " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <input type="reset" name="reset" class="button" value="    Reset    " />
</form>
<P>

<table align="center" border="1" bordercolor="#cccccc" cellpadding="5" cellspacing="0">
  <tr bgcolor="#ffffff">
    <td align="center" valign="middle">
<font face="verdana" size="1">
You are being logged: <?php echo getenv('REMOTE_ADDR') ?>
    </td>
  </tr>
</table>
<P>

<?php

echo $tail;
exit();
&#125;
?>
thats exactally how i have it.

*note to admin: didnt mean to post so much, just makes it easier this way.*

- node

Posted: Thu Feb 20, 2003 3:45 pm
by daven
I don't have the time to go over the code in-depth at the moment, but a few quick things I noticed:

1. you never access the "radio" element after POST
2. You have radio valuue="gold" twice (the second time it should be "platinum")
3. You never close your <font> tags out. Actually, since you are using a CSS, you should not need <font> tags anyways. Just make a class for it
4. You have "United States" listed twice in your country select
5. You are using a header() to send the user onto final.php. However, once you leave the current page, all your form data will disappear. You need to either put it in a database or send it to final.php in the URL.
6. Suggestion: encode the password. md5() is a pretty good way to do this. Check out viewtopic.php?t=6278 for examples

What errors are you getting when you run the code now?

--Be back tomorrow (Friday) about 9:00am Eastern Time, US (GMT -5)

Posted: Thu Feb 20, 2003 4:57 pm
by DarkAngelBGE
I wonder if this

Code: Select all

if($domain = "" || $company = "" || $FirstName = "" || $LastName = "" || $addr = "" || $zip = "" || $state = "" || $email = "" || $phone = "" || $fax = "" || $uname = "" || $passwd = "")
shouldn't be this

Code: Select all

if($domain == "" || $company == "" || $FirstName == "" || $LastName == "" || $addr == "" || $zip == "" || $state == "" || $email == "" || $phone == "" || $fax == "" || $uname == "" || $passwd == "")

Posted: Fri Feb 21, 2003 8:07 am
by daven
Ah. Good point. *smacks self in head* I cannot believe I missed that yesterday. Yup, PHP uses == for equality, and = to set values. Come to think of it, Delphi (based on Pascal) is the only language I know that uses = for equality.