Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,206,475 members, 7,995,851 topics. Date: Wednesday, 06 November 2024 at 04:49 PM |
Nairaland Forum / Science/Technology / Webmasters / Php Class For Beginners. Question Will Be Treated With High Priority. (35698 Views)
How Should Archive And Label Pages Be Treated? / Blogging Advice For Beginners / Designing A Website: For Beginners (2) (3) (4)
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) ... (13) (Reply) (Go Down)
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by RuuDie(m): 4:21pm On Oct 29, 2009 |
yawa-ti-de: Its R.u.u.d.i.e madamoiselle yawa-ti-de: Thanx for all the effort. . . . but are there really beaches in Potiskum yawa-ti-de: Very correct. . . . yawa-ti-de: what directory might this be yawa-ti-de: makes a world of sense. . . . yawa-ti-de: Sure will, thank you so very much. . . you work in a software devt firm |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by yawatide(f): 4:43pm On Oct 29, 2009 |
Jokes aside, I am happy that I now have a better understanding of what you are looking for and that my suggestions have helped. No, I don't work in a software development firm per se (I mean, let's face it, don't let anyone tell you that as a web developer you aren't developing software cos u r, albeit for the web ). I work on a corporate website and we use JSP. So rather than wear many hats at the same time, I would rather wear the hat that fits the occasion if you know what I mean. |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by RuuDie(m): 6:18pm On Oct 29, 2009 |
@ yawa-ti-de, sorry i haven't yet tried anything cuz work is just closing now for me. . . . 6am - 6pm, e no easy oh! |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by folarin22(m): 1:49pm On Oct 30, 2009 |
try this site it will be helpful http://naijabaze.wap9.mobi |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by RuuDie(m): 6:04pm On Oct 31, 2009 |
here is the codes i used - pls help check for whatever it is am doing wrong: this is the script that inserts the values into the database <?php $user_name = "root"; $password = ""; $database = "onlinedating"; $server = "127.0.0.1"; $db_handle = mysqli_connect($server, $user_name, $password, $database) or die ("Error connecting to database" if($_SERVER['REQUEST_METHOD'] == 'POST') { $name = $_POST['txtName']; $sex = $_POST['sltSex']; $email = $_POST['txtemail']; $phone = $_POST['txtphone']; $location = $_POST['txtlocation']; $description = $_POST['txtDesc']; $photo = $_FILES['filePic']['name']; $username = $_POST['txtUsername']; $pword = $_POST['txtPass1']; here's all the database field names //(us_Name, us_Sex, us_Email, us_Phone, us_Loc, us_Desc, us_Photo, username, password, reg_Date, reg_Time) } $query = "INSERT INTO reg_users VALUES ('$name','$sex', '$email', '$phone', '$location', '$description', '$photo', '$username', '$pword', NOW(), NOW())"; $result = mysqli_query ($db_handle, $query); mysqli_close ($db_handle); ?> html code for the form - which calls the script above <table width="777" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#333333"> <tr> <td bgcolor="#FFCC66"><h1 align="center"><br> <span class="style7">New User Sign Up</span> <br> <br> </h1></td> </tr> <tr> <td><form action="confirmation.php" method="post" enctype="multipart/form-data" name="form1"> <table width="100%" border="0"> <caption> </caption> <tr> <th width="46%" scope="row"><div align="right" class="style4">Name</div></th> <td width="54%"><input name="txtName" type="text" id="txtName"></td> </tr> <tr> <th scope="row"><div align="right" class="style4">Sex</div></th> <td><select name="sltSex" size="1" id="sltSex"> <option>Male</option> <option>Female</option> </select> </td> </tr> <tr> <th scope="row"><div align="right" class="style4">Email</div></th> <td><input name="txtemail" type="text" id="txtemail"></td> </tr> <tr> <th scope="row"><div align="right" class="style4">Phone Number </div></th> <td><input name="txtphone" type="text" id="txtphone"></td> </tr> <tr> <th scope="row"><div align="right" class="style4">Current Location</div></th> <td><input name="txtlocation" type="text" id="txtlocation" size="20"> / <select name="sltLoc" size="1" id="sltLoc"> <option>Anambra</option> <option>Abia</option> <option>Adamawa</option> <option selected>Lagos</option> <option>Rivers</option> <option>Abuja</option> <option>Cross River</option> </select> </td> </tr> <tr> <th scope="row"><div align="right"><span class="style4">Describe Yourself </span></div></th> <td><textarea name="txtDesc" cols="45" rows="5" id="txtDesc"></textarea></td> </tr> <tr> <th scope="row"><div align="right"><span class="style4">Upload Photo </span></div></th> <td><input name="filePic" type="file" id="filePic" size="30" accept = "image/jpeg"></td> </tr> <tr> <th scope="row"><div align="right"><span class="style1"><span class="style5"><span class="style1"><span class="style5"></span></span></span></span></div></th> <td> </td> </tr> <tr> <th scope="row"><div align="right" class="style4">Username</div></th> <td><input name="txtUsername" type="text" id="txtUsername"></td> </tr> <tr> <th scope="row"><div align="right" class="style4">Password</div></th> <td><input name="txtPass1" type="password" id="txtPass1"></td> </tr> <tr> <th scope="row"><div align="right" class="style4">Confirm </div></th> <td><input name="txtPass2" type="password" id="txtPass2"></td> </tr> <tr> <th scope="row"> </th> <td> </td> </tr> <tr> <th scope="row"><div align="right" class="style4"> <input name="btnSubmit" type="submit" id="btnSubmit" value="Submit"> </div></th> <td><input name="btnReset" type="reset" id="btnReset" value="Cancel"></td> </tr> </table> </form> </td> </tr> <tr> <td bgcolor="#666666"><div align="center" style="font-size: 12px; color: #CCCCCC;">HOME | ABOUT | NEWS </div></td> </tr> </table>[color=#990000][/color] in the database, i've tried both VARCHAR and BLOB data types for the photo field with the same result - no error messages are generated but form input values are not entered into the database. appreciate all the help i can get. |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by yawatide(f): 9:59pm On Oct 31, 2009 |
The problem is filePic - you are not capturing it in your script. If you are, then I missed it. Again, you need to write the code that creates the directory where the images will be stored. This you will do by getting the value of filePic, creating a directory and then storing filePic's value (the uploaded image) into that directory. Make sense? |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by RuuDie(m): 5:45pm On Nov 01, 2009 |
yawa-ti-de: makes a bit of sense, thanx a bunch. . . . but then, if i do this, how does the script or any other script reconcile the two different directories - the 1 specified in the input field and then this 1 to be created? my sincere apologies if i'm wearing u out with the questions; its just so confusing right now! |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by yawatide(f): 9:16am On Nov 02, 2009 |
he he, you aren't wearing me out. If you were, I wouldn't even respond The directory in the "browse" textfield is a "dummy" directory. The only thing that is "extracted" from that textfield is the last item - whatever it is that you are uploading. The PHP script then creates a directory and adds what you are downloading to that directory. The directory in the "browse" textfield is just for the script to know where to go to copy the image. e nu go? |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by RuuDie(m): 12:56pm On Nov 02, 2009 |
yawa-ti-de: really not my intention pls. . . . am just a plain, dumb Bleep with dis php thingy. yawa-ti-de: hmmmmm. . . . makes a world of sense; you are pretty good, you know! yawa-ti-de: yeah i dig! |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by quadrillio(m): 1:01pm On Nov 02, 2009 |
I believe enough people are learning here wit dis. please bring more. @yawa, everyone thanks @ruudie, u almost there. |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by yawatide(f): 3:58pm On Nov 02, 2009 |
eally not my intention pls. . . . am just a plain, dumb Bleep with dis php thingy.Come on! Assuming this isn't a joke, don't say that. Everyone has to start from somewhere. I was where you are 4 yrs ago and guess what? There are things that I still don't know The important thing is that you finally get it, you make sure it sticks, while constantly learning new things. This way, you always have marketable skills. Good luck! |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by RuuDie(m): 11:49am On Nov 03, 2009 |
tried and failed again. . . this getting depressing! hey. . . . could it be because the form is pointing to a script on another page i mean its not a self-referencing form. . . . . |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by yawatide(f): 12:00pm On Nov 03, 2009 |
Based on your code above, most likely. I see the php on the same form page. I like to separate my form from my "processing page (in your case, confirmation.php)" so try moving your php code into the confirmation page and let us know how it goes. Don't get depressed just yet. Remember, you aren't alone in this battle. Others have tried and prevailed. Don't be the odd ball |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by quadrillio(m): 11:56am On Nov 04, 2009 |
RuuDie:dont get depressed, like yawaytide said "Coding is serious business, " jus try out d other steps, there's no victory in trying and failing, victory comes when u succeed. so far, yawatide's steps are dbest for you so don't loose focus. yawa-ti-de:yes, we solidly behind u. |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by quadrillio(m): 3:28pm On Nov 04, 2009 |
I decided to dedicate like 30min of my time to search around and put up dis tutorial. cos I think many are watching and learning. this a script dat upload an image to a dir, and also show u ow to retrieve it for display. LET'S START first, your form to choose d image to upload <form action="./upload.php" method="post" enctype="multipart/form-data"> <p> <label for="file">Select a file:</label> <input type="file" name="userfile" id="file"> <button>Upload File</button> <p> </form> dis is to create a form and link to a file named:"upload.php" to process it. Secondly, write d script to process d image. This will check that the file upload is safe by setting a list of allowed filetypes and disallowing all other file uploads. This will prevent people from uploading malicious files. Then we will check the filesize to prevent large files from being uploaded. <?php // Configuration - Your Options $allowed_filetypes = array('.jpg','.gif','.bmp','.png'); // These will be the types of file that will pass the validation. $max_filesize = 524288; // Maximum filesize in BYTES (currently 0.5MB). $upload_path = './files/'; // The place the files will be uploaded to (currently a 'files' directory). $filename = $_FILES['userfile']['name']; // Get the name of the file (including file extension). $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename. // Check if the filetype is allowed, if not DIE and inform the user. if(!in_array($ext,$allowed_filetypes)) die('The file you attempted to upload is not allowed.'); // Now check the filesize, if it is too large then DIE and inform the user. if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize) die('The file you attempted to upload is too large.'); // Check if we can upload to the specified path, if not DIE and inform the user. if(!is_writable($upload_path)) die('You cannot upload to the specified directory, please CHMOD it to 777.'); // Upload the file to your specified path. if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)) echo 'Your file upload was successful, view the file <a href="' . $upload_path . $filename . '" title="Your File">here</a>'; // It worked. else echo 'There was an error during the file upload. Please try again.'; // It failed . ?> there u go, suitable upload script please NOTE that by default PHP will not handle file uploads larger than 2MB, if you require PHP to handle larger files then you must first set upload_max_filesize and post_max_size in your php.ini file to be larger than 2MB. I hope dis helps. SAFE. |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by RuuDie(m): 11:52am On Nov 06, 2009 |
Thanks Quadrillo, even my untrained eye can see its a darn good script. . . but my computer must have massive issues with finding "paths." I used your code - exactly as it is but guess what I get a frigging parse error right here $upload_path = './files/'; // The place the files will be uploaded to (currently a 'files' directory). I just don't get it. . . . i created the folder "files" folder inside the folder where all the other pages are!? Can you think of anything i might have gotten wrong? |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by latbabs(m): 4:28pm On Nov 06, 2009 |
i asked for generating number and i will like it if u can give me the two, but i need the one for pin. so make it fast, |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by RuuDie(m): 6:34am On Nov 07, 2009 |
@ quadrillo, hey man, plenty thanx. the script worked - found the error i'd made that stopped it from working right. but i still have cannot input those values into my database - please help me review the codes i posted earlier abeg! |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by yawatide(f): 10:55am On Nov 08, 2009 |
i asked for generating number and i will like it if u can give me the two, but i need the one for pin. so make it fast, poster: Is this a good way to seek help? I will let you be the judge |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by maranro(m): 10:51pm On Nov 08, 2009 |
thanks quadri 4 d class. Pls i want 2 learn web design and development. Lets discuss my mail is abey232000@hotmail.com |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by quadrillio(m): 9:54am On Nov 09, 2009 |
latbabs:Is this an ORDER or a REQUEST? RuuDie: am takin my time to review ur code. will post back back d edited version later. maranro:later. D class will continues, SAFE. |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by Nobody: 8:49pm On Nov 09, 2009 |
just strolling by. . . |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by quadrillio(m): 9:58am On Nov 11, 2009 |
*dhtml:we're together |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by RuuDie(m): 1:32pm On Nov 11, 2009 |
*dhtml: quadrillio: guys, abeg una no stroll me pass oh |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by quadrillio(m): 8:57am On Nov 17, 2009 |
@ruudie, can I continue d class now? hope u ve find your way round it? d class starts now, |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by quadrillio(m): 4:33pm On Nov 17, 2009 |
next in d class,we'll be introducing ourselves to OOP in PHP OOP meaning, Object Oriented Programming where we'll also learn about d different types of Design patterns and others. - Safe |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by RuuDie(m): 4:22pm On Nov 18, 2009 |
quadrillio: Carry go bro. . . . nothing do u! |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by quadrillio(m): 4:17pm On Nov 19, 2009 |
Object-Oriented PHP PHP can, if you want, be written in an object-oriented (OO) fashion. In PHP5 & 6, the OO functionality of the language has been enhanced considerably. If you are familiar with other OO languages, such as C++ or Java, you may prefer the OO approach to programming PHP, whereas if you are used to other procedural languages, you may not want to use objects at all. There are, after all, many ways to solve the same problem. If you are new to programming as well as to PHP, you probably have no strong feelings either way just yet. It's certainly true that OO concepts are easier to grasp. The aim of this lesson is to introduce how a class is created and referenced in PHP so that if you have a preference for using objects, you can begin to develop scripts by using OO methods. Most importantly, however, you will be able to pick up and use some of the many freely available third-party class libraries that are available for PHP from resources such as those at phpclasses What Is a Class? A class is the template structure that defines an object. It can contain functionsalso known as class methodsand variablesalso known as class properties or attributes. Each class consists of a set of PHP statements that define how to perform a task or set of tasks that you want to repeat frequently. The class can contain private methods, which are only used internally to perform the class's functions, and public methods, which you can use to interface with the class. A good class hides its inner workings and includes only the public methods that are required to provide a simple interface to its functionality. If you bundle complex blocks of programming into a class, any script that uses that class does not need to worry about exactly how a particular operation is performed. All that is required is knowledge of the class's public methods. Because there are many freely available third-party classes for PHP, in many situations, you need not waste time implementing a feature in PHP that is already freely available. When to Use Classes At first, there may not appear to be any real advantage in using a class over using functions that have been modularized into an include file. OO is not necessarily a better approach to programming; rather, it is a different way of thinking. Whether you choose to develop your own classes is a matter of preference. One of the advantages of OO programming is that it can allow your code to scale into very large projects easily. In OO programming, a class can inherit the properties of another and extend it; this means that functionality that has already been developed can be reused and adapted to fit a particular situation. This is called inheritance, and it is a key feature of OO development. When you have completed this book, if you are interested in learning more about OO programming, take a look at Sams Teach Yourself Object-Oriented Programming in 21 Days by Anthony Sintes. What a Class Looks Like A class is a grouping of various functions and variablesand that is exactly how it looks when written in PHP. A class definition looks very similar to a function definition; it begins with the keyword class and an identifier, followed by the class definition, contained in a pair of curly brackets ({}). The following is a trivial example of a class to show how a class looks. This example contains just one property, myValue, and one method, myMethod (which does nothing): class myClass { var $myValue; function myMethod() { return 0; } } |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by quadrillio(m): 4:43pm On Nov 30, 2009 |
Guys, am seriously busy on a project, BRB. |
Re: Php Class For Beginners. Question Will Be Treated With High Priority. by Nobody: 11:22pm On Dec 01, 2009 |
same thing here. |
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) ... (13) (Reply)
When You Are A Computer Guru And Your Girlfriend Needs Your Assistance / The Meaning Of CAPTCHA & 6 Types Of CAPTCHA / Meet The Nigerian Lady Zuckerberg Mentioned In Live Chat After Visit (PICTURED)
Viewing this topic: 1 guest(s)
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 108 |