shoopaie Posted December 6, 2010 Report Share Posted December 6, 2010 Can anyone tell me why when a value is submitted to these fields, the error array still populates and then is echoes? Is there an issue in this code? if(isset($_REQUEST['submitted'])){ if(empty($_POST['first_name'])){ $errors[] = "You forgot to enter your first name"; }else{ $fn = trim($_POST['first_name']); }//end of check on first_name if(empty($_POST['last_name'])){ $errors[] = "You forgot to enter your last name"; }else{ $ln = trim($_POST['last_name']); }//end check for last_name if(empty($_POST['phone'])){ $errors[] = "Please enter a valid phone number XXX-XXX-XXXX"; }else{ $phone = trim($_POST['phone']); }//end check for numeric phone number if(empty($_POST['ftp_username'])){ $errors[] = "Please go back and enter an FTP username"; }else{ $ftpun = trim($_POST['ftp_username']); } if(empty($errors)){ if($_POST["service"] == "storage"){ echo '<div id="ftp_questions"> <form action="" method="" /> Name of Subfolder:<br /> slayersservices.com/<input type="text" size="10" name="subfolder" /><br /><br /> <b>If you need database access:</b><br /><br /> Username:<br /><input type="text" name="database_username" maxlength="30" /><br /> Password:<br /><input type="password" name="db_pass1" maxlength="30" /><br /> Confirm Password:<br /><input type="password" name="db_pass2" maxlength="30" /><br /><br /> <b>Desired Subdomain</b><br /> <input type="text" size="10" name="subfolder" />.slayersservices.com </form> </div>'; }//end if statement to check if input is storage intended }else{ foreach($errors as $msg){ echo "- $msg<br />"; } } }else{ echo "it is not submitted"; }//end of main if to see if submitted has taken place I understand the code is weak, and probably messy, i'm just trying to jump in head-first. Thanks for the look. Quote Link to comment Share on other sites More sharing options...
shoopaie Posted December 6, 2010 Author Report Share Posted December 6, 2010 Can anyone tell me why when a value is submitted to these fields, the error array still populates and then is echoes? Is there an issue in this code? if(isset($_REQUEST['submitted'])){ if(empty($_POST['first_name'])){ $errors[] = "You forgot to enter your first name"; }else{ $fn = trim($_POST['first_name']); }//end of check on first_name if(empty($_POST['last_name'])){ $errors[] = "You forgot to enter your last name"; }else{ $ln = trim($_POST['last_name']); }//end check for last_name if(empty($_POST['phone'])){ $errors[] = "Please enter a valid phone number XXX-XXX-XXXX"; }else{ $phone = trim($_POST['phone']); }//end check for numeric phone number if(empty($_POST['ftp_username'])){ $errors[] = "Please go back and enter an FTP username"; }else{ $ftpun = trim($_POST['ftp_username']); } if(empty($errors)){ if($_POST["service"] == "storage"){ echo '<div id="ftp_questions"> <form action="" method="" /> Name of Subfolder:<br /> slayersservices.com/<input type="text" size="10" name="subfolder" /><br /><br /> <b>If you need database access:</b><br /><br /> Username:<br /><input type="text" name="database_username" maxlength="30" /><br /> Password:<br /><input type="password" name="db_pass1" maxlength="30" /><br /> Confirm Password:<br /><input type="password" name="db_pass2" maxlength="30" /><br /><br /> <b>Desired Subdomain</b><br /> <input type="text" size="10" name="subfolder" />.slayersservices.com </form> </div>'; }//end if statement to check if input is storage intended }else{ foreach($errors as $msg){ echo "- $msg<br />"; } } }else{ echo "it is not submitted"; }//end of main if to see if submitted has taken place I understand the code is weak, and probably messy, i'm just trying to jump in head-first. Thanks for the look. Quote Link to comment Share on other sites More sharing options...
shoopaie Posted December 6, 2010 Author Report Share Posted December 6, 2010 Problem solved. Answer was in the html form. Apparently you can't create 2 forms and expect 1 submit button to submit all info in both forms Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.