[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Ok faggots, can any of you code PHP/MySQL?

This is a red board which means that it's strictly for adults (Not Safe For Work content only). If you see any illegal content, please report it.

Thread replies: 80
Thread images: 6

File: Screenshot_18.png (8KB, 680x137px) Image search: [Google]
Screenshot_18.png
8KB, 680x137px
This is a simple like button. I need it to save and display clicks. I've been trying to learn PHP and SQL for days now, but it's fucking retarded. And my site needs to be live very soon. How do I do this?
>>
>heigth
>width and height in HTML
>FONT element

JUST
>>
>>25801595
I feel like this thread would be better on any board but this one
>>
>>25801595
Ya I can help. Is that your full code?
The button needs to be in a form. The form action should be a seperate PHP script page (or the same page if its just simple shit). Preferably the form should be method POST. In the PHP page you connect to sql and run an insert query.
If you show me more code I can give you specifics
>>
>>25801641
nothing's wrong with that you fucking nigger
>>
I can help. Instead of using php, use javascript to make a sql request to your database.

Also >>>/g/
>>
>>25801672
Its better to put it in a style tag. The font element is pretty useless considering you can just use a span
>>
That's neither php or MySQL, that's just html
Either way, you have to store each post on to a MySQL database so you can assign it an ID, so it's easier to display in a list, and another column for number of likes
>>
>>25801670
That's all my code, yes. I appreciate ya.
>>
what kinda website you making pham?
>>
>>25801670
Wait, I'll give you my full page
>>
>>25801672

Yes it is

Put the styling in css.

- web developer
>>
>>25801670
Here

http://shorttext.com/718fb01a
>>
>>25801595
>font tags

don't do that
>>
>>25801700
I'll change it then for you OCD niggers
>>
>>25801772
Do you have any databases? If so are any tables set up?
>>
File: Screenshot_19.png (15KB, 229x311px) Image search: [Google]
Screenshot_19.png
15KB, 229x311px
>>25801833
I did this. Sorry for taking long to reply, I keep getting muted
>>
File: Screenshot_20.png (34KB, 1435x280px) Image search: [Google]
Screenshot_20.png
34KB, 1435x280px
>>25801833
Excuse my nigger language
>>
lol, go to stack overblow if you want somebody else to do your homework
>>
>>25801988
They told me to fuck off
>>
>>25801670
>lol what is javascript
events are a thing niggr
>>
>>25801988
Which I don't understand. This should be simple and fast, I'm just too stupid to to it myself. I thought someone there would at least give me a hint.
>>25802019
I don't understand your fucking javascripples
>>
File: ring-lord.jpg (53KB, 600x800px) Image search: [Google]
ring-lord.jpg
53KB, 600x800px
Is this the /r9k/ programming thread? If so, I could use some help.

How do I create an undo/redo method in FX/FXML without Swing? I studied the command design pattern, but I'm unsure how to properly implement methods that correlate to undoing actions within a text area.

Does anyone here have any tips?
>>
File: johnny rumbles.jpg (6KB, 210x200px) Image search: [Google]
johnny rumbles.jpg
6KB, 210x200px
>ask php/sql question
>"it's easy", just

>use css font, faggot
>use javascript
>go to /g/

Thanks, friends!
>>
>>25802049
http://pastebin.com/TDuyD0eg
Here is rough layout of how it should look. you are lucky I am bored right now
>>25802019
What is the point?
>>
Just put in html for the button <input type ="submit" name="submit" method="post" action="count.php" value="submit" />

and count.php

<?php
if (array_key_exists($_POST['submit'])) {
$this->db = new PDO('mysql:host='YOURHOSTHERE';dbname='.YOURDBNAMEHERE'', YOURUSERNAMEHERE, YOURPASSHERE);
$this->db->exec('UPDATE table SET field = field + 1');
}

}
if (
>>
>>25802188
You are an true hero
>>
>>25801891
>>25801911
How exactly do you plan on this to work? Do you just need anonymous users to increment a value? Should each user have one like to make? How do you identify each user?
>>
>>25802066
https://github.com/TomasMikula/UndoFX
>>
>>25802220
I'm taking it step by step
>>
>>25802243
Its going to be harder that way. You need to structure everything first.
>>
>>25802271
I'll make it 1 per IP. Now I have something to start off with, so I should be able to get the rest myself
>>
>>25802188
>directly concatenating form data
>no prepared queries

please don't do that.

http://php.net/manual/en/mysqli.quickstart.prepared-statements.php
>>
I can, but I'm not sure what it is you're not getting from a sentence and a screencap. You want to persistently store the like counter across sessions in a database? Say you created the table with something like
>CREATE TABLE post(id INT, content VARCHAR, upboats INT, PRIMARY KEY (id));

Create a new post like:
>INSERT INTO post VALUES (123, "LELELELE", 1);
where 123 is the post ID, "LELELE" is the content, and 1 is the initial upboats.

When the like button is clicked on post #123, then your button would send a POST request to a PHP, which should first do something like
>SELECT upboats FROM post WHERE id = 123;
to get the current likes, add one to it, then
>UPDATE post SET upboats=2 WHERE id=123;
where 2 is the new number of likes.
>>
>>25802311
Why not?

pxlvpxvstopfuckingmutingme
>>
>>25802345
I have multiple pages with a button on each. It should just display the number clicks, 1 every IP.
>>
>>25802293
Ok then I would recommend having the vote table to store IPs instead of votes.
This is how you should have it:
>item PHP page (with vote button) and get data ID
>like button PHP script
>connection PHP page (with login that you keep private, you can secure with apatche etc) (optional but safer)
>table for votes should have IP and page id columns
>item page should check if user IP is in table for that page id (preferably with select only permission login)
>if already in database don't allow click
kinda like this guy >>25802345
>>25802311
I was originally going to use mysqli_prepare etc but didn't feel like writing all the extra lines
>>25802371
People can easily hack it
>>
>>25802234
Thanks famicom
>>
>>25802371
>set pageid to ); SHOW TABLES; (
>???
>profit
>>
>>25802444
Okay, thanks again. When people click like, they're directed to another page, kind of like a roulette. So I didn't think the IP think was too important.
>>
>>25802561
http://pastebin.com/V1CskZ6E
This should get you most of the way there
>>
>>25802740
>http://pastebin.com/V1CskZ6E
Do you have a way I can thank you? That doesn't involve the dust in my wallet?
>>
>>25802893
Well, I haven't had my dick sucked in a while.
>>
>>25802893
nah its good. just git gud at coding and thank me later
>>
>>25802906
I'll suck it but no homo
>>
op i'll do it after i get home from the gym, if you post your email i'll get back to you
t. web designer who uses php & mysql every day at work
>>
>>25803646
You can send it to [email protected], appreciate it
>>
>>25803646
But another fella has already sent me a solution, so you don't have to waste your time. But he says it's vulnerable to hacking.
>>
>>25803896
nobody's gonna hack it desu unless some anon on here did it just to spite you

did you gey it working?
>>
>>25804564
Not yet, I'm about to fucking kill myself

I use foundation and I'm trying to change <p> text to 255,255,255,0.5 but it won't let me. I can use color:white, but not color:255,255,255. Fucking coding
>>
>>25804564
Fuck yeah I fucking fixed it

WOOOO

Just had to do opacity: 0.5;

I'll get back to you
>>
>>25804564
One question about your script. The like button is an image. How do I edit the code appropriately?

And the image links to index.php which looks like this:

<?php
$urls = array (
"1.php",
"2.php",
"3.php",
"4.php",
"5.php",
"6.php"
);
$random = (rand()%6);
header("Location: ".$urls[$random]);
exit;
?>

Is that a good way to do it?
>>
>>25804564
And how is the number displayed?

Sorry, I'm a fucking imbicile and it's 5 am
>>
>>25805752
What the fuck is this
what do those files contain ( 1.php, 2.php, etc.)?

I just got into this thread and i'm so confused right now

All you need to do is a form which points to index.php or some other php file, the file will receive the POST data and you save to the DB that's about it. Add some cookie and/or session data to detect if someone already voted (or go by IP like mentioned above)
>>
>>25806473
Nigga, the button links the user to a random page
>>
>>25801736
This. Thank you. The fact that OP is using PHP is bad enough let alone him not knowing how to use CSS.
>>
>>25806518
What's wrong with PHP now? Everybody criticises my coding, but no one has anything better, funny enough
>>
>>25806507
I saw that, i'm wondering why, why have 6? Why do you need different files?
Why does he need random pages?
Even the point is to load "different" pages for each user, 6 is not nearly enough and that code is fucking rubish
>>
>>25806603
I explained why I need random pages in >>25802561

6 is just an example

Again, some cunt criticising my code without having anything good to say about how to improve it
>>
>>25806754
Sorry about that, it's just not clear what you're trying to do and the info is scrambled in this thread, you can't expect us to keep up when you don't even have a trip or name or if you had just made it very clear from the start what the flow was supposed to be..

Do you have anything left, I can help.
>>
>>25807067
I do, thanks,

this is my like button code.

Can I use a custom image instead of the standard button? And how do I display the amount of likes on the page?

I have two MySQL columns: IP and PageId.

Additionally, what is the "si" for?
>>
File: Screenshot_21.png (15KB, 758x222px) Image search: [Google]
Screenshot_21.png
15KB, 758x222px
>>25807067
Code:
>>
>>25805752
dont make the like button an img. keep it as a submit input & make it look like the image with css. and no that's stupid, use include for the random page link
>>
btw if you're still here i'll do it all for you but only if you tell me everything u need it to do because i domt feel like reading the whole thread :^)
>>
>>25807224
>>25807211

