connect ( ); if ( isset ( $_POST [ 'url' ] ) ) { $url = $_POST [ 'url' ]; $database->prepare ( "INSERT INTO `links` ( `ID`, `URL`, `created_by` ) VALUES ( NULL, ?, " . $_SESSION [ 'user_id' ] . " );" ); $parameters = [ [ "s" ], [ &$url ], ]; $database->bind ( $parameters ); $database->execute ( ); $database->prepare ( "SELECT MAX( links.ID ) as `last` FROM links;"); $database->execute ( ); $result = $database->get_result ( ); $row = $result->fetch_assoc ( ); header ( 'Content-Type: application/json' ); $response = [ 'status' => 200, 'message' => 'URL inserted correctly.', 'last_insert' => $row [ 'last' ], ]; echo ( json_encode ( $response ) ); exit; } else { $database->prepare ( "SELECT links.ID, links.URL FROM links WHERE links.created_by = " . $_SESSION [ 'user_id' ] ); $database->execute ( ); $result = $database->get_result ( ); $row = $result->fetch_assoc ( ); ?> BJPHoster URL Shortener | Control Panel
" ); } else { do { echo ( "\t\t\t" . '
' . $row [ 'ID' ] . " | " . $row [ 'URL' ] . "
\n" ); } while ( $row = $result->fetch_assoc ( ) ); } ?>