Jump to content

Newbie needs help!


dollojo

Recommended Posts

Hi, I'm a newbie in web development and I'm hoping you can help me with a couple of issues I have. I noticed that tables that I built with dreamweaver in my customized template are showing up in firefox with defined table edges but preview in explorer invisibly. Any idea why that is?I'm also trying to add php code to a form on the site but I don't know php. After scouring the web, I finally was able to come up with this code and I'm hoping you can tell me it will work!Form html:<form action="contact.php" method="post"> <p><strong>Title</strong>                                 <input type="radio" name="Title" value="Dr" checked="checked" /> Dr <input type="radio" name="Title" value="Mr" /> Mr <input type="radio" name="Title" value="Mrs" /> Mrs <input type="radio" name="Title" value="Ms" /> Ms </p> <p> </p> <p><strong>First Name</strong>                      <input name="firstname" type="text" id="firstname" size="40" maxlength="40"> </p> <p> </p> <p><strong>Last Name</strong>                       <input name="lastname" type="text" id="lastname" size="40" maxlength="40"> </p> <p> </p> <p><strong>Email Address</strong>                <input name="email" type="text" id="email" size="40" maxlength="40"> </p> <p> </p> <p><strong>Contact Telephone</strong>       <input name="telephone" type="text" id="telephone" size="40" maxlength="40"> </p> <p> </p> <p><strong>Comments</strong>                      <textarea name="comments" cols="60"></textarea> </p> <p> </p> <p>                                        <input type="submit" name="Submit" value="Send Message">                         <input type="reset" name="Submit2" value="Clear Form"> </p> </form>PHP code:<?php$myemail = "email@domain.com";$title = check_input($_POST['title']);$firstname = check_input($_POST['firstname'], "Enter your name");$lastname = check_input($_POST['lastname'], "Enter your name");$email = check_input($_POST['email']);$telephone = check_input($_POST['telephone']);$comments = check_input($_POST['message'], "Write your comments");if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)){ show_error("E-mail address not valid");}$message = "Hello!Your contact form has been submitted by:Title: $titleFirst Name: $firstnameLast Name: $lastnameE-mail: $emailTelephone: $telephoneComments:$commentsEnd of message";mail($myemail, $subject, $message);header('Location: thanks.htm');exit();function check_input($data, $problem=''){ $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data;}function show_error($myError){?> <html> <body> <b>Please correct the following error:</b><br /> <?php echo $myError; ?> </body> </html><?phpexit();}?>

Link to comment
Share on other sites

I can't say much about the PHP part. I'm not the most fluent with PHP.I can say that your HTML does need some help though. :)- For starters, those   entities should not be used in the way you're using them. You should use CSS margins and padding to position your elements.- You might want to consider using <label>'s for your radio buttons. The way you have it set up now is invalid. To use a label you need to assign your radio buttons an id. Here's an example:

<input type="radio" name="Title" id="Title" value="Dr" checked="checked" /><label for="Title">Dr</label>

- Get rid of those empty <p> tags. (I'm refering to these: <p> </p>) You should use margins like I stated above to create extra space between your <p> tags.

Link to comment
Share on other sites

The PHP will work just fine. All it does is check the inputs from the form to make sure that they aren't empty. If they are, it displays a message telling the user what was wrong. You can change the page people land on if they're successful by changing this line:header('Location: thanks.htm');to contain the URL you want.

Link to comment
Share on other sites

the browser only renders content in the form of HTML/XML/Javascript, PHP has no influence in that, short of providing said content. Hence the acronym; PHP.

Link to comment
Share on other sites

What does that mean?
1. I was wondering why my pages look fine in internet explorer but in firefox, the tables frames are showing up around the text. 2. I also notice that a page on my modified template prompts internet explorer to give this message and wouldn't display a flash movie I have on it until I click on the message bar: "To help protect your security, internet explorer has restricted this webpage from running scripts or active X control that could access your computer. Click here for options." Why would the browser do that to just the page containing flash and how can I make the browser stop?(I have internet explorer 8 by the way) Is that how others will always browse that page?3. I have yet another question! In order to override the css style page that came with the template, I included a css text style in my html head document to prevent my links from underlining at all and to make them have a size change when the cursor hovers over them. But for some reason I couldn't get the hover links to also change color (as well as size), and the visited links to also change color. Any ideas how to do that? Below is my code:<style type="text/css"><!--a:link {text-decoration: none}a:visited {text-decoration: none}a:active {text-decoration: none}a:hover {font-size:105%;}--></style>Thanks!
Link to comment
Share on other sites

1. I was wondering why my pages look fine in internet explorer but in firefox, the tables frames are showing up around the text.
I don't see any tables in your original code. Are you using a Strict DTD? You should look back at my first post on this topic and try to follow some of those guidelines.
2. I also notice that a page on my modified template prompts internet explorer to give this message and wouldn't display a flash movie I have on it until I click on the message bar: "To help protect your security, internet explorer has restricted this webpage from running scripts or active X control that could access your computer. Click here for options." Why would the browser do that to just the page containing flash and how can I make the browser stop?(I have internet explorer 8 by the way) Is that how others will always browse that page?
I think I remember seeing the answer to this in another topic. If I remember correctly it will only prompt you with the message bar when you load the file locally (from your hard drive on your computer). The issue should disappear after you upload to your host.
3. I have yet another question! In order to override the css style page that came with the template, I included a css text style in my html head document to prevent my links from underlining at all and to make them have a size change when the cursor hovers over them. But for some reason I couldn't get the hover links to also change color (as well as size), and the visited links to also change color. Any ideas how to do that?
You should just be able to add declarations to your CSS. I prefer to keep my CSS formatted like I have it below. For me at least it's easier to read that way.
<style type="text/css">a:link {   text-decoration: none;}a:visited {   text-decoration: none;   color: #990066;}a:active {   text-decoration: none;}a:hover {   font-size:105%;   color: #000099;}</style>

I don't think you need those comments ( the <!-- and --> ) so I removed them.

Link to comment
Share on other sites

Okay thanks. jkloth you were right, the message bar disappeared when I loaded it. My form, however, gave me an error message about the 'comments' when I tested it. Do you think there is something wrong with the html code above other than the   part of it? I also added an upload document function. Will I need to add a php code to make that work?Regarding my radio buttons in the form html above, do I need to add id="Title" value="Dr" checked="checked"<label for="Title">Dr</label>to every button?

Link to comment
Share on other sites

My form, however, gave me an error message about the 'comments' when I tested it. Do you think there is something wrong with the html code above other than the   part of it? I also added an upload document function. Will I need to add a php code to make that work?
I'm not certain what you mean by this. The text area? Actual HTML comment tags?
Regarding my radio buttons in the form html above, do I need to add id="Title" value="Dr" checked="checked"<label for="Title">Dr</label>to every button?
You certainly don't need to do it. The reason I suggested the label is because a label is directly bound to an element and will always align perfectly with that element. By using a label the text becomes clickable too. The checked attribute you would only add to whichever radio you want to have checked by default when the page loads (Only one radio per name group can be checked)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...