<br> not working?

Discussion in 'Web Design' started by mischievousx3, Sep 25, 2014.

to remove all ads.
  1. mischievousx3

    mischievousx3 New Member

    Messages:
    3
    Hi guys,

    I'm trying to figure out why <br> isn't working on one of my pages (http://www.mischievous-designs.net/hosting-form.php)

    You can see where the white text is too close to the images. I checked for unclosed tags and found none but maybe I'm missing something here.

    Anyways, this is the code for that whole page:
    Code:
    			
    			<td valign="top" id="content">
    			<div id="content1">
    			<br>
    			<h3>Packages</h3>
    			<br>
    			<img src="hosting/packages/package1.jpg" align="left" style="margin-left: 15px;"></img>
    			<img src="hosting/packages/package2.jpg" align="right" style="margin-right: 15px;"></img>
    	
    			<img src="hosting/packages/package3.jpg" align="left" style="margin-left: 15px; margin-top:20px;"></img>
    			<img src="hosting/packages/package4.jpg" align="right" style="margin-right: 15px; margin-top:20px;"></img>
    			<br><br>
    </div>
    	
    						<?php
    // OPTIONS - PLEASE CONFIGURE THESE BEFORE USE!
    
    $yourEmail = "[email protected]"; // the email address you wish to receive these mails through
    $yourWebsite = "Mischievous-Designs"; // the name of your website
    $thanksPage = ''; // URL to 'thanks for sending mail' page; leave empty to keep message on the same page 
    $maxPoints = 4; // max points a person can hit before it refuses to submit - recommend 4
    $requiredFields = "name,email,comments"; // names of the fields you'd like to be required as a minimum, separate each field with a comma
    
    
    // DO NOT EDIT BELOW HERE
    $error_msg = array();
    $result = null;
    
    $requiredFields = explode(",", $requiredFields);
    
    function clean($data) {
    	$data = trim(stripslashes(strip_tags($data)));
    	return $data;
    }
    function isBot() {
    	$bots = array("Indy", "Blaiz", "Java", "libwww-perl", "Python", "OutfoxBot", "User-Agent", "PycURL", "AlphaServer", "T8Abot", "Syntryx", "WinHttp", "WebBandit", "nicebot", "Teoma", "alexa", "froogle", "inktomi", "looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory", "Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot", "crawler", "www.galaxy.com", "Googlebot", "Scooter", "Slurp", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz");
    
    	foreach ($bots as $bot)
    		if (stripos($_SERVER['HTTP_USER_AGENT'], $bot) !== false)
    			return true;
    
    	if (empty($_SERVER['HTTP_USER_AGENT']) || $_SERVER['HTTP_USER_AGENT'] == " ")
    		return true;
    	
    	return false;
    }
    
    if ($_SERVER['REQUEST_METHOD'] == "POST") {
    	if (isBot() !== false)
    		$error_msg[] = "No bots please! UA reported as: ".$_SERVER['HTTP_USER_AGENT'];
    		
    	// lets check a few things - not enough to trigger an error on their own, but worth assigning a spam score.. 
    	// score quickly adds up therefore allowing genuine users with 'accidental' score through but cutting out real spam :)
    	$points = (int)0;
    	
    	$badwords = array("adult", "beastial", "bestial", "blowjob", "clit", "cum", "cunilingus", "cunillingus", "cunnilingus", "cunt", "ejaculate", "fag", "felatio", "fellatio", "****", "fuk", "fuks", "gangbang", "gangbanged", "gangbangs", "hotsex", "hardcode", "jism", "jiz", "orgasim", "orgasims", "orgasm", "orgasms", "phonesex", "phuk", "phuq", "pussies", "pussy", "spunk", "xxx", "viagra", "phentermine", "tramadol", "adipex", "advai", "alprazolam", "ambien", "ambian", "amoxicillin", "antivert", "blackjack", "backgammon", "texas", "holdem", "poker", "carisoprodol", "ciara", "ciprofloxacin", "debt", "dating", "porn", "link=", "voyeur", "content-type", "bcc:", "cc:", "document.cookie", "onclick", "onload", "javascript");
    
    	foreach ($badwords as $word)
    		if (
    			strpos(strtolower($_POST['comments']), $word) !== false || 
    			strpos(strtolower($_POST['name']), $word) !== false
    		)
    			$points += 2;
    	
    	if (strpos($_POST['comments'], "http://") !== false || strpos($_POST['comments'], "www.") !== false)
    		$points += 2;
    	if (isset($_POST['nojs']))
    		$points += 1;
    	if (preg_match("/(<.*>)/i", $_POST['comments']))
    		$points += 2;
    	if (strlen($_POST['name']) < 3)
    		$points += 1;
    	if (strlen($_POST['comments']) < 15 || strlen($_POST['comments'] > 1500))
    		$points += 2;
    	if (preg_match("/[bcdfghjklmnpqrstvwxyz]{7,}/i", $_POST['comments']))
    		$points += 1;
    	// end score assignments
    
    
    	if (!empty($_POST['name']) && !preg_match("/^[a-zA-Z-'\s]*$/", stripslashes($_POST['name'])))
    		$error_msg[] = "The name field must not contain special characters.\r\n";
    	if (!empty($_POST['email']) && !preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i', strtolower($_POST['email'])))
    		$error_msg[] = "That is not a valid e-mail address.\r\n";
    	if (!empty($_POST['url']) && !preg_match('/^(http|https):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i', $_POST['url']))
    		$error_msg[] = "Invalid website url.\r\n";
    	
    	if ($error_msg == NULL && $points <= $maxPoints) {
    		$subject = "Hosting Application";
    		
    		$message = "You received this e-mail message through your website: \n\n";
    		foreach ($_POST as $key => $val) {
    			if (is_array($val)) {
    				foreach ($val as $subval) {
    					$message .= ucwords($key) . ": " . clean($subval) . "\r\n";
    				}
    			} else {
    				$message .= ucwords($key) . ": " . clean($val) . "\r\n";
    			}
    		}
    		$message .= "\r\n";
    		$message .= 'IP: '.$_SERVER['REMOTE_ADDR']."\r\n";
    		$message .= 'Browser: '.$_SERVER['HTTP_USER_AGENT']."\r\n";
    		$message .= 'Points: '.$points;
    
    		if (strstr($_SERVER['SERVER_SOFTWARE'], "Win")) {
    			$headers   = "From: $yourEmail\r\n";
    		} else {
    			$headers   = "From: $yourWebsite <$yourEmail>\r\n";	
    		}
    		$headers  .= "Reply-To: {$_POST['email']}\r\n";
    
    		if (mail($yourEmail,$subject,$message,$headers)) {
    			if (!empty($thanksPage)) {
    				header("Location: $thanksPage");
    				exit;
    			} else {
    				$result = 'Your mail was successfully sent.';
    				$disable = true;
    			}
    		} else {
    			$error_msg[] = 'Your mail could not be sent this time. ['.$points.']';
    		}
    	} else {
    		if (empty($error_msg))
    			$error_msg[] = 'Your mail looks too much like spam, and could not be sent this time. ['.$points.']';
    	}
    }
    function get_data($var) {
    	if (isset($_POST[$var]))
    		echo htmlspecialchars($_POST[$var]);
    }
    ?>
    <!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" xml:lang="en" lang="en">
    <head>
    	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
    	<title>My Email Form</title>
    	
    	<style type="text/css">
    		p.error, p.success {
    			padding: 10px;
    			border: 1px solid;
    		}
    		p.error {
    			background: #ffc0c0;
    			color: #900;
    		}
    		p.success {
    			background: #82166f;
    			color: #ffffff;
    			align:center;
    		}
    	</style>
    </head>
    <body>
    
    
    <?php
    if (!empty($error_msg)) {
    	echo '<p class="error">ERROR: '. implode("<br />", $error_msg) . "</p>";
    }
    if ($result != NULL) {
    	echo '<p class="success">'. $result . "</p>";
    }
    ?>
    
    
    <table border="0" cellspacing="0" cellpadding="5" align="center">
    <center><b>The ones are that are bolded are required</b></center>
    <form action="<?php echo basename(__FILE__); ?>" method="post">
    <noscript>
    		<p><input type="hidden" name="nojs" id="nojs" /></p>
    </noscript>
    
    
    	<tr><td><b>Name:</b> </td>
    		<td><input type="text" name="name" id="name" size="30" value="<?php get_data("name"); ?>"><br /></td></tr>
    	
    	<tr><td><b>E-mail:</b> </td>
    		<td><input type="text" name="email" id="email" size="30" value="<?php get_data("email");?>"><br /></td></tr>
    	
    	<tr><td>Website URL: <br></td>
    		<td><input type="text" name="url" id="url" size="30" value="<?php get_data("url"); ?> include http://" onfocus="if(this.value==this.defaultValue)this.value=''"    
    onblur="if(this.value=='')this.value=this.defaultValue"><br /></td></tr>
    	
    	<tr><td><b>Hosting Package:</b></td>
    		<td><select name="Avatar Size:" class="form" rows="10">
    		<option selected="selected">Please Choose:</option>
       		<option value="Beginner Package">Beginner Package</option>
       		<option value="Intermediate Package">Intermediate Package</option>
      		<option value="Advanced Package">Advanced Package</option>
    		<option value="Expert Package">Expert Package</option>
    		</select></td></tr>
    	
    		<tr><td><b>Desired FTP Username:</b> <br></td>
    		<td><input type="text" name="FTP Username" id="url" size="30" ><br /></td></tr>
    		
    				<tr><td><b>Desired FTP Password:</b><br></td>
    		<td><input type="text" name="FTP-Password" id="url" size="30" value="min of 7 characters" onfocus="if(this.value==this.defaultValue)this.value=''"    
    onblur="if(this.value=='')this.value=this.defaultValue"><br /></td></tr>
    		
    						<tr><td><b>Desired Email:</b> <br></td>
    		<td><input type="text" name="Email-Username" id="url" size="30" value="only if you want" onfocus="if(this.value==this.defaultValue)this.value=''"    
    onblur="if(this.value=='')this.value=this.defaultValue"><br /></td></tr>
    		
    						<tr><td><b>Desired Email Password:</b> <br></td>
    		<td><input type="text" name="Email-Password" id="url" size="30" value="min of 7 characters" onfocus="if(this.value==this.defaultValue)this.value=''"    
    onblur="if(this.value=='')this.value=this.defaultValue"><br /></td></tr>
    	
    	<tr><td>Comments/Further Instructions:<br> </td>
    		<td><textarea name="comments" id="comments" rows="5" cols="30" value="<?php get_data("comments"); ?>"></textarea><br /></td></tr></table>
    
    <p style="margin-left: 310px;">
    	<input type="submit" name="submit" id="submit" value="Send" <?php if (isset($disable) && $disable === true) echo ' disabled="disabled"'; ?> />
    	<input type="reset" value="Clear" name="clear" />
    </p>
    </form>
    
    
    </body>
    </html>
    			
    			</td>
    
    	
    
    Thanks for your help
     
  2. chrishirst

    chrishirst Well-Known Member Staff Member

    Messages:
    2,662
    Why not simply use the margins of the heading elements rather than peppering the source with line breaks, which is very 1995 style.

    Though I DO suggest that you fix the two doctype declarations, BOTH in the wrong place. along with the multiple html, body and head elements in the code BEFORE you start trying to fix minor aesthetic points.

    Or maybe hire a competent developer to augment your design skills.
     
  3. mischievousx3

    mischievousx3 New Member

    Messages:
    3
    I've removed those doctype declarations, html, body and head elements. It hasn't fixed the problem. When I tried removing the images from the page temporarily, <br> was working. Seems the problem only persists when those images are there. But they have been closed, so why?
     
  4. chrishirst

    chrishirst Well-Known Member Staff Member

    Messages:
    2,662
    <img> elements are self closing.

    You are using a DTD for XHTML yet have tags in the code that were deprecated before XHTML was even a W3c working group project.

    You use tables for layout, your whole coding style is 'last century' the DTD is STILL in the wrong place there are TWO <html> elements.

    This thread is a good example of why designers should design and developers should develop. So do yourself and future clients a big, big favour and just give up coding, stick to what you are patently very good at ... Designing.

    If you learn HTML and CSS to a point where you know it's limitations, you will be a worse designer, because you will be aware of what cannot be done easily so you will limit your imagination to be within those parameters.

    The design is quite stunning, but the coding is horrendous, I would love to get a high quality PDF or a layered TIFF of the design and see If I could do it justice as a coded layout :)
     
  5. mischievousx3

    mischievousx3 New Member

    Messages:
    3
    problem has been solved.
     
  6. chrishirst

    chrishirst Well-Known Member Staff Member

    Messages:
    2,662
    Ermmm no.

    It may look 'solved' but that abysmal coding WILL come back to haunt you on some device or other.
     

Share This Page