• Web Dev Questions That Don't Need Their Own Thread v4
    5,001 replies, posted
[QUOTE=pinecleandog;41528335]As much as I love CSS3 transitions, I try to avoid using them because they don't work in firefox[/QUOTE] ...They've been able to use since 4.0 (and I can confirm they work since I use them often) [url]http://caniuse.com/#search=transition[/url]
[QUOTE=pinecleandog;41528335]As much as I love CSS3 transitions, I try to avoid using them because they don't work in firefox[/QUOTE] Obviously they won't work with the -webkit- prefix :v:
Ok, this is what I believe quite a technical question as I have searched in many places and found things similar to what I want but do the wrong function. I want to create a form for a website that writes to a document ( whether it be .txt or excel or whatever). I want to do this as I want people to submit orders of stock they want and it can be all located in a document which can then be accessed and all the orders needed will be displayed there. Now all the other solutions I have found so far allow you to write to it but then any other information submitted after overrides the info already there. I understand that this most likely contains php as that is what the others use (I don't know php at all but no better time to learn than now). Could someone please point me in the right direction or show me how to do this? Many thanks, Slim
[QUOTE=SlimHaydy;41529637]Ok, this is what I believe quite a technical question as I have searched in many places and found things similar to what I want but do the wrong function. I want to create a form for a website that writes to a document ( whether it be .txt or excel or whatever). I want to do this as I want people to submit orders of stock they want and it can be all located in a document which can then be accessed and all the orders needed will be displayed there. Now all the other solutions I have found so far allow you to write to it but then any other information submitted after overrides the info already there. I understand that this most likely contains php as that is what the others use (I don't know php at all but no better time to learn than now). Could someone please point me in the right direction or show me how to do this? Many thanks, Slim[/QUOTE] If you need to store it and are planning on using a text file (up to you), you would need to append to the file instead of overwriting it. (PHP's fopen "a+" parameter).
[QUOTE=andersonmat;41530123]If you need to store it and are planning on using a text file (up to you), you would need to append to the file instead of overwriting it. (PHP's fopen "a+" parameter).[/QUOTE] As I said before, I do not know [B]any[/B] php. How quick would it be to learn it? Or if quicker, do you know where I can find a code like this already written up so I can look and possibly temper it to my needs?
Whats the best way to keep a background consistent across diff resolutions?
[QUOTE=SlimHaydy;41529637]Ok, this is what I believe quite a technical question as I have searched in many places and found things similar to what I want but do the wrong function. I want to create a form for a website that writes to a document ( whether it be .txt or excel or whatever). I want to do this as I want people to submit orders of stock they want and it can be all located in a document which can then be accessed and all the orders needed will be displayed there. Now all the other solutions I have found so far allow you to write to it but then any other information submitted after overrides the info already there. I understand that this most likely contains php as that is what the others use (I don't know php at all but no better time to learn than now). Could someone please point me in the right direction or show me how to do this? Many thanks, Slim[/QUOTE] A MySQL database would be more appropriate for storing these records than a text file. I wrote an example: [PHP] <?php if(isset($_POST['submit'])){ $ip = '127.0.0.1'; $db = 'mydatabase'; $user = 'user'; $pass = 'password'; // Create the PDO Object $pdo = new PDO('mysql:dbname='.$db.';host='.$ip, $user, $pass); // Prepare the statement $statment = $pdo->prepare("INSERT INTO mytable (sometext, anumber) VALUES (:sometext, :anumber)"); // Bind values $statement->bindValue(':sometext', $_POST['sometext'], PDO::PARAM_STR); $statement->bindValue(':anumber', $_POST['anumber'], PDO::PARAM_INT); // Run the query $statement->execute(); } ?> <form method="post"> <label for="sometext"><input type="text" name="sometext"> <label for="anumber"><input type="number" name="anumber"> <input type="submit" value="submit"> </form> [/PHP] This would work with the following table: [CODE] CREATE TABLE IF NOT EXISTS `mytable` ( `id` int(11) NOT NULL AUTO_INCREMENT, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `sometext` varchar(300) CHARACTER SET utf8 NOT NULL, `anumber` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; [/CODE] To view this data in a HTML table: [PHP] <?php $ip = '127.0.0.1'; $db = 'mydatabase'; $user = 'user'; $pass = 'password'; // Create the PDO Object $pdo = new PDO('mysql:dbname='.$db.';host='.$ip, $user, $pass); // Query the database $result = $pdo->query("SELECT created, sometext, anumber FROM mytable ORDER BY created DESC"); // Return the data as a assosiative array $data = $result->fetchAll(\PDO::FETCH_ASSOC); ?> <table> <tr> <th>Created</th> <th>Some Text</th> <th>A Number</th> </tr> <?php foreach($data as $row): ?> <tr> <td><?php echo $row['created'] ?></td> <td><?php echo $row['sometext'] ?></td> <td><?php echo $row['anumber'] ?></td> </tr> <?php endforeach; ?> </table> [/PHP]
While the above answer is really the best one for what you want,[I] if you feel the itch to write to disk by any means[/I]... [QUOTE=CBastard;41530474] [PHP] <?php if(isset($_POST['submit'])){ $stock_list = fopen("stock_list.txt", "a+"); $string_to_add = '('.date(DATE_RFC822).') '.$_POST['sometext'].' - '.$_POST['anumber'].'\n'; //You can change this with any ways of storing the strings that you want. //Right now it prints date, text and its amount in the following way: (Mon, 15 Aug 2005 15:12:46 UTC) SOMETEXT - SOMEVALUE fwrite($stock_list, $string_to_add); fclose($stock_list); } ?> <form method="post"> <label for="sometext"><input type="text" name="sometext"> <label for="anumber"><input type="number" name="anumber"> <input type="submit" value="submit"> </form> [/PHP] To view this data in a HTML page (with no tables, because I think it's fairly obvious what is what): [PHP] <?php $stock_list = file_get_contents('stock_list.txt'); if($stock_list == FALSE){print "No list of stock exists (yet) !";} else {print $stock_list;}; ?> [/PHP][/QUOTE] Haven't tested it, but unless I've missed something, it should work just fine.
Hi guys, I have a question that has always been bugging me. Why do each person (usually) have a different git branch? How do front-end and back-end devs collaborate like that? Why not just use masters? [editline]20th July 2013[/editline] also, what the hell? [img]http://i.imgur.com/sU3Ojod.png[/img]
[QUOTE=garry;41521569]Cloudflare is fucking terrible. They want $200 a site to enable 'real' DDOS protection. If you don't pay the $200 this happens (I was on the $20 plan at the time). [img]http://i.imgur.com/AhsvFMd.png[/img][/QUOTE] "they're a business and they want money for their services. how terrible" Bandwidth is expensive. I'm not really a fan of CF, but what they do have is massive amounts of bandwidth. No one else has that. [QUOTE=garry;41517066]What I'm looking for is somewhere totally managed, that scales with traffic, so if I get ddossed it just throws up more servers and copes - and costs me more money. So I don't have to do anything.[/QUOTE] So instead of a fixed $200 monthly cost (per site) you're going with a variable cost that's based on how many people didn't like you during that billing period. Does that really make sense? [highlight](User was permabanned for this post ("Didn't I already ban you once" - garry))[/highlight]
If you set a certain font family for your website by putting it in the body and say I wanted to use a different font for a certain thing, Do I need to add all the extra fonts in font family? E.g I want a header to be in the 'Sego UI' font, do I need to put 'calibri, arial, sans-serif' etc after it even though its set in the body?
so trying to add a small login area to my page so people can login to the game panel. however, it wont open up the pop up to try to login. this all sits in an html file. any clue as to what i'm doing wrong? [code] <div id="login-holder"> <script type="text/javascript"> function LaunchPopup(page) { newwindow = window.open(page + document.getElementById("un").value + "&password=" + document.getElementById("pw").value); } </script> <form method="post" name="ugcclogin"> <strong> <span style="color:#00ff00;">Username: </span> <input name="un"><br> <span style="color:#00ff00;">Password: </span> <input name="pw"> </strong> <button type="button" class="sml-btn green" onclick='LaunchPopup("http://panel.somesite.com/default.aspx?user=")'>Login</button> </form> [/code]
[QUOTE=FrankPetrov;41544127]so trying to add a small login area to my page so people can login to the game panel. however, it wont open up the pop up to try to login. this all sits in an html file. any clue as to what i'm doing wrong? [code] <div id="login-holder"> <script type="text/javascript"> function LaunchPopup(page) { newwindow = window.open(page + document.getElementById("un").value + "&password=" + document.getElementById("pw").value); } </script> <form method="post" name="ugcclogin"> <strong> <span style="color:#00ff00;">Username: </span> <input name="un"><br> <span style="color:#00ff00;">Password: </span> <input name="pw"> </strong> <button type="button" class="sml-btn green" onclick='LaunchPopup("http://panel.somesite.com/default.aspx?user=")'>Login</button> </form> [/code][/QUOTE] It can't find the ID's, since your javascript is trying to look for objects with id's of "un" and "pw", and not the names. Give the inputs proper id's as well.
[QUOTE=eternalflamez;41544265]It can't find the ID's, since your javascript is trying to look for objects with id's of "un" and "pw", and not the names. Give the inputs proper id's as well.[/QUOTE] I'm quite new to javascript, if you wouldn't mind, how would I do this?
[QUOTE=FrankPetrov;41544961]I'm quite new to javascript, if you wouldn't mind, how would I do this?[/QUOTE] Change the inputs, as such: [html] <input name="un"> Becomes: <input id="un" name="un"> [/html] [html] <input name="pw"> Becomes: <input id="pw" name="pw"> [/html]
[QUOTE=FrankPetrov;41544961]I'm quite new to javascript, if you wouldn't mind, how would I do this?[/QUOTE] Considering that document.getElementById("pw") will get any elements with the id "pw", you would just need to indicate it on those elements with [B]id='pw'[/B] [editline]21st July 2013[/editline] two ninjas on the same day, great
[QUOTE=FrankPetrov;41544127]so trying to add a small login area to my page so people can login to the game panel. however, it wont open up the pop up to try to login. this all sits in an html file. any clue as to what i'm doing wrong? [code] <div id="login-holder"> <script type="text/javascript"> function LaunchPopup(page) { newwindow = window.open(page + document.getElementById("un").value + "&password=" + document.getElementById("pw").value); } </script> <form method="post" name="ugcclogin"> <strong> <span style="color:#00ff00;">Username: </span> <input name="un"><br> <span style="color:#00ff00;">Password: </span> <input name="pw"> </strong> <button type="button" class="sml-btn green" onclick='LaunchPopup("http://panel.somesite.com/default.aspx?user=")'>Login</button> </form> [/code][/QUOTE] It's probably worth mentioning that transmitting passwords over URL's like that isn't safe in the slightest.
[QUOTE=eternalflamez;41545131]Change the inputs, as such: [html] <input name="un"> Becomes: <input id="un" name="un"> [/html] [html] <input name="pw"> Becomes: <input id="pw" name="pw"> [/html][/QUOTE] Thanks. Still doesn't solve the reason it's not opening the pop up to login to the page. [editline]21st July 2013[/editline] [QUOTE=Dorkslayz;41545185]It's probably worth mentioning that transmitting passwords over URL's like that isn't safe in the slightest.[/QUOTE] What's an alternative? And how is it unsafe?
[QUOTE=Dorkslayz;41545185]It's probably worth mentioning that transmitting passwords over URL's like that isn't safe in the slightest.[/QUOTE] The method is POST.
[QUOTE=CBastard;41545305]The method is POST.[/QUOTE] My understanding of this might be wrong, but I'll give it a shot anyway. [code]<form method="post" name="ugcclogin">[/code] The form has no action, therefore the data isn't being posted anywhere. [code]<div id="login-holder"> <script type="text/javascript"> function LaunchPopup(page) { newwindow = window.open(page + document.getElementById("un").value + "&password=" + document.getElementById("pw").value); } </script>[/code] The function "LaunchPopup" takes a variable called page, then launches a new window with the URL as a series of concatenated variables (takes the value of page, adds it to the value of the username field, add's the string "&password" and then adds the value of the password field). [code]<button type="button" class="sml-btn green" onclick='LaunchPopup("http://panel.somesite.com/default.aspx?user=")'>Login</button>[/code] When the button is clicked, it runs the "LaunchPopup" function with a parameter of "http://panel.somesite.com/default.aspx?user=". When the new window is being opened - it opens with the URL "http://panel.somesite.com/default.aspx?user=*value of username field*&password=*value of password field*. The form POST's nothing.
My mistake, yes that is bad. [QUOTE=Dorkslayz;41545709] The form has no action, therefore the data isn't being posted anywhere. [/QUOTE] When a form is submitted and no action attribute is set it posts it to the current page, so it's posting and doing an AJAX GET at the same time.
I figured it out. Thanks for the help everyone. Though i read something rather interesting tonight. Is php removing mysql support or is gamecp talking out of their asses again? [url]http://forums.gamecp.com/viewtopic.php?f=53&t=6866[/url]
[QUOTE=FrankPetrov;41549129]I figured it out. Thanks for the help everyone. Though i read something rather interesting tonight. Is php removing mysql support or is gamecp talking out of their asses again? [url]http://forums.gamecp.com/viewtopic.php?f=53&t=6866[/url][/QUOTE] Talking out their asses. PHP is removing support for the old mysql_ functions, people should be using mysqli_ [url]http://www.php.net/manual/en/intro.mysql.php[/url] [url]http://stackoverflow.com/questions/13902943/future-of-the-php-mysql-functions[/url]
After reading documentation, I still fail to understand MySQLi's prepared statements. Is it that you put together the statement before you actually query it?
[QUOTE=CBastard;41545973]My mistake, yes that is bad. When a form is submitted and no action attribute is set it posts it to the current page, so it's posting and doing an AJAX GET at the same time.[/QUOTE] Sorry, I should of been clearer. I said "not being posted anywhere" in terms of being posted anywhere useful, since it's not used on the page.
[QUOTE=wh1t3rabbit;41549536]Talking out their asses. PHP is removing support for the old mysql_ functions, people should be using mysqli_ [url]http://www.php.net/manual/en/intro.mysql.php[/url] [url]http://stackoverflow.com/questions/13902943/future-of-the-php-mysql-functions[/url][/QUOTE] Thanks for clearing that up.
[QUOTE=Epiclulz762;41550317]After reading documentation, I still fail to understand MySQLi's prepared statements. Is it that you put together the statement before you actually query it?[/QUOTE] Yep. You separe the query and its data, they go on different ways, and you avoid SQL injections. So first, you prepare the query, adding the placeholder[B] ?[/B] whenever you want to insert data. Then, you bind the params ( $stmt->bind_param("s", $string) ), indicating the kind of variable that it should be (in this case, S as STRING), and the variable itself. Then you execute it, fetch results, etc.
I am using twitter bootstrap to make a dropdown menu. I am trying to make a menu with 2 submenus and get this: [img]https://dl.dropboxusercontent.com/u/14273442/bottstraptrapraprapyoyo.png[/img] Both menus get displayed by default. Is it normal that there is no mouseover event or am I doing something wrong?
What's a good cheap website host? I'm from the UK if it matters
[QUOTE=xianlee;41552098]What's a good cheap website host? I'm from the UK if it matters[/QUOTE] You could check out Nick's services: [url]http://afterburst.com/[/url]
Sorry, you need to Log In to post a reply to this thread.