Jump to content

moose-en-a-gant

Members
  • Posts

    164
  • Joined

  • Last visited

Everything posted by moose-en-a-gant

  1. Hey man I'd be happy to help you, I've mostly been asking rather than giving here so here goes... First you need a connection to the database, and the table name as well as the names of the columns Let's say you've got a form that asks for a name, an age and a bio. I would use four columns for this, the fourth being a unique idenfitication This is the code, save it as a .php file so the php part executes I went through a lot here, you asked for separate eg. action="somewhere.php" but I think that is bad from what I have experienced although in retrospect a delete function uses action="delete.php" for example so... usually forms redirect to themselves for the error checking aspect, someone else may chime in. This code was stripped from one of my functioning websites. Most of this code was given to me, this template from coding forums so I'm happy to help you out. POST is when you hit "submit" so if you read through the code, when the page is first loaded, nothing happens, until a person fills in the form then hits submit, you see if something POST, then the code is executed, error checks are done, if no errors, data is inserted. I've also attached error logs above to displayed if there are any problems. <?php // the MYSQLI_REPORT_OFF is turned off because of a known problem with indexes mysqli_report(MYSQLI_REPORT_OFF); error_reporting(E_ALL); error_reporting(-1); // your server-database connection here $servername = "localhost"; $username = " "; // usually is root $password = " "; $dbname = " "; $link = new mysqli("$servername", "$username", "$password", "$dbname"); if($_SERVER['REQUEST_METHOD']=='POST'){ // this is an array to hold errors such as entering a number in the name field $errors = array(); // a sample error test if (empty($_POST['name'])){ $errors['name'] = "a name is required"; }else { $name = $_POST['name']; } if(empty($errors)){ $id = ""; left empty for database to fill in by auto_increment $name = $_POST['name']; $age = $_POST['age']; $bio = $_POST['bio']; // User is the name of your table // the number of questions matches the number of columns you have in your table // the question marks are for paramenter binding to prevent people from injecting bad code // notice the 'isis' this has to match the data type of your columns, so in sequence, $id, $name, $age, $bio would be of data types int, varchar, int, text which varchar and text are both strings $stmt = mysqli_prepare($link, "INSERT INTO User VALUES (?,?,?,?)"); $stmt->bind_param('isis',$id,$name,$age,$bio); $stmt->execute(); // a message to be displayed upon the completion of the insert shown below in the html where it would appear $_SESSION['status_message'] = "Data inserted"; // this refreshes the page after posting you can redirect to a new page here by chaging the $host and $uri to something like name.com/somewhere.html $host = $_SERVER['HTTP_HOST']; $uri = $_SERVER['REQUEST_URI']; // the path/file?query string of the page header("Location: http://$host$uri"); exit; $link->close(); } } ?> <!DOCTYPE HTML> <head> <style> // can add a style here for the inputs or submit button input[name="name"]{ width: 200px; height: auto; font-size: 100%; color: black; } .errors { color: red; font-size: 100%; } </style> </head> <body> <?php // here is an example of a redirect where you can go somewhere once the insert has been completed. This is a manual method, usually it is automatic and would be bypassed by a redirect above if(isset($_SESSION['status_message'])){ echo '<font color="#ff8400">'.htmlspecialchars($_SESSION['status_message']).'</font>'.' '.' '. '<a href="http://www.somewhere.com" class="linkfix">Go to my profile</a>'; unset($_SESSION['status_message']); // clear the message } ?> // the placeholders place the name of the field inside the input (where you type) and I think this is cleaner but I have shown both ways <form method="post" action=""> <input type="text" name="name" placeholder="name"> <br> // display error above name or next to it <span class="errors"><?php echo isset($errors['name'])? $errors['name']:""; ?></span> <br> <input type="number" name="age" placeholder="age"> <br> name <input type="text" name="bio" placeholder="bio"> <br> <input type="submit" name="submit" value="submit"> <br> </form> </body>
  2. I want to plot the positive side of the function 1/x^2 For now I may simply look one up, trace it in GIMP and use it as a background with a varying height div as columns but I'm curious if someone has done graphing whether it is pChart or GD or whatever... I just want bar graphs that react to varying varialbe values <- redundant? I'd appreciate any thoughts.
  3. I mean if the website did not have HTTPS at all... can I still use websockets? Well, you must be able to, I imagine Omegle uses web sockets and they don't have https.
  4. Do you happen to know if this applies to websockets? As in, if I use a self-signed certificate, will that take care of security issues concerning websocket connection? Thanks for your response.
  5. I'm just wondering how the self-signed certificates compare to company issued ones like by GoDaddy Where do you notice a difference, if you "self-sign" are you in essence "faking" a security? Or what? I mean what makes an HTTPS certificate given out by GoDaddy "legit" ? I may need more SSL certificates and I'm not sure if I want to buy them for like upwardly approximated at $100.00 each
  6. First I don't know if this is the right forum to ask about Web Sockets, I came here because DOM says XML and AJAX says XML Anyway, Reading up on websockets. I came across this paragraph: I don't know if I'm misreading it or misunderstanding it. I only have one SSL certificate that came with a GoDaddy server not self-signed. I'm not really trying to use it on this project. I looked up https and websockets and came across these : If anyone has any experience or information, I'd greatly appreciate the help.
  7. What if it was just four tablets connected together physically by hinges but they were all synced to each other when you opened it, you could even only use one of them, but they were wired together to share power equally... hmm drawing time God, should have bougth that drawing tablet, but doesn't work on linux my Vivotab8 is my windows computer hehe it's no Surface Pro 3 but it is still great, I love it, so glad I finally bought a tablet. I'd draw on that but the stylus I ordered (paid $16.00 more dollars for expedited shipping on a $1.99 item) has still not arrived it's been like a week, should be here by tomorrow apparently. I'd also use the tablet but it is mounted to my laptop screen to the left playing Sherlock Holmes haha So some drawings, using sumo paint, nothing fancy, I like Google SketchUp it's an easy to use 3D modeling, it's not Solidworks by a long shot but it works. Easy to use but again, Linux... no juice to run Wine. Microsoft paint is also a great tool Haven't learned inkscape yet, wasn't pleased from my brief encounter eh... nothing like drawing with your hands on clean copy paper... damn lines four asusvivotab 8's what is that, $640.00 for a four screen device, four quad core processors, with 8 GB of RAM... would be interesting. The base tablet would be used as the keyboard, maybe 10" is better, like the size of a normal keyboard.
  8. Kind of a future project when I'm in a better state but I recently (today) attached my VivoTab8 tablet to my HP Presario CQ60 using a coat hanger, foam, hot glue and some rubber bands. It's mounted like a simple pivoting sign, supported at the bottom right and glued at the top. So I can watch a movie while I use my main screen to split screen. I actually have a secondary monitor but I only connect to that when I'm sitting upright eg. at a desk. But when I reach that point where I can't code anymore but still awake, I put on movie after movie till I pass out, in the meantime researching and learning about different subjects. So, this to me is useful thus: I wanted a laptop with four screens... yes, FOUR Imagine your average laptop, it has two halves, you open it and the screen pops up perpendicular to the keyboard. Then, imagine unfolding the first fold to the left, the second fold to the right, then the last fold upwards, now you have a laptop with four screens. I don't know if anyone else has done this, it seems like a fun project to me. I was talking to quick about building super computers using networking or literally connecting a bunch of smaller computers or even those that you plug into walls. Anyway, I alwasy wanted to muck around with Raspberry Pi's, I recently heard about ODroid which is apparently even better but anyway. Virtual mapping, this may not be the correct term but, what I want to do which ties in with a different project... hold on, there are three things here: 1) virtual map the screens and join them together as one 2) virtual map a laptop to a mobile phone on any software using wifi 3) virtual map the individual single board computers to act as one hence "super computer" I realize that raspberry pi's arent' that powerful, wait... quad-core? What!!! A 900MHz quad-core ARM Cortex-A7 CPU 1GB RAM http://www.raspberrypi.org/products/raspberry-pi-2-model-b/ Anyway, I would use like 3 or more of these, design a special "circuit-*ehem*-bread-board" Ideally I would design a laptop body to be 3D printed that houses the three or more raspberry pis inside A cheaper alternative perhaps fun too and also a nightmare would be to buy crap laptops from craiglist for like $100.00 each and take off their screens, I realize the adapters may pose a problem but again the virtual mapping. Treat the panels like four parts of a square and asign values to them like a grid, the cursor has a "fake" value that is arbitrary, following the fake screens but is displayed on the screen. Anyway, this is probably super hard as I haven't actually delved into it yet but it's one of my projects hehe. Just wanting to see if anyone has any insight on it. I don't know, I'll probably spend some time building custom computers even steam punk ones or like a Pip Boy from Fallout 3. Would be fun, using Lithium Polymer batteries (use them for drones) as a power source, building regulators, custom designs, maybe just gut laptops and clob parts together, I don't know... About #2 I created a phone stand out of a credit card where you place the phone in landscape mode, so your phone sits like that on your desk, kind of neat, there's a tutorial on youtube about it that I made. Anyway, I wanted to be able to take the mouse from my computer and go into the phone with the mouse, the phone comes on from sleep and I can click on stuff with the mouse and also use the keyboard on the computer to type into the phone. I would use internet relaying to trasnfer the commands probably have to deal with API on the phone part but I don't know, I "suggested" it to microsoft but eh... who knows. They don't seem to pay attention to people, I asked Tesla Motors how much they would convert a Lamborghini Aventador to electric but no response, one day when the cost of an Aventador is 10% of my networth, I'll find out myself. Yeap so I ranted... luckily I build websites so I'll write my own tech DIY sort of websites in the future, it's fun to buy domains... <- confession of a shop-a-holic right there haha
  9. Well I wiped my computer anyway Brings some ideas to mind, multiple partitions on hard disk drives Running a mobile operating system on a micro sd card I'd like to look into a 'glove-type' operating system <- made that up Where the operating system operates independent of the main operating system but has no interent access I don't know if it is impossible to completely isolate an operating system from transfer but still affect things outside of itself It would be cool to "chain-reaction" build an operating system from nothing, like say you buy a phone, then you load in a sim card and this sim card has a very basic instruction on it that starts a chain reaction that builds a secondary os within the primary os... anyway just thinking without knowing their so could be completely BS but... Definitely on my mind is privacy and security, I want to know that I am completely secure. It would be cool to have personal devices manufactured for me, like the Samsung Edge or whatever came out, why wasn't it entirely made of glass? I don't know or an extruded rectangle with rounded ends like the Lumia 920's shape, glass all around except the ends like endcaps to a pipe. Or ideally the entire thing is transparent, graphene? Anyway, build a dual motherboard phone, you have two phones on each side, anyway... would be cool to create any color scheme that you want, phone charges from sound, vibration, heat from your hand and solar. Opacity, color, every part of the surface is an LED... just rambling here
  10. So... browsing gmail and I see this email with a person's name... I don't know the person... I'm not usually a noob. Luckily in a way I use linux but I'm concerned about key logging... again Linux... not sure if still equally vulnerable to windows. I upload the file and scan it here, nothing https://www.virustotal.com/ https, trustworthy right? Still... I'm inclined to load up my Linux Mint 17 Qianna DVD and install clean Nothing really to lose, just have to reinstall files, upload some files to my server and then redownload them. Yeah it says "You've won $500,000.00 just write down all of your information and send it here hahaha it even has a signature... Oh man... so... am I being paranoid? Should I not care? I don't know.
  11. The ini_set helped, that seems to show errors, I mean if it doesn't work I know something is wrong haha then turn the errors on, it seems though that MySqli All is my primary problem. Thanks for your input
  12. So the remaining 19, that's nothing then. Doesn't count as "allocated space" ? Also, the letter a, is that a byte? 8 bits = 1 byte but... I'll ready on this Thanks for the clarification I'll use varchar255 for potentially long entries and text for paragraphs / lots of text
  13. I'm still unclear on this, If I only use 17 characters and I declared varchar(255) or anything more than 17 like varchar(30) is that a waste? Is that length allocated? Should it be exact? I don't know exactly the number that is generated from my passwordhashing with an array cost of 9, I think it is fixed I just haven't counted each one yet, could just paste it into a character counter but if I use varchar(255) to be safe, is that fine or am I wasting space wtih the unused space?
  14. I don't understand what that means I have id and it is autoincremented then under the table structure it says INDEXES: and id is shown Type BTREE Unique No
  15. thank you that is great. I'll read up on that.
  16. Oh man that was perfect, I had these which didn't show any errors mysqli_report(MYSQLI_REPORT_OFF); error_reporting(E_ALL); error_reporting(-1); Yes the first one is off because the error which was shown by the ini_set was a lack of index which I asked about in the past, I still haven't solved the problem The solution I have found on stack overflow was to turn off mysqli_report which indeed works now, no white page. I have an index or key set. I don't know what to do about the error of no index used.
  17. I'm not sure if this is the appropriate forum to post about this although I chose HTML because of input of a form I want to cache what I have written in the event of a username session timeout, which is what I'm facing now, I'm writing a lot of stuff, when I finally push "submit" my session username is gone and the data disappears even when I hit back. I've seen this cache on a few forums and even yahoo answers I need this function How do I achieve it or what do I look at?
  18. Thanks for your responses and that link, going to give that a gander
  19. Do I need to declare a length for a varchar? If you say varchar(255) isn't that the max?
  20. Part I control statement list generator I think this could be simplified with a permuation but first, this problem of creating a list based on certain conditions, This is the rough structure of my list generator: First I have a table with people in it; stores a person's id, gender, orientation, interested partner, age The orientation is uncertain because in some cases it seems redundant like a transgender person declaring a gender Anyway, so given the five pieces of information I create an "alogrithm?" or control statement list generator based on user id's like this: Start with gender then orientation then age The age part is concerning, I have a character fix of 2, eg. 10 to 99 I am doing in ten years like 10 to 20, 20 to 30, etc... but using a <= operator So person A looking for person B Person A is a male, straight, age<=20 One branch of the control statement is about 30 lines or less which doesn't seem bad, but that's 3 x 6 x 3 x 30 = ~ 170 lines of code which doesn't seem bad. I'm also concerned about using switch instead of a try-all-till-found sort of control system The multiplication mambo jambo over there is from the three specifications of a person: gender: male,female,both orientation: straight, lesbian, gay, bi, don't care to say, other date sought: male, female, both I realize too that this can be much better Already my form is ugly, there are 7 lines to be filled including username, email, password. Part II who has viewed who This is a matter of what works best or are they the same. I want the experience to be this: once you've passed a person eg. declared you weren't interested in him / her, you don't see them again, unless you want to. I'm not sure yet how I will generate a list, I know already that it won't be images, but numbers eg. text only, but how do you have a current list eg. when new members sign up after you have generated a list? This is more related above but... The thought is to create a separate table with at least three columns: id, user, user id viewed Can it be better than that? The problem here is that say 16 people exist on the website, then for each person to look at the other person, what is that 16 x 15 = 240 columns? Just from 16 people? Can it be better? Thanks for any suggestions
  21. Simpler is not a bad thing hehe I have 0 idea at the moment, was going to read about this when I reach that stage of "can't write code anymore but still awake". Thanks, that's what I will read about then.
  22. I'm working on a dating website, nothing new, just to touch up on sockets, file sharing, dragging, ajax, a bunch of different stuff that will help me learn more and implement into future projects. Currently I'm working on the "flow" or control statement of the results a person matches right now I'm going by gender, orientation then age, then from here on some more stuff, but I'm going to post another thread about asking to simplify like a switch statement possibly, anyway I'm curious about two things: age and photos I know that you guys aren't legal experts or something, I'm just hoping that maybe one or two of you have worked on a similar project and have learned some things about legal implications. For example, I set an age limit of 2 digits, so 100 is out (obviously) and 9 is out and below but what about 10 or anything between 10 and 17 say... I'm not trying to "restrict minors" although I'm not sure if I'm supposed to anyway. I am thinking of implementing something where a 50 year old can't talk to a 17 year old but these are default settings, and I will give a user the ability to change their filter settings. Regardless a person can fake their information which I catch by my own design but anyway About the nude photo thing, I read that (OCR?) automated systems can be fooled like a bald head or a stomach or something so, what happens there? I'm scared about CP, don't want that stuff. Really anything nude so I'm not sure what to do. Is it bad to give a dating website "free reign" ? I mean of course a person can "block" another person but... I don't know I'd appreciate any thoughts on this matter.
  23. Say you aren't sure how long a value is, but it's not more than 10 characters and you use text instead of varchar(10) just because you are unsure, is that a waste? I mean is "empty space" allocated by specifying a length or what?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.