Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include_once("includes/check_login_status.php");
- include_once("includes/link_checker.php");
- // AJAX CALLS THIS LOGIN CODE TO EXECUTE
- if (isset($_POST) && !empty($_POST)) {
- check_links();
- } else {
- ?>
- <html>
- <head>
- <title>testing</title>
- <script type="text/javascript" src="js/main.js"></script>
- <script src="js/ajax.js"></script>
- <script>
- function emptyElement(x){
- _(x).innerHTML = "";
- }
- function cleanURL(){
- var params = []; //creates an array to store the form data
- var facebook_url = _("facebook_link").value;
- var twitter_url = _("twitter_link").value;
- var google_url = _("google_link").value;
- google_url = google_url.replace(/\+/g, ":plus:");
- var instagram_url = _("instagram_link").value;
- var youtube_url = _("youtube_link").value;
- var personal_url = _("personal_link").value;
- var saved = "true";
- if(facebook_url == "" && twitter_url == "" && google_url == "" &&
- instagram_url == "" && youtube_url == "" && personal_url == "" ){
- _("status").innerHTML = "Please provide at least one link before clicking submit";
- } else {_("submitbtn").style.display = "none";
- _("status").innerHTML = 'please wait ...';
- var ajax = ajaxObj("POST", "test2.php");
- if (facebook_url !== "") {
- params.push("fb=" + facebook_url); //creates key value pair and adds to array
- }
- if (twitter_url !== "") {
- params.push("tw=" + twitter_url); //creates key value pair and adds to array
- }
- if (google_url !== "") {
- params.push("go=" + google_url); //creates key value pair and adds to array
- }
- if (instagram_url !== "") {
- params.push("in=" + instagram_url); //creates key value pair and adds to array
- }
- if (youtube_url !== "") {
- params.push("yt=" + youtube_url); //creates key value pair and adds to array
- }
- if (personal_url !== "") {
- params.push("pe=" + personal_url); //creates key value pair and adds to array
- }
- ajax.onreadystatechange = function() {
- if(ajaxReturn(ajax) == true) {
- if (ajax.responseText == "") {
- _("status").innerHTML = "Sorry";
- } else {
- result = ajax.responseText.split("|");
- var arrayLength = result.length;
- // loop through all if statments for each element within the result[] array
- for (var i = 0; i < arrayLength; i++) {
- // Check for facebook response strings
- if (result[i] == "fb1") {
- _("fb").innerHTML = "fb1 message";
- }
- if (result[i] == "fb2") {
- _("fb").innerHTML = "fb2 message";
- }
- if (result[i] == "fb3") {
- _("fb").innerHTML = "fb3 message";
- }
- if (result[i] == "fb4") {
- _("fb").innerHTML = "fb4 message";
- }
- // Check for twitter response strings
- if (result[i] == "tw1") {
- _("tw").innerHTML = "tw1 message";
- }
- if (result[i] == "tw2") {
- _("tw").innerHTML = "tw2 message";
- }
- if (result[i] == "tw3") {
- _("tw").innerHTML = "tw3 message";
- }
- if (result[i] == "tw4") {
- _("tw").innerHTML = "tw4 message";
- }
- // Check for google+ response strings
- if (result[i] == "go1") {
- _("go").innerHTML = "go1 message";
- }
- if (result[i] == "go2") {
- _("go").innerHTML = "go2 message";
- }
- if (result[i] == "go3") {
- _("go").innerHTML = "go3 message";
- }
- if (result[i] == "go4") {
- _("go").innerHTML = "go4 message";
- }
- // Check for instagram response strings
- if (result[i] == "in1") {
- _("in").innerHTML = "in1 message";
- }
- if (result[i] == "in2") {
- _("in").innerHTML = "in2 message";
- }
- if (result[i] == "in3") {
- _("in").innerHTML = "in3 message";
- }
- if (result[i] == "in4") {
- _("in").innerHTML = "in4 message";
- }
- // Check for youtube response strings
- if (result[i] == "yt1") {
- _("yt").innerHTML = "yt1 message";
- }
- if (result[i] == "yt2") {
- _("yt").innerHTML = "yt2 message";
- }
- if (result[i] == "yt3") {
- _("yt").innerHTML = "yt3 message";
- }
- if (result[i] == "yt4") {
- _("yt").innerHTML = "yt4 message";
- }
- // Check for personal response strings
- if (result[i] == "pe1") {
- _("pe").innerHTML = "pe1 message";
- }
- if (result[i] == "pe2") {
- _("pe").innerHTML = "pe2 message";
- }
- if (result[i] == "pe3") {
- _("pe").innerHTML = "pe3 message";
- }
- if (result[i] == "pe4") {
- _("pe").innerHTML = "pe4 message";
- }
- }
- }
- }
- }
- ajax.send(params.join("&")); // sends the array of key value pairs to php and joins enteries with &
- }
- }
- </script>
- </head>
- <body>
- <p id="status"></p>
- <form id="linkform" onSubmit="return false;">
- <p>Facebook: <input type="text" id="facebook_link"><p id="fb"></p></p>
- <p>Twitter: <input type="text" id="twitter_link"><p id="tw"></p></p>
- <p>Google+: <input type="text" id="google_link"><p id="go"></p></p>
- <p>Instagram: <input type="text" id="instagram_link"><p id="in"></p></p>
- <p>YouTube: <input type="text" id="youtube_link"><p id="yt"></p></p>
- <p>Personal: <input type="text" id="personal_link"><p id="pe"></p></p>
- <br/><button id="submitbtn" onClick="cleanURL()">Save</button>
- </form>
- <?php } ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement