php - How can I make a simple api that can connect to mysql? -
i need on how make api php. trying make 1 web server communicate webserver through php.
i want update mysql code. using $_get
less secure. here code, can please take @ it?
<?php /* example: website-url-here.com/?command=insert-command-here&password=testing */ $command = $_get["command"]; $password = $_get["password"]; if ($password == "testing") { //was not idea, less secure. //echo eval($command); //more secure if ($command == "create-user") { //create user command here } else if ($command == "delete-user") { //delete user command here } else { die("command incorrect"); } } echo "success"; ?>
this question way open ended answer in stackoverflow answer. try reading little on rest, , lot on pdo, in context of sanitizing user input.
think happen if called api [url]?command=rm -rf .&password=testing
Comments
Post a Comment