Jump to content

Is my code wrong?


shoopaie

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...