Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

GAH! HTML tables... problems with the code... yes, I'm lame :(

  • 10-07-2006 1:28pm
    #1
    Closed Accounts Posts: 27,857 ✭✭✭✭


    Yeh, I'm workin on this site, and as usual tables are wrecking my head!!!

    Here's the code...
    <html>
    <head>
    <title>Test</title>
    
    <STYLE TYPE="text/css"><!--
    A.Toplinks:link {color: #000000; text-decoration: none; font-family: "Century Gothic"; font-size: 10pt}
    A.Toplinks:active {color: #000000; text-decoration: none; font-family: "Century Gothic"; font-size: 10pt}
    A.Toplinks:visited {color: #000000; text-decoration: none; font-family: "Century Gothic"; font-size: 10pt}
    
    
    --></STYLE>
    
    </head>
    <body bgcolor=#000000>
    
    <center>
    <table width=75% border=1 bgcolor=#FFFFFF  cellpadding=0 cellspacing=0>
    <tr>
    	<td width=15% align=left valign=bottom>
    		<img src=my_logo3.jpg alt="MYSITE.net logo" border=0 width=145 height=180>
    	</td>
    	<td width=85%>
    
    		<table border=1 width=100% cellpadding=0 cellspacing=0>
    		<tr height=160>
    			<td colspan=5 align=center>
    			Google Ads banner can go here
    			</td>
    		</tr>
    		<tr height=20>
    			<td align=left valign=bottom width=20%>
    			<a href=test.html><img src=tab_home3.gif alt="Home" width=68 height=24 border=0></a>
    			</td>
    			<td align=left valign=bottom width=20%>
    			<a href=test.html class=Toplinks>&nbsp;&nbsp;Submit</a>
    			</td>
    			<td align=left valign=bottom width=20%>
    			<a href=test.html class=Toplinks>Database</a>
    			</td>
    			<td align=left valign=bottom width=20%>
    			<a href=test.html class=Toplinks>&nbsp;About</a>
    			</td>
    			<td align=left valign=bottom width=20%>
    			<a href=test.html class=Toplinks>Contact</a>
    			</td>
    		</tr>
    		</table>
    	
    	</td>
    </tr>
    <tr>
    	<td align=right background=tab_bar.gif colspan=3>
    		LINKS BANNER GOES HERE!
    	</td>
    </tr>
    <tr>
    	<td align=left valign=top width=20%>
    		News
    	</td>
    
    	<td valign=top width=60%>
    		<center>Welcome to MYSITE.net</center>
    	</td>
    
    	<td valign=top width=20%>
    		Ads
    	</td>
    </tr>
    <tr>
            <td>
             HOME | CONTACT | SUBMIT | ETC | COPYRIGHT
            </td>
    </tr>
    </table>
    </center>
    
    
    </body>
    </html>
    

    And I want it to be laid out like in the attached image.

    As you can see it's not working too well!

    Can someone just point out where I'm goin wrong? I know this is all newbie lame-ass sh*t for most of you :p, but I'm still stuck with html for the most part! It was working fine yesterday and then I started tweaking it a bit and it all went to the sh*ts!

    Cheers


Comments

  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    there ya go

    <html>
    <head>
    <title>Test</title>
    
    <STYLE TYPE="text/css"><!--
    A.Toplinks:link {color: #000000; text-decoration: none; font-family: "Century Gothic"; font-size: 10pt}
    A.Toplinks:active {color: #000000; text-decoration: none; font-family: "Century Gothic"; font-size: 10pt}
    A.Toplinks:visited {color: #000000; text-decoration: none; font-family: "Century Gothic"; font-size: 10pt}
    
    
    --></STYLE>
    
    </head>
    <body bgcolor=#000000>
    
    <center>
    <table width=75% border=1 bgcolor=#FFFFFF  cellpadding=0 cellspacing=0>
    <tr>
    	<td width=15% align=left valign=bottom>
    		<img src=my_logo3.jpg alt="MYSITE.net logo" border=0 width=145 height=180>
    	</td>
    	<td colspan="2">
    
    		<table border=1 width=100% cellpadding=0 cellspacing=0>
    		<tr height=160>
    			<td colspan=5 align=center>
    			Google Ads banner can go here
    			</td>
    		</tr>
    		<tr>
    			<td align=left valign=bottom width=20%>
    			<a href=test.html><img src=tab_home3.gif alt="Home" width=68 height=24 border=0></a>
    			</td>
    			<td align=left valign=bottom width=20%>
    			<a href=test.html class=Toplinks>&nbsp;&nbsp;Submit</a>
    			</td>
    			<td align=left valign=bottom width=20%>
    			<a href=test.html class=Toplinks>Database</a>
    			</td>
    			<td align=left valign=bottom width=20%>
    			<a href=test.html class=Toplinks>&nbsp;About</a>
    			</td>
    			<td align=left valign=bottom width=20%>
    			<a href=test.html class=Toplinks>Contact</a>
    			</td>
    		</tr>
    		</table>
    	
    	</td>
    </tr>
    <tr>
    	<td align=right background=tab_bar.gif colspan=3>
    		LINKS BANNER GOES HERE!
    	</td>
    </tr>
    <tr>
    	<td align=left valign=top width=20%>
    		News
    	</td>
    
    	<td valign=top>
    		<center>Welcome to MYSITE.net</center>
    	</td>
    
    	<td valign=top width=20%>
    		Ads
    	</td>
    </tr>
    <tr>
            <td colspan="3">
             HOME | CONTACT | SUBMIT | ETC | COPYRIGHT
            </td>
    </tr>
    </table>
    </center>
    
    
    </body>
    </html>
    


  • Closed Accounts Posts: 27,857 ✭✭✭✭Dave!


    Cheers man! :D


  • Closed Accounts Posts: 27,857 ✭✭✭✭Dave!


    hmmm... I'm gonna need to have a form on the site, for people to send information in with. Is it necessary to have some sort of php or cgi script to handle the inputted information? I'd be happy to have the form go straight to my email address, but when I try to do so with this example...
    		<form action="mailto:myemail@gmail.com" method="post">
    		<fieldset>
    		<legend>Submit a dive</legend>
    		<label for="name">Your name:</label><br />
    		<input type="text"  id="yourname" name="yourname"  />
    		<br />
    		<label for="email">Email:</label><br />
    		<input type="text" id="email" name="email" /><br/>
    		<label for="website">Website:</label><br />
    		<input type="text" id="website" name="website" value="http://" />
    		<br />
    		<label for="comment">Comment:</label><br />
    		<textarea cols="30" rows="15" name="comment" id="comment">
    		</textarea>
    		<p>
    		Please specify a file, or a set of files:<br>
    		<input type="file" name="datafile" size="40">
    		</p>
    		<br /><label for="submit">&nbsp;</label><br />
    		<input id="submit" name="submit" type="submit" value="submit" />
    		</fieldset>
    		</form>
    

    ...it automatically calls up the default email program (Outlook) on the computer, rather than just send it through the browser. It also didn't seem to send the file that I attached :( I haven't a clue about php or cgi, so if I could just have it so that the form sends an email to my address, laid out like

    Name:
    Email:
    Comment:
    [file attached]

    ...then that would probably suffice for the time-being! Any ideas on this? Thanks!


  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    simple answer - yes you need asp, php or cgi to do some decent form processing


  • Registered Users, Registered Users 2 Posts: 46 nogihno


    Ph3n0m wrote:
    simple answer - yes you need asp, php or cgi to do some decent form processing


    check out the asp email objects, usually Persists or CDONTS Mail objects are supported by the asp server, then use the request.form code to take the form variables and send the email from within the asp page.


  • Advertisement
  • Closed Accounts Posts: 2,046 ✭✭✭democrates


    You need to protect against header injection attacks or your form could be used by spamlords.
    If you're using php to process user input for mail check this out.
    There'll be similar help for asp out there, google is your friend.


  • Closed Accounts Posts: 27,857 ✭✭✭✭Dave!


    Looks like I'm learnin php in that case :( lol

    I did a Hello World program, it doesn't seem that hard! :D

    Only thing is, I have to upload it to my server every time I wanna test a file, is there any easy way to develop it locally? I searched for it and I'm reading that I have to install software for php, Perl, mySql, and so on... Is it really necessary to do all that? Can I not download a plug-in for my browser that will let me view it locally? lol


  • Registered Users, Registered Users 2 Posts: 35,524 ✭✭✭✭Gordon


    Download a program called XAMPP.


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    There are a few out-of-the-box solutions like XAMPP for this kind of thing.

    Setting up a local webserver for testing your scripts is an essential part of learning to write code for the web IMHO.


  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    I personally use http://apache2triad.net/


  • Advertisement
  • Closed Accounts Posts: 27,857 ✭✭✭✭Dave!


    hmmm... I've gone through a tutorial or 2 on php, it's not too hard. But I'm still not really able to see a way to use it to send information via email (from a form). It seems that the html form sends information to a .php target, and I have to use those variables to display the inputted information on the page (after clicking submit). How would I be able to make it so that the form is sent to my email address? Any hints on what code I could use?

    Cheers!

    ps. When you're searching a website for a keyword, for example, does that scan through a MySql database until it finds what it's looking for? Or is it something completely different? Thanks


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    DaveMcG wrote:
    hmmm... I've gone through a tutorial or 2 on php, it's not too hard. But I'm still not really able to see a way to use it to send information via email (from a form). It seems that the html form sends information to a .php target, and I have to use those variables to display the inputted information on the page (after clicking submit). How would I be able to make it so that the form is sent to my email address? Any hints on what code I could use?
    When the contents of a form are sent to a .php file, they don't necessarily have to be displayed by the php file. It can process them any way it wants.

    For emailing, there's a mail() function in PHP which you can use to send the data to yourself. If you go down this route, read up on it. Their are security exploits for the mail() function.
    ps. When you're searching a website for a keyword, for example, does that scan through a MySql database until it finds what it's looking for? Or is it something completely different? Thanks
    That depends on the search engine. Some sites may just pass the data into a simple SQL query. Others may parse the search term, do searches for each term individually and merge the results. Other engines may keep a whole pile of tables full of indices and keywords purely to serve the search. Search engines tend to guard their search methods quite strongly.


  • Closed Accounts Posts: 2,046 ✭✭✭democrates


    http://www.php.net/manual/en/function.mail.php
    And don't forget the other link I posted to prevent header injection.


  • Closed Accounts Posts: 27,857 ✭✭✭✭Dave!


    Cheers, that's what I was looking for! Havin a bit of trouble though (what's new?)...

    FORM.HTML
    <html>
    <body>
    
    <form action="mail.php" method="post">
    Firstname: <input type="text" name="firstname" />
    Lastname: <input type="text" name="lastname" />
    Age: <input type="text" name="age" />
    <input type="submit" />
    </form>
    
    </body>
    </html>
    

    MAIL.PHP
    <html>
    <body>
    <?php
    $to  = 'myemail@gmail.com';
    $subject = 'New submission';
    $message = echo $_POST["firstname"];
    
    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    // Mail it
    mail($to, $subject, $message, $headers);
    ?> 
    </body>
    </html>
    

    And the email I get is
    echo $_POST["firstname"]

    I've tried all sorts of combinations and alterations in the code, and it always either gives me an error or else sends me the wrong info.

    Thanks for any help! And I'll read up on that security thing once I get this workin.


  • Closed Accounts Posts: 2,046 ✭✭✭democrates


    [php]if (isset($_POST["firstname"])){ //make sure the field exists before using it

    //put some validation code here

    //if the message submitted is valid
    $message = $_POST["firstname"];
    }
    [/php] The echo command is just to send something to the browser, you don't use it to assign a value to a variable.

    Make this your php bible: http://www.php.net/manual/en/
    If has information for all php functions, with examples and public comments/submissions.


  • Closed Accounts Posts: 27,857 ✭✭✭✭Dave!


    woohoo! Okay I seem to have it working now :)

    Check out the code
    <html>
    <body>
    <?php
    $to  = 'Dave <myemail@gmail.com>';
    $subject = 'New dive submitted';
    
    $message = "<b>Name: </b>" . $_POST["name"] . "<br><b>Email: </b>" . $_POST["email"] . "<br><b>Diver: </b>" . $_POST["diver"] . "<br><b>Match:</b> " . $_POST["match"];
    
    
    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    
    $headers .= 'From: MYSITE.net <nobody@myhost.com>' . "\r\n";
    
    [B]$emailPattern = '/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i';
    	if (!preg_match($emailPattern, $emailFieldToTest)){
    		print 'Please review the email address you entered. There seems to be a problem';
    	}[/B]
    
    
    // Mail it
    mail($to, $subject, $message, $headers);
    ?> 
    </body>
    </html>
    

    I'm not sure I understand fully the code I put in there to cover the exploit... You think you could tell me if that's correct, or what I need to put in?


  • Closed Accounts Posts: 2,046 ✭✭✭democrates


    DaveMcG wrote:
    I'm not sure I understand fully the code I put in there to cover the exploit... You think you could tell me if that's correct, or what I need to put in?
    Boards is great when you're stuck on something that won't take much time to resolve, for programmer tutorials google is your friend.

    To learn about regular expressions check out http://www.zend.com/zend/tut/tutorial-delin2.php.


  • Closed Accounts Posts: 27,857 ✭✭✭✭Dave!


    Thanks for the help...

    2 days into learning php, some of these tutorials can be hard to understand.


  • Closed Accounts Posts: 27,857 ✭✭✭✭Dave!


    Can anyone help me with the header injection thing?

    It makes sense to me!!! I'll throw in comments to show where I'm comin from...
    //if someone presses submit
    	if ($submit) {
    //checks to see if the $email field is in the form name@address.something
    		$okay = preg_match (
    			'/^[A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{2,4}$/',
    			$email
    		);
    //if it is, sends the mail to me
    		if ($okay) {
    			mail($to, $subject, $message, $headers);
    //if it's not, echoes that message
    		} else {
    			echo "There was a problem with your email address. Please press 'Back' and adjust the field appropriately.";
    		}
    //if someone doesn't press submit... dunno why I'd ever use this else, but w/e
    	else {
    		echo "Thank you?"
            }
    

    So it makes sense to me... yet I get this message:

    Parse error: syntax error, unexpected T_ELSE in /home/beserah/public_html/jobbanter/nodiving/submitdive.php on line 114

    Line 114 is the
    [B]else {[/B]
    echo "Thank you?"
    }
    

    ...part. I was gonna just leave it with no validation, but it's startin to scare me now!


  • Closed Accounts Posts: 2,046 ✭✭✭democrates


    There's no terminating ; on the echo statement.

    Note that with some error messages the line referred to may be perfect, an error on a previous line could be the culprit, as some code errors like this one can fool php into thinking that following lines are also part of the earlier dodgy statement.

    You need some more validation, so far you're checking the email address is the correct format (though I haven't tested your regex), this also prevents a big list of addresses being inserted in that field.

    You still need to protect against the form being used to enter other unwelcome extras into your mail() statement. From the earlier link I posted:
    [PHP]function safe( $name ) {
    return( str_ireplace(array( "\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:" ), "", $name ) );
    }

    /*************
    NOTE: str_ireplace is a PHP5 function. If you are using an
    earlier version of PHP, you can use preg_replace
    with the i modifier.
    *************/[/PHP]

    You see those strings in the array, any one could subvert your mail() statement,
    so if you find any one of them in user-submitted data, that could be a crammer (cracker & spammer)
    attempting to invite people to help him get money out of his country following the coup. This is not a
    php problem, it could happen in any web language.


  • Advertisement
Advertisement