SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 27 of 27
  1. #26
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    My big questions would be where's your FIELDSET, and what the devil makes that a TABLE in the first place? Semantic markup could go a LONG ways towards cleaning that up into something functional instead of all those extra tags for NOTHING. LABEL and INPUT already have semantic meanings, there is NO reason to be wrapping those with other tags that have meanings like tables or lists.

    ... as could an echo statement and axing all that annoying hard to follow <?php ?> nonsense -- but that's probably just me; I'd like to see <?php and ?> removed from PHP in it's entirety... also on 'email' you're opening a quote before value that shouldn't be there.

    NOT that you should be writing new code in transitional anyways -- this isn't 1997.

    REGARDLESS of what you are doing for styling, it is VERY unlikely you should be using much more than:

    Code:
    } else {
    
    	echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html
    	xmlns="http://www.w3.org/1999/xhtml"
    	lang="en"
    	xml:lang="en"
    ><head>
    
    <meta
    	http-equiv="Content-Type"
    	content="text/html; charset=utf-8"
    />
    
    <meta
    	http-equiv="Content-Language"
    	content="en"
    />
    
    <link
    	type="text/css"
    	rel="stylesheet"
    	href="screen.css"
    	media="screen,projection,tv"
    />
    
    <title>
    	Demo Form
    </title>
    
    </head><body> 
    
    <form action="',$_SERVER['PHP_SELF'],'" method="POST"> 
    	<fieldset>
    	
    		<div class="',form_row_class('NAME',$errors),'" > 
    			<label for="NAME">Name</label>
    			<input 
    				type="text"
    				name="NAME"
    				id="NAME"
    				value="',(isset($_POST['NAME']) ? hsc($_POST['NAME']) : ''),'"
    			/> 
    			',error_for('NAME',$errors),'
    		</div>
    		 
    		<div class="',form_row_class('TELEPHONE',$errors),'"> 
    			<label for="TELEPHONE">Telephone</label>
    			<input
    				type="text"
    				name="TELEPHONE"
    				id="TELEPHONE"
    				value="',(isset($_POST['TELEPHONE']) ? hsc($_POST['TELEPHONE']) : ''),'"
    			/> 
    			',error_for('TELEPHONE',$errors),' 
    		</div>
    		 
    		<div class="',form_row_class('EMAIL',$errors),'"> 
    			<label for="EMAIL">Email Address</label>
    			<input
    				name="EMAIL"
    				id="EMAIL"
    				type="text"
    				value="',(
    					isset($_POST['EMAIL']) ? hsc($_POST['EMAIL']) : ''
    				),'"
    			/> 
    			',error_for('EMAIL',$errors),'
    		</div>
    		 
    		<div class="',form_row_class('COMMENTS',$errors),'"> 
    			<label for="COMMENTS">Comments</label>
    			<textarea
    				name="COMMENTS"
    				id="COMMENTS"
    			>',(
    				isset($_POST['COMMENTS']) ? hsc($_POST['COMMENTS']) : ''
    			),'</textarea>
    			',error_for('COMMENTS',$errors),' 
    		</div> 
    		
    		<input type="submit" value="Go!" class="submit" /> 
    		 
    	</fieldset> 
    </form> 
    
    </body></html>';
    
    }
    
    ?>
    for the markup. Basically drag it kicking and screaming into THIS century.

  2. #27
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spikeZ View Post
    You need to move the comments up into the PREVIOUS else.
    What the code says at the minute is:

    if the form has been sent
    -- process it
    -- insert into the database
    -- redirect
    otherwise
    --display the message...

    So you would end up with:

    Code PHP:
     
          header("Location: thankyou.php"); 
        exit; 
        }  
      } else { 
        echo "Sorry, your comment could not be saved at this time"; 
     
       //  DEBUGGING ONLY - DISABLE IN PRODUCTION SITE 
       echo "<br/><br /> MySQLi Error: " . mysqli_error($conn); 
       } 
      } // <-- closes the if(SERVER METHOD) line
    I generally use latin1_Swedish_ci because it is the default setting and has generally worked for me. I'm sure if you ask over in the MySQL forum then you would get a much more comprehensive answer!!
    Thanks. Work fine, only trouble is if the data entered does not validate (according to my form validation) then the error message appears saying can not write to database which I guess it true, but would be better if it happened once all data is valid.

    Hi deathshadow60. Yeah I realise there is a fair bit of cleaning up that is needed, but just wanted the basic strucutre to get right first. Thanks for pointing out thought and some very good points which I will fix.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •