Shoutbox

Contact Us Required - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Contact Us Required (/showthread.php?tid=71023)

Contact Us Required by Eddie on 01-25-2007 at 04:31 AM

Hello guys :) I'm still working on my website, i have done a contact us form, and im now trying to make it so all the items on the contact us form are required for succesful "postage". I have this code;

code:
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}
How would i go about making it work with more than just one?

Whole Code If Required:
code:
<?php

// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "admin@haboz.net";
$Subject = "Contact Us";
$Name = Trim(stripslashes($_POST['HabboName']));
$Query = Trim(stripslashes($_POST['Query']));

// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Habbo Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Query: ";
$Body .= $Query;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>


RE: Contact Us Required by WDZ on 01-25-2007 at 04:51 AM

Can't you check the other fields the same way you check $EmailFrom? If any one of them fails the validation, $validationOK will be set to false, and if $validationOK equals false, the script exits.

For example...

code:
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if ($Name == "") $validationOK=false;
if ($Query == "") $validationOK=false;
if (!$validationOK) {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    exit;
}
:p
RE: Contact Us Required by Eddie on 01-25-2007 at 05:17 AM

Thanks WDZ :) Worked (Y)