Jump to content

markvs

Member
  • Posts

    27
  • Joined

  • Last visited

Everything posted by markvs

  1. I'm not sure? I'm just trying to limit the number of calls to the database and I'm not sure how to do this within PHP. I just thought I could send it all to MySQL and then filter out the empty fields somehow.
  2. Hello, I have a one row table that's being populated using a HTML form with several fields. I'm needing the database fields to be UPDATED only if the form fields have been filled in. I can do this in PHP, but would prefer to do this using MySQL. Below is an example of the PHP code. Keep in mind that I'm a green at both PHP/MySQL, so any suggestions are appreciated. if($user_name == 'user' && $password == 'password') { if(!empty($_POST['location'])) { mysqli_query($con, "UPDATE gig_date SET location='$location' WHERE gig_id=1"); } if(!empty($_POST['band_name'])) { mysqli_query($con, "UPDATE gig_date SET band_name='$band_name' WHERE gig_id=1"); } if(!empty($_POST['start_time'])) { mysqli_query($con, "UPDATE gig_date SET start_time='$start_time' WHERE gig_id=1"); } } Thanks, Mark
  3. I can create a php web form, but how can I use it to change the value of a variable on the server?
  4. Before you send the form to the server to be processed by the php interpreter, it would be nice if all of the required fields had some data; preferably in the correct format. eg. An email address could be checked to make sure it had some minimal formatting, such as making sure it contained the "@" and "." symbols and this could be done by JavaScript on the clients computer. If a required field was left blank, that could be checked, etc. - all before you send a request to the server. Considering that a very large percentage of users have JavaScript turned on (over 97%, I think), it would be a good idea to use JavaScript and php to process a form. JavaScript to improve the user experience and take some of the load off of the server, and php to take care of the real processing which is much more secure than JavaScript. Like I said, I'm far from a pro, but this is what I've read.
  5. For those with JavaScript available - I would think that you could do some simple verification using JavaScript before submitting the form. And then do a more thorough validation using php and Regular Expressions. I'm also far from an expert, but I've read that somewhere and it would make for a better user experience for most.
  6. return false; good to know and it's important for this application. Thanks for the heads up.
  7. Okay, that help a lot. Here is my re-worked code. I'll have to modify things a bit for my application, but the getElementById() is what I needed. The HTML, CSS, and Javascript are all in this file, so you can run it in your browser with ease. Thanks again! <!DOCTYPE html> <html> <head> <style type="text/css"> body {font-size:large; font-family:sans-serif;} a {color:red; font-weight:bold; text-decoration:none; } #content { width: 500px; margin: 100px auto; padding: 20px; background-color: #FFF; border: solid 2px #000; } #content_to700js { width: 700px; margin: 100px auto; padding: 20px; background-color: #000099; color: #FFF; border: solid 2px #000; } </style> </head> <body> <div id="content"> <p><a id="the_link" href="#" onclick="return divWidthTo700()" >Click on Link </a> ...and an iframe will load here, but it will need more width then 500px. So, I need to increase the width of this area on the click of "the_link" I've created a style block in the CSS for an id called (content_to700js) that will come into play with the click of "the_link".</p> <p>Thanks!</p> </div> </body> <script type="text/javascript"> function divWidthTo700() { document.getElementById("content").id = 'content_to700js'; } </script> </html>
  8. Yes Ben that's what I'm looking for, let me try and wrap my brain around it and I'll reply after lunch. Thanks!
  9. Thanks for the replies. I'm just trying to learn Javascript for now, but later on I would like to learn how to use jQuery. w3s... is helpful at times, but I enjoy the back and forth here on Killersites with explanations to include best practices, etc.. In my code example, forget the iframe or why, I just want to learn how to grab an id using some Javascript, and change it to something else so that it will be styled according to the CSS file. Thanks, Mark
  10. I'll include some code that will hopefully be self explanatory. The CSS is included in the markup, but I need to learn Javascript. Thanks in advance, Mark <!DOCTYPE html> <html> <head> <style type="text/css"> body {font-size:large; font-family:sans-serif;} a {color:red; font-weight:bold; text-decoration:none; } #content { width: 500px; margin: 100px auto; padding: 20px; background-color: #FFF; border: solid 2px #000; } #content_to700js { width: 700px; margin: 100px auto; padding: 20px; background-color: #000099; color: #FFF; border: solid 2px #000; } </style> </head> <body> <div id="content"> <p><a id="the_link" href="url">Click on Link </a> ...and an iframe will load here, but it will need more width then 500px. So, I need to increase the width of this area on the click of "the_link" I want to keep my HTML, CSS, and Javascript files separate. Can you please explain how to do this. I've created a style block in the CSS for an id called (content_to700js) that I want to switch to on the click of "the_link".</p> <p>Thanks!</p> </div> </body> </html>
  11. Yes Ben, that did the trick. I had left off the parenthesis. Thanks!
  12. Why does this code display the code for the getValue function and not the return value? // Card constructor, using private variables. var Card = function(s,n) { 'use strict'; var suit = s; var number = n; this.getSuit = function(){ return suit; }; this.getNumber = function(){ return number; }; this.getValue = function () { if (number>= 10 && number <=13){ return 10; } else if ( number>=2 && number<=9) { return number; } else if (number === 1) { return 11; } else {return "what the heck";} }; }; var card1 = new Card(2, 11); var card2 = new Card(10, 13); alert(card1.getValue); alert(card2.getValue);
  13. I found this in a php book last night. "On some - primarily Unix-systems, the \r\n characters aren't handled properly. If you have problems with them, use just \n instead." Larry Ullman I've also read that it's important to have an empty line separating the message(body) from the headers, using \r\n\r\n or just \n\n.
  14. Wickham, You might find this post helpful, it talks about Outlook and using (PHP_EOL) instead of \r\n.... ... http://forums.devarticles.com/php-development-48/formatting-a-newline-line-break-in-php-html-output-5274.html
  15. Hi Amy, I agree, but by using the if statement, you would at least know if the email was being handed off to the mail server for delivery, whether delivered or not.
  16. Have you tried just the Line Feed(\n) without the Carriage Return(\r). What server are you running it through? If it's Unix, this may be the problem from what I've read. Just a shot in the dark. I'm really green when it comes to php. good luck! mail( $email, "Village Hall booking", "$club\n$room $book\n$day/$month/$year $starttime to $endtime\n$replymsg", "From: $admin" ); mail( $admin, "Village Hall booking", "$club\n$room $book\n$day/$month/$year $starttime to $endtime\n$who $phone $email\n$message", "From: $admin" );
  17. markvs

    The Break Tag

    Is this how you would right the code for several addresses, maybe give the paragraphs holding them a class, or is there a better solution for this?
  18. Shouldn't you enclose your mail function within an if statement if you want to test if it was accepted to be sent and echo out something whether true or false? e.g. $subject = "testing mail"; $message = "Here is a test mail message"; $to = "me@gmail.com"; $from = "me@gmail.com"; $header = "From: ".$from; if(mail($to, $subject, $message, $header)) echo "Oh ya!<br>"; else echo "well crap!<br>";
  19. markvs

    The Break Tag

    Can you give an example of when using a break tag is acceptable. Thanks
  20. markvs

    The Break Tag

    Thanks Stefan, What about inline styles?
  21. I'm not sure if I should use the break tag or not. Will it affect a site using a responsive web design approach? What about semantics? Is there ever a situation to where it's acceptability to use a break tag in modern web design? Maybe a link to a current article would be helpful. Thanks
  22. Been playing around with Ubuntu(Linux) on an older window computer that just keep crashing using windows xp. It looks promising and Ubuntu offers some free cloud backup as well. You might check it out... ubuntu-dot-com
  23. Thanks Wickham - that was very helpful! Cheers
  24. The clear: both; is working just as it should in the footer. No need for the div to clear. By removing the float right on #aside and adding a float left to #left works for me. That may be all you need. Best of luck, Mark
  25. Not for sure what your wanting, but this may help get you there. #left - I don't see where you have this division floated left. So, add that property. aside - comment out or remove all styling and add a margin property.... margin: 0 0 0 730px; Adding the large left-margin will allow the aside div to move up the page and align with the float. If this isn't what your looking for, please disregard. If so, now you can adjust your images as needed. Best of luck, Mark PS. remove the clear div, it's not needed. You cleared the left float in the footer.
×
×
  • Create New...