The "si" is a paremeter for the exec command, it tells what data type is expected (" s for string and i for integer") http://php.net/manual/en/mysqli-stmt.bind-param.php

Here I added some stuff to the script, it's completely blind ( did not test) but it should work
http://pastebin.com/jQXZidq1
You can display the amount of likes and display a message if the user voted already. Although now that I think about it, it might be missing some checks and allow people to vote twice (because of the POST code being at the end)
>>
use ezsql OP
>>
>>25801595
>php
>not using nodejs+express
>not using ruby on rails
>not even using css

why
>>
>>25807817
><input type="hidden" name="IP" value="<?php $_SERVER["REMOTE_ADDR"]; ?>">

why is there no echo?
>>
>>25807897
Missed that, thanks
Here's a revision as well
http://pastebin.com/mAxKaGgP
>>
>>25807793
I'm still here, thanks:
>>25807224
>>25807211
>>
>>25807817
I'll check it out, thank you
>>
use css to make the button an image
>>
>>25807766
>>25808095
Can you tell me how I can do that?
>>
>>25808144
add a class to the input button

do you have a live version of the site we can look at?
>>
>>25808177
Hopefully before monday
>>
change the submit button to

><input type="submit" class="likebtn" value="" />

add to css:
>.likebtn {
>background-image:url('img/heart.png');
>border-width:0;
>border-radius:0;
>padding:0;
>width:???px;
>height:???px;
>}
>>
>>25808144
Not that guy but here's a quick rule

input.likeBtn {
background: url("button.png") no-repeat scroll center center transparent;
border: none;
width:50px;
height:50px;
}
add this to your css file or inside a <style> tag in the head of your html

rename "button.png" to whatever your image filename is, also the image needs to be at the root of the folder ( same folder as your main php file ) otherwise change the path

change the width/height to your image dimensions also
>>
>>25808217
>>25808219
My niggles
>>
>>25808238
i'm done spoonfeeding for tonight, good luck man
>>
>>25808301
Thanks, didn't expect this much help to be honest
Thread posts: 80
Thread images: 6


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.