Page 1 of 1

If....Submit Validation Not Working

Posted: Wed Feb 24, 2010 3:36 pm
by jackponte
Hi,
I introduces the validation for blank fileds on my code but it's not running the if statments. The form get submitted no matter what. I guess the logic is not right but I cannot see the mistake.

Code: Select all

 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>Rogers ESC RMA Portal</title>
    <link rel=stylesheet type="text/css" href="../style.css">
    <style type="text/css">
<!--
.style3 {
    font-size: 12pt;
    font-weight: bold;
    font-style: italic;
}
.style5 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: small;
    font-weight: bold;
    color: #EB0E17;
}
.style7 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: small;
    font-weight: normal;
    color: #000000;
}
.style9 {font-family: Arial, Helvetica, sans-serif; font-size: small; font-weight: normal; color: #000000; }
.style10 {font-size: x-small}
-->
    </style>
 
<!----- Autodate Javascript------------------------------------------>
<script type="text/javascript" src="autoEnterCurrentDate.js"></script>
<!-------------------------------------------------------------------->
<!----- Auto RMA Number Javascript------------------------------------>
<script type="text/javascript" src="autoEnterRMA.js"></script>
<!-------------------------------------------------------------------->
<!------------- Auto Format Phone Number and Postal Code
<script type='text/javascript' src='dFilter.js'></script> --------------->
<!-------------------------------------------------------------------->
<!--------------- Auto Check For Empty Fields --------------------->
<script type='text/javascript' src='autoCheckEmptyFields.js'></script>
<!-------------------------------------------------------------------->
 
<script type="text/javascript">  
 
function useSavedAddress(useSaved){   
document.getElementById('ShipAttention').value = (useSaved) ? js_attention : '';  
document.getElementById('ShipPhone').value = (useSaved) ? js_phone : '';  
document.getElementById('ShipEmail').value = (useSaved) ? js_email : ''; 
document.getElementById('ShipStreet').value = (useSaved) ? js_street : '';  
document.getElementById('ShipAddinfo').value = (useSaved) ? js_addinfo : '';    
document.getElementById('ShipCity').value = (useSaved) ? js_city : '';   
document.getElementById('ShipProv').value = (useSaved) ? js_prov : '';   
document.getElementById('ShipPCode').value = (useSaved) ? js_pcode : '';  
 
return;}  
</script>
 
</head>
 
<body bottommargin="0" leftmargin="0" rightmargin="0" topmargin="0" background="/img/background.jpg">
 
<?php
// Connects to your Database
mysql_connect("localhost", "root", "escrma") or die(mysql_error());
mysql_select_db("rma_portal") or die(mysql_error());
 
//Set Login Variable with the UserID
$loginID = $_COOKIE['ID_my_site'];
 
 
// Collects data from "cust_info" table 
$datausers = mysql_query("SELECT * 
                     FROM cust_info
                     WHERE cust_info.Cust_Username = '$loginID'") 
or die(mysql_error());
 
// puts the "cust_info" info into the $infousers array 
$log_cust_info = mysql_fetch_assoc($datausers);  
 
?> 
 
<!-- Set the Javacript variables with the PHP Array values from the user that just loged in ---> 
<script type="text/javascript">  
 
var js_attention =  "<?php echo $log_cust_info['Def_Attention']; ?>"
var js_phone = "<?php echo $log_cust_info['Def_Phone']; ?>" 
var js_email = "<?php echo $log_cust_info['Def_Email']; ?>"
var js_street = "<?php echo $log_cust_info['Def_Address']; ?>"  
var js_addinfo = "<?php echo $log_cust_info['Def_Additional']; ?>" 
var js_city = "<?php echo $log_cust_info['Def_City']; ?>" 
var js_prov = "<?php echo $log_cust_info['Def_Prov']; ?>"
var js_pcode = "<?php echo $log_cust_info['Def_PCode']; ?>"
   
</script>
 
<table height="123" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<!----- insert logo below ------------------------------------------>
<td><img src="img/backer.jpg" width="574" height="123"></td>
<!------------------------------------------------------------------>
<td width="75%" background="../img/topbg.jpg"><p><img src="img/logo_Rogers.jpg" width="300" height="100" align="right"></p>
  </td>
</tr>
</table>
 
<table height="40" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="75" background="../img/topbar.jpg"></td>
</tr>
</table>
 
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
 
<td width="201"><p><BR>
      <!----- menu, insert links below ------------------------------------------>
  &raquo;<a href="http://www.rogers.com" target="_blank">Rogers.com</a><BR>
  <img src="img/menubar.jpg" width="201" height="11" border="0" alt=""><BR>
  <!--&raquo;<a href="http://www.webaddresshere.com/form.html">Process RMA </a><BR>
<img src="img/menubar.jpg" width="201" height="11" border="0" alt=""><BR>
&raquo;<a href="http://www.webaddresshere.com">Submit</a><BR>
<img src="img/menubar.jpg" width="201" height="11" border="0" alt=""><BR>
<BR>-->
  &raquo;<a href="logout.php">Logout</a><img src="img/menubar.jpg" width="201" height="11" border="0" alt=""><BR>
  </p>
</td>
 
<td width="75%">
    <table width="75%" cellpadding="10" cellspacing="0" border="0">
        <tr valign="top">
            <td>
<!----- content, insert text and content below ------------------------------------------>
<h3 align="center"><img src="img/request_banner.jpg" width="900" height="41"></h3>
<div align="center" class="style3">
  <div align="center">
    <p>Complete the form being sure to provide complete and detailed information</p>
    </div>
</div>
 
<?php
//This code runs if the form has been submitted
if (isset($_POST['Submit'])) {
 
    //This makes sure they did not leave any fields blank
    if ( empty ($_POST['RMANumber'])) {
        echo "<br>There's seems to be a problem generating an RMA number Please contact ESC at 1-877-939-3232 and report the problem";
    }
    if (empty ($_POST['CustomeCompany'])){
        echo "<br>No login detected. Please logout and log back in until you see the <B>Company</b> field populated."; 
    }
    if (empty ($_POST['CustomerName'])){
        echo "<br>No login detected. Please logout and log back in until you see the <B>Customer Name</b> field populated.";
    }
    if (empty ($_POST['DevicePhone'])){
        echo "<br>Please fill the <B>Device Phone #</B> field i.e 999-999-9999";
    }
    if (empty ($_POST['DeviceModel'])){
        echo "<br>Please fill the <B>Model</B> field i.e 9000";
    }
    if (empty ($_POST['DeviceIMEI'])){
        echo "<br>Please fill the <B>IMEI#</B> field";
    }
    if (empty ($_POST['DescDefect'])){
    echo "<br>Please fill the <B>Description of Defect</B> field";
    }
    //Check If Shipping Fields are also Blank
    if (empty ($_POST['ShipAttention'])){
    echo "<br>Please fill the <B>Attention</B> field<br><br>";
    }
    if (empty ($_POST['ShipPhone'])){
    echo "<br>Please fill the <B>Attention</B> field<br><br>";
    }
    if (empty ($_POST['ShipEmail'])){
    echo "<br>Please fill the <B>Attention</B> field<br><br>";
    }
    if (empty ($_POST['ShipStreet'])){
    echo "<br>Please fill the <B>Attention</B> field<br><br>";
    }
    if (empty ($_POST['ShipAddinfo'])){
    echo "<br>Please fill the <B>Attention</B> field<br><br>";
    }
    if (empty ($_POST['ShipCity'])){
    echo "<br>Please fill the <B>Attention</B> field<br><br>";
    }
    if (empty ($_POST['ShipPCode'])){
    echo "<br>Please fill the <B>Attention</B> field<br><br>";
    }
    
}
else
{
 
?> 
 
<form action="formdatapost0.php" method="post" name="form" id="form">
  <label></label><div align="left"></div>
  <table width="90%" border="0" align="center" cellpadding="6" cellspacing="6">
    <tr>
      <td width="49%" height="32"><span class="style5">RMA Information <input name="CustomerID" type="hidden" size="25" VALUE="<?php echo $log_cust_info['Cust_ID'] ?>"></span></td>
      <td width="51%"></td>
    </tr>
    <tr>
      <td colspan="2" align="left" valign="top" class="style7"><table width="684" border="0">
        <tr>
          <td width="135"><span class="style9">
            <label>Date</label>
          </span></td>
          <td width="178"><span class="style9">
            <input name="RMADate" type="text" id="tdate" readonly="readonly">
          </span></td>
          <td width="84"><span class="style9">RMA#</span>
            </label></td>
          <td width="269"><span class="style9">
            <input name="RMANumber" type="text" id="RMAnum" readonly="readonly">
          </span></td>
        </tr>
        <tr>
          <td><span class="style9">Customer Name </span></td>
          <td><input name="CustomerName" type="text" size="20" value="<?php echo $log_cust_info['Cust_Name'] ?>" readonly="readonly"></td>
          <td class="style9">Company </td>
          <td><input name="CustomerCompany" type="text" value="<?php echo $log_cust_info['Cust_Company'] ?>" readonly="readonly"></td>
        </tr>
      </table>
        <div align="center"></div> 
        </td>
      </tr>
    
    <tr>
      <td class="style5"><p>Device Information</p>
        </td>
      <td></td>
    </tr>
    <tr>
      <TH COLSPAN=2 align="left" valign="top"><label class="style7">
 
          </label>
        <table border="0">
          <tr>
            <td><span class="style9">Device Phone #</span></td>
            <td><input name="DevicePhone" type="text" onBlur="this.value=(this.value.match(/^\d{10}/))?this.value.substring(0,3)+'-'+this.value.substring(3,6)+'-'+this.value.substring(6):this.value" size="20" maxlength="12"></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><span class="style9">Device Type</span></td>
            <td><select name="DeviceType">
              <option value="Apple">Apple</option>
              <option value="Globetrotter">Globetrotter</option>
              <option value="HP">HP</option>
              <option value="HTC">HTC</option>
              <option value="Motorola">Motorola</option>
              <option value="Nokia">Nokia</option>
              <option value="Options Wireless">Options Wireless</option>
              <option value="Others">Others</option>
              <option value="Palm">Palm</option>
              <option value="RIM" selected>RIM</option>
              <option value="Samsung">Samsung</option>
              <option value="Sierra Wierless">Sierra Wierless</option>
              <option value="Sony Ericsson">Sony Ericsson</option>
              <option value="Windows">Windows</option>
            </select></td>
            <td><span class="style9">Model</span></td>
            <td><span class="style9">
              <input name="DeviceModel" type="text" size="15">
            </span></td>
            <td class="style9">Color</td>
            <td><span class="style9">
              <input name="DeviceColor" type="text" size="15" id="DeviceColor">
            </span></td>
          </tr>
          <tr>
            <td class="style9">IMEI #</td>
            <td><input name="DeviceIMEI" type="text" onKeyDown="javascript&#058;return dFilter (event.keyCode, this, '###############');" size="15" maxlength="15"></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
        </p>
        <label class="style7"></label>
        <label></label>
        <div align="left"></div>
        <label class="style7"></label>    
        <label class="style7"></label></TH>
    </tr>
    
      
    <tr>
      <td colspan="2"><label><span class="style5">Description of Defect<br>
          </span>
        <textarea name="DescDefect" cols="100" rows="4"></textarea>
      </label></td>
      </tr>
    <tr>
      <td colspan="2" class="style5"><label>Troubleshooting Steps Completed<br>
        <br>
        <span class="style7">
        <input type="checkbox" name="Troubleshooting[ResetDevice]" value="ResetDevice">
        <span class="style7">Reset Device </span></span>
          <input type="checkbox" name="Troubleshooting[SoftwareReload]" value="SoftwareReload">
        <span class="style7">Software Reload</span>
        <span class="style7">
         <input type="checkbox" name="Troubleshooting[WipeDevice]" value="WipeDevice">
        Wipe Device</span>
         <input type="checkbox" name="Troubleshooting[TroubOther]" value="TroubOther">
        <span class="style7">Other<br>
        <br>
        </span>Troubleshooting Notes<br>
        <textarea name="TroubNotes" cols="100" rows="4"></textarea>
              </label></td>
      </tr>
    <tr>
      <td class="style5">Shipping Information </td>
      <td></td>
    </tr>
    <tr>
      <td colspan="2"><table border="0">
        <tr>
          <td colspan="2"><label class="style9">My Default Address
              </label>
            <label>
            <input type="checkbox" name="useSaved" onClick="useSavedAddress(this.checked);" />
            </label>
            <label class="style9">            </label></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><span class="style9">Attention</span></td>
          <td width="274"> <input name="ShipAttention" id="ShipAttention" type="text" size="45" VALUE="" > </td>    
          <td width="31">&nbsp;</td>
          <td width="60">&nbsp;</td>
          <td width="71">&nbsp;</td>
          <td width="42">&nbsp;</td>
        </tr>
        <tr>
          <td><span class="style9">Contact Phone</span></td>
          <td><input name="ShipPhone" id="ShipPhone" type="text" onBlur="this.value=(this.value.match(/^\d{10}/))?this.value.substring(0,3)+'-'+this.value.substring(3,6)+'-'+this.value.substring(6):this.value" size="20" maxlength="12"></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><span class="style9">Contact Email</span></td>
          <td colspan="2"><span class="style9">
            <input name="ShipEmail" id="ShipEmail" type="text" size="45">
          </span></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><span class="style9">Street Address</span></td>
          <td><input name="ShipStreet" id="ShipStreet" type="text" size="45"></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><span class="style9">Additional Info</span></td>
          <td><span class="style9">
            <input name="ShipAddinfo" id="ShipAddinfo" type="text" size="45">
          </span></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><span class="style9">City</span></td>
          <td><span class="style9">
            <input name="ShipCity" id="ShipCity" type="text" size="30" >
          </span></td>
          <td><span class="style9">Prov.</span></td>
          <td><span class="style9">
            <select name="ShipProv" id="ShipProv">
              <option value="AB">AB</option>
              <option value="BC">BC</option>
              <option value="MB">MB</option>
              <option value="NB">NB</option>
              <option value="NFL">NFL</option>
              <option value="NS">NS</option>
              <option value="ON">ON</option>
              <option value="PEI">PEI</option>
              <option value="QC">QC</option>
              <option value="SK">SK</option>
                                                                        </select>
          </span></td>
          <td><span class="style9">Postal Code</span></td>
          <td><input name="ShipPCode" id="ShipPCode" type="text" size="7" maxlength="7"></td>
        </tr>
      </table>
        <label class="style7"></label>
        <label></label></td>
      </tr>
    <tr>
      <td colspan="2"><label><span class="style5">Additional Notes<br>
      </span>
          <textarea name="ShipAddNotes" cols="100" rows="3"></textarea>
          <br>
      </label></td>
      </tr>
    <tr>
      <td colspan="2"><label for="Submit"></label>
        <input type="submit" name="Submit" value="Submit" id="Submit"></td>
    </tr>
  </table>
  </form>
</td>
        </tr>
    </table></td>
</tr>
</table>
  <?php
}
?>
</body>
</html>
 
 
Thanks for your help

Peace,

JP

Re: If....Submit Validation Not Working

Posted: Wed Feb 24, 2010 3:52 pm
by Kurby
Are you saying every time you submit it still prints the form? Have you tried a print_r($_POST) to make sure Submit is getting set?

Re: If....Submit Validation Not Working

Posted: Wed Feb 24, 2010 3:59 pm
by jackponte
Hi,
Thanks for the fast reply. Yes. The form submits and the new page shows.

Were would I print $POST?

Peace,

Re: If....Submit Validation Not Working

Posted: Wed Feb 24, 2010 4:01 pm
by AbraCadaver
Is the above code contained within formdatapost0.php?

Re: If....Submit Validation Not Working

Posted: Wed Feb 24, 2010 4:14 pm
by jackponte
No, This code is posted in the page were the form is.

Re: If....Submit Validation Not Working

Posted: Wed Feb 24, 2010 4:18 pm
by Kurby
jackponte wrote:Hi,
Thanks for the fast reply. Yes. The form submits and the new page shows.

Were would I print $POST?

Peace,
Somewhere before the if(isset($_POST['Submit']))

Re: If....Submit Validation Not Working

Posted: Wed Feb 24, 2010 4:27 pm
by jackponte
Hi,
There nothing on it. I can see full in the formtodata0.php but at that time the form has been submited.
Peace,

Jack P

Re: If....Submit Validation Not Working

Posted: Wed Feb 24, 2010 4:35 pm
by AbraCadaver
jackponte wrote:Hi,
There nothing on it. I can see full in the formtodata0.php but at that time the form has been submited.
Peace,

Jack P
What? What is the name of the file that contains the code that you have shown?

Re: If....Submit Validation Not Working

Posted: Wed Feb 24, 2010 4:49 pm
by jackponte
The name of the file is form5.php

Re: If....Submit Validation Not Working

Posted: Wed Feb 24, 2010 4:56 pm
by AbraCadaver
OK, if you look at the <form action="formdatapost0.php", it is sending the data to formdatapost0.php, so you need to put the if (isset($_POST['Submit'])) and validations in that file.