KevinM1
Moderators-
Posts
5,222 -
Joined
-
Last visited
-
Days Won
26
Everything posted by KevinM1
-
Array variables work different than 'normal' variables within a double-quoted string. Normally, something like: echo "Some value: $value"; Works just fine. For array variables, you need to stick them in curly braces for it to work, like so: echo "Look, it's an array variable: {$array[$key]}"; In your case, name needs to be put in single-quotes ($ama['name']).
-
To be perfectly honest, if you mean for this to be a serious website for your business, you'll need to do a complete overhaul. 1. Never, ever, ever use Comic Sans as your font. You are not a comic book. 2. Don't use a gradient for a background. That's okay for "Grandma's pictures of her summer vacation." Not for a site belonging to a professional. 3. Site structure. You need to organize your pages, and create areas that clearly demarcate navigation, content, etc. Look at every other site you've been to. They have columns. They have clearly defined headers and footers. These structures exist for a reason. Use them. 4. Ditch the iframes. Also, on your front page, the images, when clicked, bring me to an error page. You need to fix it. I'm not trying to be harsh, just realistic. You're (presumably) trying to separate yourself from the pack to generate more business for yourself. In order to do it, you need to see how the competition does it, and then attempt to do it better. I understand that this is your first attempt, and honestly for a first attempt it's not too bad (you should have seen the monstrosities I made back in the day). That said, since this is a site showcasing your business, it needs to be held to a higher standard. This attempt should be considered a rough draft. You got your feet wet with the process. Now it's time to go at it for real.
-
You're not guaranteed that HTTP_REFERER will work, as not all user agents set it. For more info, see: http://www.php.net/manual/en/reserved.variables.server.php
-
Not bad. Crits: There's a lot of wasted space at the top, between your navigation and introductory blurb. I'm not a fan of content appearing so low on a page. Some of the colors for the text (green tags, the orange links at the bottom of your blog entry, the gray copyright) make it hard to read. Still, overall a thumbs up.
-
Most likely a runtime issue. JavaScript will attempt to obtain references to elements before they exist, which will in turn break your script. Use either window.onload = function(){ // script code here } Or put your script at the bottom of the page to ensure the elements are rendered before JavaScript attempts to use them.
-
Lack of ability != lack of intelligence. You successfully replaced existing code with new code that added functionality to your site. It may not seem like much, but, hey, it's a start.
-
That's where we differ. I'm a whore.
-
Nope, you don't need any kind of starting tag/header/preprocessor call/etc. at the beginning. There's a small caveat with HTTP header redirects, but you're not even close to needing to worry about that. For your form file, unless you're going to add PHP to it later, I'd just keep it as a straight HTML file. Why make the server do more work than it needs to do to render the page? I wouldn't be worried about file extension consistency. It's much better to be consistent with actual file names and your directory structure.
-
I feel so used... :'(
-
Sorry. Okay, I know that you can put PHP inside of HTML. I am wondering if you can completely wrap HTML inside of you PHP? It just seems weird to me to have a ".php" file and yet it is PHP inside of HTML. I dunno. Am I making any more sense? I see what you're saying, but you're looking at it the wrong way. .php files are, well, PHP files. This means they run on the server. The PHP tags denote where you want to execute logic. Code not within those tags is being output to the screen by, essentially, an invisible echo call. So, something like: <!doctype html> <html lang="en-us"> <head> <title>Example 3</title> </head> <body> <?php for($i = 0; $i < 10; ++$i) { echo $i . "<br />"; } ?> </body> </html> Is actually like: echo '<!doctype html>\n<html lang="en-us">\n\t<head>\n\t\t<title>\n\t\t\tExample 3\n\t\t</title>\n\t</head>\n\n\t<body>'; for($i = 0; $i < 10; ++$i) { echo '\n\t\t$i<br />'; } echo '\n\t</body>\n\n</html>'; Behind the scenes. The PHP tags tell the PHP interpreter where you want to break from the default, invisible echo and perform logic. This means that wrapping HTML in PHP tags wouldn't work, as the interpreter treats anything within the tags as language constructs. You'd get a ton of errors even trying it. Also, just because PHP has tags, that doesn't mean that it has anything to do with HTML's Document Object Model (DOM). These tags aren't elements. If you view the rendered source code of a PHP file (like, say, this very forum... right-click, then left-click 'View Source'), you wouldn't see any PHP at all.
-
To be honest, I'm not sure what you're asking.
-
<?php $EmailFrom = "Win One"; $EmailTo = "sales@capsonewire.com"; $Subject = "Registration"; $Name = trim(stripslashes($_POST['Name'])); $Tel = trim(stripslashes($_POST['Tel'])); $Email = trim(stripslashes($_POST['Email'])); $Phone = trim(stripslashes($_POST['Phone'])); $Message = trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = "Name: $Name\n"; //$Body .= "City: $City\n"; $Body .= "Email: $Email\n"; $Body .= "Phone: $Phone\n"; $Body .= "Message: $Message\n"; $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success) { //Modify content for confirmation and send to user $Confirm = "This is to confirm that the following message was sent to our sales department:\n\n" . $Body; mail($Email, $Subject, $Confirm, "From: <$EmailFrom>"); //Redirect to thank you page print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } else { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> Here's a cleaned up version for you.
-
It looks like you overwrote the initial email sending: $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); You need to stick that line before the first if($success){ Line.
-
How should I handle my file type? I think I want a .php file, right? How do I intermingle the HTML and PHP? To me, it is a PHP file first with the HTML just used to create the form. Any thoughts? Yeah, it should be a .php file. Intermixing the two is easy. Simply use PHP tags (<?php ?>) to denote where you want to do script processing. Example: <?php echo "I'm appearing even before the HTML is rendered!"; ?> <!doctype html> <html lang="en-us"> <head> <title>Example 2</title> </head> <body> <p> I'm written by the HMTL! </p> </body> </html> <?php echo "And I come after everything else!"; ?> Where you put the PHP for your form depends on how you want to handle form processing. Am I right in assuming you want a sticky form?
-
Post all of your code as it stands now.
-
To the OP, I suggest writing your markup with the HTML 5 doctype instead of the XHTML doctype. It'll save you a line or two of ugly, ugly code. It also has the benefit of forcing browsers to still render in standards mode, despite being a somewhat exotic doctype at the moment. If you're not familiar with what I'm talking about, something like: <!doctype html> <html lang="en-us"> <head> <title>Example</title> <!-- CSS link --> </head> <body> <!-- Stuff goes here --> </body> </html>
-
Your best bet is to show us some code you've written and where your concerns lie in relation to that code. It's hard to understand a problem, let alone solve it, without seeing what you're actually doing. So, post code, even if it's just pseudo-code, and chances are you'll get some real help.
-
Senior PHP Developer Position Interview Questions
KevinM1 replied to hadoob024's topic in Miscellaneous
Don't reply to posts that are nine months old. -
JavaScript to change properties of a CSS class
KevinM1 replied to chiprivers's topic in Javascript Help
Russell, no offense man, but that's probably the worst way to do it. JavaScript allows one to dynamically alter an element's CSS on the fly. Why write directly to the DOM when you can simply play with CSS attributes? To the OP: the problem has two components - grabbing a hold of all the elements of a certain class, then changing their CSS attributes once you have them. The easiest way to do both is to use jQuery. It's selector engine saves one from having to worry about those browsers that don't implement a getElementsByClassName function. To get jQuery and read it's documentation, go to: http://jquery.com So, with that out of the way, something like: $('.sometext').each(function(){ $(this).css('color', 'blue'); }); Should do the trick. Keep in mind, that solving this problem does not require jQuery to work. It's just the simplest way to go about it. You could do the same thing in vanilla JavaScript. It would merely require you to do the heavy lifting of looping through elements to find the right class name, then looping through them again to apply the new CSS rule. -
Not really. Looks a bit blurry to me. You answered your own question here. Those people that are virtually computer illiterate won't bother changing browsers. They aren't your audience. The people that are your audience are people who already know what a browser is. It's still unnecessary. Do you really think that your audience will care about the lingo? That they'll give a hoot about HTML 5 or CSS 3? It could be puppy kisses and unicorn farts, for all they know. And it still doesn't say anything beyond "technology is advancing." It's essentially a paragraph long truism. Why would they care about what your site looks like when, as you say, the popular sites still look fine? Why would they want to change when, as you say, the technological changes won't be official until 2022? I get it as a developer. Most users couldn't care less so long as Facebook and Twitter work. You need to make a convincing argument to those people. Describing the changes in technology in the vaguest of terms and showing how messed up your site looks in an old browser isn't compelling. Also, none of this addresses the fact that most people unwittingly update browsers when they buy new computers. Modern sites will still cater to the old browsers long enough so that many people wont have to manually upgrade anyway. Again, not saying that I disagree with you, but rather you need to think like a typical end user - a lazy skeptic. Make a compelling argument, one that will make them upgrade rather than feel that IE6-7 is good enough for now.
-
Some other general tips: I don't see why you'd want to store the user's password in a session. They're already logged in, right? Passwords should be stored as a hashed value in the db. For even tighter password security, use a salt. Whenever a user does something important/critical, regenerate their session id (session_regenerate_id). MySQLi with prepared statements is really the way to go.
-
Are you intentionally writing bitwise or ('|')? Because logical or ('||') is a different thing entirely.
-
I hate the font. It's hard on the eyes regardless of what browser one uses. Do you really think you need to inform people of what a web browser actually is? They're viewing your site on the internet... I think they at least know what a browser is. People who don't upgrade their browsers are ignorant, not retarded. There's a lot of jargon without any context. Most users don't know or care about what XHTML or CSS is. They care about content - that's it. So, instead of saying "technologies x will eventually be replaced by technologies y", without anything to really illustrate the point, have a series of comparison shots. Show popular websites in IE 6 compared to modern browsers. Facebook, Twitter, NY Times, CNN, ESPN, etc. Show, don't tell.