{"id":5340,"date":"2010-01-20T10:01:40","date_gmt":"2010-01-20T17:01:40","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=5340"},"modified":"2010-01-20T10:01:40","modified_gmt":"2010-01-20T17:01:40","slug":"append-login-credentials-to-url","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/snippets\/php\/append-login-credentials-to-url\/","title":{"rendered":"Append Login Credentials to URL"},"content":{"rendered":"

The example here is if you had a form on a website that when submitted, needed to use that information to go to a special URL where the login information was all appeneded to the URL. You could have the form post with method GET, but that is limited to the typical ?variable=foo&variable2=bar format.<\/p>\n

HTML Form<\/h4>\n

Typical form with three bits of information that submits to a file called ftp.php<\/p>\n

<form action=\"..\/processing\/ftp.php\" method=\"post\">\r\n<p><label for=\"ftp-company-name\">Company<\/label><input type=\"text\" name=\"ftp-company-name\" id=\"ftp-company-name\" \/><\/p>\r\n<p><label for=\"ftp-user-name\">User Name<\/label><input type=\"text\" name=\"ftp-user-name\" id=\"ftp-user-name\" \/><\/p>\r\n<p><label for=\"ftp-password\">Password<\/label><input type=\"password\" name=\"ftp-password\" id=\"ftp-password\" \/><\/p>\r\n<p><input type=\"submit\" id=\"ftp-submit\" class=\"button\" value=\"submit\" \/><\/p>\r\n<\/form><\/code><\/pre>\n

PHP file<\/h4>\n

This file reads in the POST variables (if they are set), builds the URL from them, and redirects to it. You’d probably want to clean up the POST variables for security purposes.<\/p>\n

<?php\r\n\r\n    if (isset($_POST[\"ftp-company-name\"])) {\r\n    \r\n        $company = $_POST[\"ftp-company-name\"];\r\n        $username = $_POST[\"ftp-user-name\"];\r\n        $password = $_POST[\"ftp-password\"];\r\n        \r\n        $url = \"ftp:\/\/$username:$password@ftp2.edgeconsult.com\/$company\";\r\n        \r\n        header( \"Location: $url\" ) ;\r\n        \r\n    } else {\r\n    \r\n        \/\/ do nothing\r\n        \r\n    }\r\n\r\n?><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"

The example here is if you had a form on a website that when submitted, needed to use that information to go to a special URL where the login information was all appeneded to the URL. You could have the form post with method GET, but that is limited to the typical ?variable=foo&variable2=bar format. HTML […]<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":3233,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"page-snippet.php","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":""},"tags":[],"acf":[],"jetpack-related-posts":[{"id":18734,"url":"https:\/\/css-tricks.com\/lodge\/v10\/152-styling-the-wordpress-lodge-login-page\/","url_meta":{"origin":5340,"position":0},"title":"#152: Styling the WordPress (Lodge) Login Page","date":"October 2, 2012","format":false,"excerpt":"Our \"widget\" for The Lodge in the sidebar of the site (shows on most pages, including homepage) has two states. One for when a user is logged out and one when a user is logged in. The logged out state has a login form right on it so current members\u2026","rel":"","context":"With 2 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":18702,"url":"https:\/\/css-tricks.com\/lodge\/v10\/136-understanding-vanilla-forums-theme-overrides\/","url_meta":{"origin":5340,"position":1},"title":"#136: Understanding Vanilla Forums Theme Overrides","date":"October 2, 2012","format":false,"excerpt":"We left off trying to decide if we can win the battle for a static login form or not. We probably could, but in more playing around with the forums, we see that it's not just login that by default comes up in a modal. The modal design pattern is\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":18728,"url":"https:\/\/css-tricks.com\/lodge\/v10\/149-building-a-login-form-for-the-lodge\/","url_meta":{"origin":5340,"position":2},"title":"#149: Building a Login Form for The Lodge","date":"October 2, 2012","format":false,"excerpt":"One of the reasons WordPress is awesome is that it comes with its own fully functioning user authentication system. Writing that from scratch these days would be pretty dumb if you don't plan to bring a heaping pile of innovation to the process. Restrict Content Pro, our membership plugin, of\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":18700,"url":"https:\/\/css-tricks.com\/lodge\/v10\/135-forums-wrangling-part-3-login\/","url_meta":{"origin":5340,"position":3},"title":"#135: Forums Wrangling, Part 3, Login","date":"October 2, 2012","format":false,"excerpt":"We keep digging into theming the Forums area of the site. We've done good so far, but the deeper we dig the more difficult things are going to get. Partially just because I don't have a ton of experience with Vanilla Forums and partially because it's just kinda weird! We're\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8254,"url":"https:\/\/css-tricks.com\/snippets\/wordpress\/customize-login-page\/","url_meta":{"origin":5340,"position":4},"title":"Customize Login Page","date":"January 6, 2011","format":false,"excerpt":"You know, the one typically at yoursite.com\/wp-login.php. These are things you would put in the active theme's functions.php file. Change the Logo Is the WordPress logo by default, this changes the file path of that image. Change file path and file name to your own needs. function custom_login_logo() { echo\u2026","rel":"","context":"With 25 comments","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4278,"url":"https:\/\/css-tricks.com\/snippets\/php\/login-function\/","url_meta":{"origin":5340,"position":5},"title":"Login Function","date":"September 29, 2009","format":false,"excerpt":"These functions will log in a user based on a username and password being matched in a MySQL database. \/\/ function to escape data and strip tags function safestrip($string){ $string = strip_tags($string); $string = mysql_real_escape_string($string); return $string; } \/\/function to show any messages function messages() { $message = ''; if($_SESSION['success']\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/5340"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=5340"}],"version-history":[{"count":3,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/5340\/revisions"}],"predecessor-version":[{"id":5343,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/5340\/revisions\/5343"}],"up":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/3233"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=5340"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=5340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}