Reputation Activity
-
davewilly reacted to Lev in Feedback on homepageVery good design, Dave, really.
Though, I'd get rid 'script' font (http://rj.gemnetworks.com/images/hire.jpg)
-
davewilly reacted to KCooper in Feedback on homepageYeah I like it too mate, really nice!
Personally, I don't think the slider images are too big; they certainly make an impact. It looks great on my monitor anyways :-P
Kyle
-
davewilly reacted to Lev in Feedback on homepageTry the same font as in the header of image.
-
davewilly reacted to andy9l in Feedback on homepageTry this.
@davewilly; Don't stop the slider on mouseover - I was waiting for ages till I realised I was actually stopping it!
-
davewilly reacted to Born4Digital in Feedback on homepageHi Dave, i think the type face is fine! the colours and finish on the boarders is great. as for the slider size, well i guess it depends, i mean you have really nice hi res images so personally i think its fine, but viewing it on a dell 10" (like me) you dont see the three boxes under it, but then research goes to show that most people duck-dive under the fold now anyway (i did) - nice work!
-
davewilly got a reaction from daniel7912 in RegistrationIt covers all of the fundamentals and will get you well on your way to programming secure and dynamic sites. It really is a great book. You can see what it covers on that link. You can view the contents etc.
-
davewilly got a reaction from Milli05 in Hepl with regular expressionsTry this, it's a PCRE.
I've tested it in RegexBuddy.
Matches: 01934 7424522, 08457226748, 0845 722 6748, 0845 7226748, 0845-722-6748, 08453-722-6748
Non Matches: 0845372266748, 084534 7226674, 08453 7422 674, -0845 722 674
It's worth investing in a program like RegexBuddy if you use them often, I've found it a life saver.
For your benefit I will explain what each part of the expression does:
^[\d]{4,5}[-\s]?[\d]{3}[-\s]?[\d]{3,4}$ ^ - Assert position at beginning of string [\d]{4,5} - Match a single digit between 4 & 5 times [-\s]? - Match either a hyphen or a space 0 or 1 times [\d]{3} - Match a single digit 3 times [-\s]? - Match either a hyphen or a space 0 or 1 times [\d]{3,4} - Match a single digit between 4 & 5 times $ - Assert position at the end of the string You will need to delimit the regex when using it in php: /^[\d]{4,5}[-\s]?[\d]{3}[-\s]?[\d]{3,4}$/
You will find some outrageously huge PCRE patterns for matching a phone number, this one is very basic, but will get you started.
Dave
Edit: Wrap your code in [c0de] [/c0de] tags, replacing the 0 for a o!
-
davewilly reacted to ElanMan in simple jQuery anim buggy in Internet Explorershaha, it's funny how it's the simple things that get you sometimes
-
davewilly reacted to ElanMan in simple jQuery anim buggy in Internet ExplorersHi Dave, make sure you use a full DOCTYPE. Seems to fix the issue for me in IE8 at least.
-
davewilly reacted to sunwukung in OOP adviceIn your initial post, you talked about putting the various steps into the constructor. Object creation can become a messy business, creating and calling several methods one after the other - so generally speaking, this is what the Factory pattern is for. It enable you to tuck those successive calls into one method in your Factory - i.e.
$V = Factory::build('Validator',$errors); //returns an object that has gone through the setup you showed in your initial post $V->report();//echo out the errors
As to the second part of your question, no, generally you should not build a God class - each class should be responsible for one particular job.
http://en.wikipedia.org/wiki/God_object
-
davewilly reacted to sunwukung in OOP adviceThis is a common problem - and you generally look at making a Factory class for this kind of thing. In a nutshell, you don't want to pepper your constructor with loads of method calls if you can help it. Instead, make a class that builds the class and calls the methods, then returns the class post setup.
i.e. you could use a switch
class Factory{
public function build($classname){ switch($classname){ $class = new $classname() //various object setup stuff break; } return $class; } }
or you could use some magic
public function build($classname){ if(method_exists($this,$classname){ return $this->$classname(); } } private function XMLthingy(){ //setup an XML thingy }
I would also allow for a second argument in the factory call to pass in some options to the class it builds.
-
davewilly reacted to Jay Gilford in OOP adviceHi Dave. The method you have used is perfectly acceptable. The rule of thumb with objects is that you want them to be reusable and as flexible as possible without giving the programmer a headache implementing it, so you need to balance it quite carefully. With the method you've used of passing the query string you've allowed your class to be used with other input such as a text string defined by something other than the server.
You could also employ the __construct method at this juncture, which would be perfectly acceptable if that's its primary purpose (and just pass all arguments from the construct to the doConversion() function, therefore ensuring the DRY technique
As for the one class to do al this, it's best not to create overly complicated objects, unless you're doing the same thing again and again and can modify parameters to meet your goals with the same class
-
davewilly reacted to Ashley Byrom in Bet solution for displaying checkboxes dynamically with select menuIt's attached in my post?
Here's the HTML if the attachment isn't showing:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Dynamic Select Boxes Example</title> <style type="text/css"> .divOne { display: block; } .divTwo { display: none; } .divThree { display: none; } </style> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { $('select').click(function(){ var value = $(this).attr("value"); if(value=="cbone") { document.getElementById('divOne').style.display = 'block'; document.getElementById('divTwo').style.display = 'none'; document.getElementById('divThree').style.display = 'none'; } else if(value=="cbtwo") { document.getElementById('divOne').style.display = 'none'; document.getElementById('divTwo').style.display = 'block'; document.getElementById('divThree').style.display = 'none'; } else if(value=="cbthree") { document.getElementById('divOne').style.display = 'none'; document.getElementById('divTwo').style.display = 'none'; document.getElementById('divThree').style.display = 'block'; } }); }); </script> </head> <body> <form id="form1" name="form1" method="post" action=""> <p> <label> <select name="selectbox" id="selectbox"> <option value="cbone" selected="selected">Checkboxes One</option> <option value="cbtwo">Checkboxes Two</option> <option value="cbthree">Checkboxes Three</option> </select> </label> </p> <div class="divOne" id="divOne"> <p>Checkbox group one can go here</p> <p> <label> <input type="checkbox" name="checkbox" id="checkbox" /> Checkbox</label> <br /> <label> <input type="checkbox" name="checkbox2" id="checkbox2" /> Checkbox</label> <br /> <label> <input type="checkbox" name="checkbox3" id="checkbox3" /> Checkbox</label> <br /> <label> <input type="checkbox" name="checkbox4" id="checkbox4" /> Checkbox</label> <br /> <label> <input type="checkbox" name="checkbox5" id="checkbox5" /> Checkbox</label> <br /> <label> <input type="checkbox" name="checkbox6" id="checkbox6" /> Checkbox</label> </p> </div> <div class="divTwo" id="divTwo"> <p>Checkbox group two can go here</p> <p> <label> <input type="checkbox" name="checkbox7" id="checkbox7" /> Checkbox</label> <br /> <label> <input type="checkbox" name="checkbox7" id="checkbox8" /> Checkbox</label> <br /> <label> <input type="checkbox" name="checkbox7" id="checkbox9" /> Checkbox</label> <br /> <label> <input type="checkbox" name="checkbox7" id="checkbox10" /> Checkbox</label> <br /> <label> <input type="checkbox" name="checkbox7" id="checkbox11" /> Checkbox</label> <br /> <label> <input type="checkbox" name="checkbox7" id="checkbox12" /> Checkbox</label> </p> </div> <div class="divThree" id="divThree"> <p>Checkbox group three can go here</p> <p> <label> <input type="checkbox" name="checkbox8" id="checkbox13" /> Checkbox</label> <br /> <label> <input type="checkbox" name="checkbox8" id="checkbox14" /> Checkbox</label> <br /> <label> <input type="checkbox" name="checkbox8" id="checkbox15" /> Checkbox</label> <br /> <label> <input type="checkbox" name="checkbox8" id="checkbox16" /> Checkbox</label> <br /> <label> <input type="checkbox" name="checkbox8" id="checkbox17" /> Checkbox</label> <br /> <label> <input type="checkbox" name="checkbox8" id="checkbox18" /> Checkbox</label> </p> </div> </form> </body> </html>
-
davewilly got a reaction from Tamizhan in database and phpHi Tamizhan, this should work for you, I've tested it.
I'm assuming $i is a counter? It would be better to use an auto_incremeting `id` field in the database for this.
<?php //***** Database stuff *****// // Ideally store in external // file and require/include it // Define constants DEFINE('DB_USER', 'Tamizhan'); DEFINE('DB_PASSWORD', '123Polizei'); DEFINE('DB_HOST', 'localhost'); DEFINE('DB_NAME', 'bilder'); // Create connection $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // If connection fail if (!$dbc) { // Trigger error *** remove error display when live! trigger_error('Could not connect to MYSQL: ' . mysqli_connect_error()); } // End if $i = "1"; $tempname = $_FILES['file']['tmp_name']; $name = $_FILES['file']['name']; $type = $_FILES['file']['type']; $size = $_FILES['file']['size']; if($type != "image/png" && $type != "image/jpeg") { $err[] = "You can only upload png-files or jpg-files."; } if($size > "1500000") { $err[] = "Your file is too big <br/> Maimum size are 1500kb"; } // If no errors if(empty($err)) { copy("$tempname", "images/" . "$name"); $image_url = "images/" . $name; // Compile query $q = "INSERT INTO `bilder` (`nummer`, `autor`, `titel`, `image`) VALUES ('$i', 'SutiSiva', 'Bild', '$image_url')"; // Do query $result = mysqli_query($dbc, $q); // If it ran OK if (mysqli_affected_rows($dbc) == 1) { // Print message echo "Die Datei $name wurde erfolgreich hochgeladen!"; } else { //If it did not run OK. echo "Actung! ..error"; } // End if } else { // We have errors.. foreach($err as $error) echo "$error<br />"; } // End if // Put your select statement here if you like // Compile query $sql = 'SELECT * FROM `bilder`'; // Do query $res = mysqli_query($dbc, $sql); // fetch it while($row = mysqli_fetch_array($res)) { echo $row['nummer'] . '<br />'; echo $row['autor'] . '<br />'; echo $row['image'] . '<br />'; } // Close the database connection mysqli_close($dbc); ?>
webdesigner93 - Web Guru, my arse
Cheers
-
davewilly got a reaction from irn3rd in Procedural to OOPHey Ben, what is it you are struggling with? Understanding classes & objects or applying it?
btw, did you get your .htaccess working? I replied again, to that thread.
Dave
-
davewilly got a reaction from Adam in User AuthenticationHi Adam, do you have any php experience? If not this is going to be quite a challenge for you, but not impossible.
Online tutorials are generally OK and plentiful but nothing beats a quality book and I can't recommend PHP 6 and MySQL 5 - Larry Ullman enough.
It starts you off with the important basics. You then setup some awesome error reporting that will save you hours of pain.
Before you know it, you'll have a config file created, database connection and will be well on your way to creating a secure login using sessions.
This book opened the door for myself and the others I have also force fed it to
-
So i've noticed on this forum alot of people post questions about creating a contact form that will submit results to your email or are having problems getting theirs to work. Well in this topic imma write a simple how to on doing this using 2 fields and a text area name,email,message this will also include this validation for the fields.
Lets start out by creating a basic html form
Contact us.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>My contact form</title> </head> <body> <!--Create the form itself--> <form method="POST" action="process.php"> <p>Name:<br /><input type="text" name="name" /></p> <p>Email:<br /><input type="text" name="email" /></p> <p>Message:<br /><textarea name="message" rows="4" cols="50"></textarea></p> <p><input type="submit" name="submit" value="Send Message" /></p> </form> </body> </html>
So far that creates a basic html form that reall all we need to do for that page so lets move onto process.php this file will process the form results and if no errors accure will send the email.
process.php
Besure when doing this you put all the php above any html
<?php //Create submit variable $submit = (isset($_POST['submit'])) ? TRUE : FALSE; //Check to make sure the form was sent if(!$submit){ header("Location:Contact us.html"); exit(); } //Create 2 variables one for email address and one for subject $subject = "Your subject"; $to = "youremail@yourdomain.com"; //Success trigger $success = FALSE; //Error trigger $error_tri = FALSE; //Header inject checker $header_inject = "/.@/"; //Email checker $email_check ="/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i"; //Error holder $errors = array(); if($submit){ //Gathering data variables $name = (isset($_POST['name'])) ? $_POST['name'] : FALSE; $email = (isset($_POST['email'])) ? $_POST['email'] : FALSE; $message = (isset($_POST['message'])) ? $_POST['message'] : FALSE; //-------VALIDATION---------- if(!$name){ $errors[] = "Please enter your name!"; } if($name){ if(preg_match($header_inject,$name)){ $errors[] = "You have entered invalid characters in name field!"; } } if(!$email){ $errors[] = "Please enter email address!"; } if($email){ if(!preg_match($email_check,$email)){ $errors[] = "please enter valid email address!"; } } if(!$message){ $errors[] = "Please enter yor message!"; } //Check if any errors if(count($errors) > 0){ //Set error trigger to true $error_tri = TRUE; }else{ //Set success to true $success = TRUE; //Create body variable $body = " You have a new message from your site \n\n Name: $name \n\n Email:$email \n\ Message: $message\n\n "; $headers = "From $name <$to>"; mail($to,$subject,$body,$headers); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Thank you for your message</title> </head> <body> <?php //Check if there are errors if($error_tri == TRUE && $success == FALSE){ foreach($errors AS $error){ echo "$error <br />"; } } //Check if success if($success == TRUE && $error_tri == FALSE){ echo "<h2>THANK YOU: ".$name." Your Message has Been Sent</h2>"; } ?> </body> </html>
Ok so thats a basich how to on creating a contact form script if this was helpful please give me a +1.
-
davewilly reacted to BenTheDesigner in JQuery Username Availability CheckerHi All
Just thought I'd let you know my first tutorial, JQuery, PHP & MySQL Username Availability Checker, is up on my blog over at http://bit.ly/aY9IZ. Take a look, and leave some feedback or suggestions Hope it helps you out, and if it does, +1 me
BenTheDesigner