Jump to content


Photo

Placing error messages in input form after submission


  • Please log in to reply
11 replies to this topic

#1 dc_jt

dc_jt
  • Members
  • PipPipPip
  • Advanced Member
  • 290 posts

Posted 17 October 2006 - 12:44 PM

Hi

I have an input form which displays errors if one or more fields are not completed. E.g. Please enter name.

However, these appear above the input form which then moves the input form further down the page and out of place. Is there anyway, once the form is submitted, the error messages are shown inside the input form (well inside the outline of it) replacing the input values name, email etc, with a button to go back which then displays the input form with the missing input?

If you understood that, any help would be great thanks

#2 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 17 October 2006 - 12:49 PM

post your code so we can take a look.

Ray

#3 dc_jt

dc_jt
  • Members
  • PipPipPip
  • Advanced Member
  • 290 posts

Posted 17 October 2006 - 12:58 PM

I cant for some reason it says URL could not be retrieved??

#4 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 17 October 2006 - 01:03 PM

open your page for editing and copy and paste the code here.

Ray

#5 dc_jt

dc_jt
  • Members
  • PipPipPip
  • Advanced Member
  • 290 posts

Posted 17 October 2006 - 01:08 PM

I did do that and when i click post it says:

The requested URL could not be retrieved

While trying to retrieve the URL: http://www.phpfreaks...rums/index.php?

The following error was encountered:

    * Read Error

The system returned:

    (104) Connection reset by peer

An error condition occurred while reading data from the network. Please retry your request.

Your cache administrator is root.

#6 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 17 October 2006 - 01:21 PM

did you put it between the "code" tags

Ray

#7 dc_jt

dc_jt
  • Members
  • PipPipPip
  • Advanced Member
  • 290 posts

Posted 17 October 2006 - 01:23 PM

yes  ???

#8 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 17 October 2006 - 01:43 PM

I think there are sites out there that will host a script for others to view. You can try those. I have had the same problem in the past and it was a certain part of my code that the site did not like. Maybe you can break it up and post it that way till you come across the part that will not work.

Ray

#9 dc_jt

dc_jt
  • Members
  • PipPipPip
  • Advanced Member
  • 290 posts

Posted 17 October 2006 - 01:49 PM

Well I dont actually have an error. When I say error messages, they are there on purpose because the user has not entered all their details correctly. For example, if they entered nothing it would say:

# Please enter your Name
# Please enter a valid Email address
# Please enter your Address
# Please enter your Business Name
# Please enter your Type of Business

However, this is displayed directly above the input form.

Instead I want it to be displayed INSIDE the form, replacing the Name, Email, Address etc fields and then having a back button which then brings these fields back for the user to input correctly??

Do you understand? Sorry its confusing, but is this possible?

Thanks

#10 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 17 October 2006 - 01:54 PM

i cannot help if I do not see the code you are using. We need the actual code.

Ray

#11 dc_jt

dc_jt
  • Members
  • PipPipPip
  • Advanced Member
  • 290 posts

Posted 17 October 2006 - 01:57 PM

This is the form in the index file

<form name="myform" method="post" action="<?=$_SERVER['PHP_SELF']?>">
		  
		  <div class="home_text">
		  <?php
	 if ($sMode == 'complete')
	 {
	 	echo '<div class="complete">Thank You for submitting your details.</div>';
	 
	 }
	 else
	 {	
		?>
		
	<? if(is_array($aErrors) && count($aErrors) > 0)
		{
		?>
		
		<ul>
		<?
			foreach($aErrors as $sError)
			{
				echo '<li>'.$sError.'<br></li>';
			} // end foreach
		?></ul><?
		} //end if (is_array($aErrors)...
		?>		
				<div class="formwrapper">
				  <div class="textlabel">Name</div><div class="formlabel"> <input name="Name" type="text" class="dataform" value="<?=(stripslashes($_POST['Name']))?>" />
				</div>
				<div class="textlabel">Email</div>
				<div class="formlabel"> <input name="Email" type="text" class="dataform" value="<?=(stripslashes($_POST['Email']))?>"/>
				</div>
				<div class="textlabel">Address</div>
				<div class="formlabel"> 
				  <textarea name="Address" rows="2" wrap="virtual" class="dataform"><?=(stripslashes($_POST['Address']))?></textarea>
				</div>
				<div class="textlabel">Business Name </div>
				<div class="formlabel"> <input name="Business_Name" type="text" class="dataform" value="<?=(stripslashes($_POST['Business_Name']))?>"/>
				</div>
				<div class="textlabel">Type of Business </div>
				<div class="formlabel"> <input name="Type_of_Business" type="text" class="dataform" value="<?=(stripslashes($_POST['Type_of_Business']))?>"/>
				</div>
				<div class="textlabel">Comments</div>
				<div class="formlabel"> 
				  <textarea name="Comments" rows="2" wrap="virtual" class="dataform"><?=(stripslashes($_POST['Comments']))?></textarea>
				</div>
				<div class="textlabel">&nbsp;</div><div class="formlabel">
				  <input name="Submit" type="submit" class="databut" value="Submit" />
				    <input type="hidden" name="mode" value="apply" />
				    	<br class="clear"/>
		</form>



This is the RCLTblClients class

private function ValidateClientData($aPostData)
	{
		$aErrors = array();
		
		if(!$aPostData['Name'])
		{
			$aErrors['Name']='Please enter your Name';
		}
		if(validateemail($aPostData['Email'])===false)
		{
			$aErrors['Email']='Please enter a valid Email address';}
		//if(validateemail(!$aPostData['Email'])===false)
		//{
		//	$aErrors['Email']='Please enter your Email';
		//}
		if(!$aPostData['Address'])
		{
			$aErrors['Enquiry']='Please enter your Address';
		}	
		if(!$aPostData['Business_Name'])
		{
			$aErrors['Business_Name']='Please enter your Business Name';
		}
		if(!$aPostData['Type_of_Business'])
		{
			$aErrors['Type_of_Business']='Please enter your Type of Business';
		}
		
		
		if (count($aErrors) > 0) return array(false, $aErrors);
		
		return array(true);
	}
}

Is that enough for you? (*Hope this works*)

#12 dc_jt

dc_jt
  • Members
  • PipPipPip
  • Advanced Member
  • 290 posts

Posted 17 October 2006 - 02:30 PM

Any idea Ray or anyone else?

Thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users