TEST - PHP Online
Form of PHP Sandbox
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of TEST.php
- <?php
- if(isset($_GET['action']) && $_GET['action'] == 'is_setup_done')
- is_Setup_Done_();
- function is_Setup_Done_() {
- require "db_connection.php";
- if($con) {
- $query = "SELECT * FROM admin_credentials";
- $result = mysqli_query($con, $query);
- $row = mysqli_fetch_array($result);
- echo ($row) ? "true" : "false";
- }
- }
- if(isset($_GET['action']) && $_GET['action'] == 'is_admin')
- _is_Admin_();
- function _is_Admin_() {
- require "db_connection.php";
- if($con) {
- $username = $_GET["uname"];
- $password = $_GET["pswd"];
- $query = "SELECT * FROM admin_credentials WHERE USERNAME = '$username' AND PASSWORD = '$password'";
- $result = mysqli_query($con, $query);
- $row = mysqli_fetch_array($result);
- if($row) {
- $query = "UPDATE admin_credentials SET IS_LOGGED_IN = 'true'";
- $result = mysqli_query($con, $query);
- echo "true";
- }
- else
- echo "false";
- }
- }
- if(isset($_GET['action']) && $_GET['action'] == 'store_admin_info')
- _store_Admin_Data_();
- function _store_Admin_Data_() {
- require "db_connection.php";
- if($con) {
- $pharmacy_name = $_GET["pharmacy_name"];
- $address = $_GET["address"];
- $email = $_GET["email"];
- $contact_number = $_GET["contact_number"];
- $username = $_GET["username"];
- $password = $_GET["password"];
- $query = "INSERT INTO admin_credentials (PHARMACY_NAME, ADDRESS, EMAIL, CONTACT_NUMBER, USERNAME, PASSWORD, IS_LOGGED_IN) VALUES('$pharmacy_name', '$address', '$email', '$contact_number', '$username', '$password', 'false')";
- $result = mysqli_query($con, $query);
- echo ($result) ? "true" : "false";
- }
- }
- if(isset($_GET['action']) && $_GET['action'] == 'verify_email_number')
- _verify_Email_Number_();
- function _verify_Email_Number_() {
- require "db_connection.php";
- if($con) {
- $email = $_GET["email"];
- $contact_number = $_GET["contact_number"];
- $query = "SELECT * FROM admin_credentials WHERE EMAIL = '$email' AND CONTACT_NUMBER = '$contact_number'";
- $result = mysqli_query($con, $query);
- $row = mysqli_fetch_array($result);
- echo ($row) ? "true" : "false";
- }
- }
- if(isset($_GET['action']) && $_GET['action'] == 'update_username_password')
- _update_Username_Password_();
- function _update_Username_Password_() {
- require "db_connection.php";
- if($con) {
- $username = $_GET["username"];
- $password = $_GET["password"];
- $email = $_GET["email"];
- $contact_number = $_GET["contact_number"];
- $query = "UPDATE admin_credentials SET USERNAME = '$username', PASSWORD = '$password' WHERE EMAIL = '$email' AND CONTACT_NUMBER = '$contact_number'";
- $result = mysqli_query($con, $query);
- echo ($result) ? "true" : "false";
- }
- }
- if(isset($_GET['action']) && $_GET['action'] == 'validate_password')
- _validate_Password_();
- function _validate_Password_() {
- require "db_connection.php";
- if($con) {
- $password = $_GET["password"];
- $query = "SELECT * FROM admin_credentials WHERE PASSWORD = '$password'";
- $result = mysqli_query($con, $query);
- $row = mysqli_fetch_array($result);
- echo ($row) ? "true" : "false";
- }
- }
- if(isset($_GET['action']) && $_GET['action'] == 'update_admin_info')
- _update_Admin_Info();
- function _update_Admin_Info() {
- require "db_connection.php";
- if($con) {
- $pharmacy_name = $_GET["pharmacy_name"];
- $address = $_GET["address"];
- $email = $_GET["email"];
- $contact_number = $_GET["contact_number"];
- $username = $_GET["username"];
- $query = "UPDATE admin_credentials SET PHARMACY_NAME = '$pharmacy_name', ADDRESS = '$address', EMAIL = '$email', CONTACT_NUMBER = '$contact_number', USERNAME = '$username'";
- $result = mysqli_query($con, $query);
- echo ($result) ? "Details updated..." : "Oops! Somthing wrong happend...";
- }
- }
- if(isset($_GET['action']) && $_GET['action'] == 'change_password')
- _change_Password_();
- function _change_Password_() {
- require "db_connection.php";
- if($con) {
- $password = $_GET["password"];
- $query = "UPDATE admin_credentials SET PASSWORD = '$password'";
- $result = mysqli_query($con, $query);
- echo ($result) ? "Password changed..." : "Oops! Somthing wrong happend...";
- }
- }
- ?>