Jump to content

ki

Members
  • Posts

    208
  • Joined

  • Last visited

Posts posted by ki

  1. How do you know it's not sending anything? Your local_settings.php script doesn't return anything back to the ajax, so data does not contain anything in your success() method. It just sets Session vars on the server.

    I don't need anything returned, just sent to the server.

    Cronix is right.  You should use firebug to determine if the ajax call is happening.  In your code snippet, I don't see you doing a session_start() at the top either.

    There is a session_start(), I didn't include it in the code I posted. 

  2. Mind you, I've altered and butchered my code several times trying to find why it's not sending anything even though it says it does.

     

    geo.html

    navigator.geolocation.getCurrentPosition(GetLocation);
    function GetLocation(location) {
    var usr_lat = location.coords.latitude;
    var usr_long = location.coords.longitude;
    $.ajax({
    url: 'local_settings.php',
    type: 'POST',
    data: { user_lat : usr_lat, user_long : usr_long },
    success: function(data)
                        {
                           alert("success! user_lat:" + data);
                        }
    });
    }

    local_settings.php

    if (isset($_POST['user_lat']) && isset($_POST['user_long'])) {
    $_SESSION['user_lat'] = $_POST['user_lat'];
    $_SESSION['user_long'] = $_POST['user_long'];
    }

     

  3. I'm trying to pull results from a database based on where the user is located based upon the variables $usr_lat & $usr_lng, and search for by a radius of x amount of miles/km (need to make it optional). I can't seem to find exactly what I'm looking for on google so I thought I'd asked here. Any help would be appreciated.

  4. I fixed it. I ended up putting the code in the body, like this:

     

    <body<?php if($_SESSION['upload'] == 1) { print(" onload=\"javascript: upload();\""); $_SESSION['upload'] = 0; } else { } ?>>
    

     

    thanks for all the help guys

  5. So when I view source on the targeted upload.php page form the browser, the header redirects it to the index.php where it's displaying the <script> code which is calling the upload script I require but when I load the page it doesn't call. So my script is working, there is a javascript problem I guess? I don't know what the hell to do.

  6. In this code:

     

    <?php
    include("index_cross_session.inc.php");
    if (!$_POST['image-upload-post']) {
    $_SESSION['upload'] = 1;
    header("Location: index.php");
    die;
    }
    ?>

     

    You attempt to write session data, but you closed the session data for writing with the "session_write_close" in your include file. That is something you should look into :)

    nope, that didn't work. the code shows up only if I print() twice, the session I don't think is the problem.

  7. Okay here I'll show you most of the code there is:

     

    upload.php

    <?php
    include("index_cross_session.inc.php");
    if (!$_POST['image-upload-post']) {
    $_SESSION['upload'] = 1;
    header("Location: index.php");
    die;
    }
    ?>
    

     

    index_cross_session.php

    <?php
    session_start();
     if (!$_SESSION['id']) { $_SESSION['id'] = hash(crc32,uniqid()); session_write_close(); }
    ?>
    

     

    index_header.php

    <?php
    include("index_cross_session.inc.php");
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <link media="screen" rel="stylesheet" href="tragical.css" />
    <link media="screen" rel="stylesheet" href="colorbox.css" />
    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    <script src="jquery.colorbox-min.js" type="text/javascript"></script>
    <script src="tragical.js" type="text/javascript"></script>
    <?php
    if($_SESSION['upload'] == 1) {
     //print("<div style=\"display:none;\">LOL</div>");
     print("<script type=\"text/javascript\">upload();</script>\n");
     $_SESSION['upload'] = 0;
    } else { }
    ?>
    

  8. You need a die after your header regardless, and remove your ?> tag, if there's whitespace after it it could screw up other header code.

     

    You've verified that this specific post value exists in all browsers?

    I did the die and yes I have verified the post.

     

    You say it isn't working, but what does that mean - exactly? Is the page getting directed and you just aren't getting the popup (which would seem to indicate a JS problem) or is it not getting redirected at all?

     

    You also say that the code you provided for the first page is the entirety of the code for that page. Where's the session_start() statement? Also, wouldn't you want to unset that session value after echoing the javascript code?

    I mean the page isn't calling the Javascript function. I've stumbled upon something while checking to see if it was maybe the session and it appears it isn't. I added another print function displaying some random string of text and it works. And I just changed the code around to where there's a inclusion of a php file which holds the session info.

     

    <?php
    if($_SESSION['upload'] == 1) {
     print("<div style=\"display:none;\">test</div>");
     print("<script type=\"text/javascript\">upload();</script>");
     $_SESSION['upload'] = 0;
    } else { }
    ?>
    

     

    That's the code that works. I don't know why it works with a print that's actually displaying text and not the other. I would just say this is working but I'm pretty anal about that.

  9. A) You need an exit; statement after your header() redirect to prevent the remainder of the logic on your page from running while the browser performs the redirect.

     

    B) Are you sure $_POST['image-upload-post'] exists? If you are using an image for a submit button or your form is invalid html, it might not exist in some browsers.

    I have nothing else after the header at this point, it's honestly just the code shown that's in that file. As for the POST, it is valid and it is working. I want anyone who hasn't tried posting anything that goes to that direct URL to go to the main page and display the Popup!

  10. I have a problem with one of my codes. It works in google chrome but not in safari which I don't understand since it's mostly a server side script.

     

    What I'm doing is creating a session and on the page where it's redirecting it's suppose to create a script to call a javascript function which works in Chrome. I don't understand what the problem is at all since I see it work in Chrome but not Safari.

     

    This is the redirect script:

    <?php
    if (!$_POST['image-upload-post']) {
    $_SESSION['upload'] = 1;
    header("Location: index.php");
    }
    ?>
    

     

    This is the script on the page it's going to:

    if($_SESSION['upload']==1) {
     print("<script type=\"text/javascript\">upload();</script>");
     $_SESSION['upload'] = 0;
    } else { }
    

  11. I have a code code right now which works but I want it to form to the height of the text, with mine I cant edit it unless I make specific values which some content will be dynamic and cant be determined. here's my code:

     

       <div id="div-overlay" onclick="javascript: closePopup();"></div>
       <div id="div-popup"></div>
    

     

    div#div-overlay {
    position: absolute;
    top: 0;
    left:0;
    width: 100%;
    height: 100%;
    background: #000;
    display: none;
    opacity: .5;
    filter: alpha(opacity=40);
    -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
    }
    div#div-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    margin-left: -200px;
    margin-top: -200px;
    width: 400px;
    height: 400px;
    display: none;
    background: #FFFFFF;
    padding: 20px;
    -moz-border-radius: 7px;
    -webkit-border-radius: 7px;
    }
    

     

    wat do?

  12. Hashing does not guarantee uniqueness, and is not designed to provide unique results. I think I would avoid that.

     

    Are you looking for anything in particular, as far as characters go?

     

    The uniqid() function will provide a unique value, mostly. It is based on the underlying server's timestamp (in milliseconds). Here are a few from my system generated in a loop, one right after the other.

    5064d63e03753
    5064d63e03789
    5064d63e037bf
    5064d63e037f6
    5064d63e0382c
    5064d63e03863
    5064d63e03899
    

     

    I kind of like this but I want it kind of like

     

    4qR31~
    

     

    Something like that, just an example though. I think I would have to use a session though.

     

    I think he wants the token to stay consistent over multiple requests.

     

    I don't think using the session ID is a good idea, even if obfuscated or hashed.

     

    Your best bet is to generate a string based on random data, then store this in a cookie with a FALSE expiration, so it expires with the user.

     

    We'd need more details to give you a better solution

    How would I go about doing this one? Someone could potentially edit that cookie and edit their ID appearing as someone else though.

  13. I'm not asking for any code really. I need a way to create a unique UserID per $_SESSION or by md5 hashing their IP address and only using the first 6 or 7 characters. Does anyone have any ideas into this? I'm not requiring a login for my specific project, but do want individuals posting to recognize each other within some time period or sense.

  14. Like 6 years ago I had made a forum software for me and my buddies to post on. It had worked all great until my friend had posted a character that skewed my whole database, unintentionly, he knew nothing about computers. But I really haven't dabbed in PHP since 2008, I'm just now getting back into it again.

     

    I need to know how I can make data from an input to be put into an MySQL database and not screw up my code. So something along the lines that make the code safe and not exploitable.

     

    Also any third party scripts on captcha would be great!

  15. I've been looking for one all over the internet and have yet to find one to my exact specifications. I don't even know how I would attempt to make said script since I don't have a database of my own with that type of information stored on it. I basically want to use History.com's This Day In History feed on my website, but I don't like their RSS feed considering it's a giant paragraph of a single article. I'm just looking to post a few random dates and some information like this for example:

     

    1986 > blah blah blah

    1990 > blah blah blah

    2010 > blah blah blah

     

    Any help would be greatly appreciated brethren.

  16. What would you guys suggest as a pretty good font to use on a website? What do you guys normally use for your web projects? I'm looking for a new look, trying to dip my fingers into each bit of style there is sort to speak.

  17. Im trying to float a div over a div, ive tried different methods trying this yet non seem to work here is the code im trying to make the div float over:

    <style>
    div#subjects { margin-bottom: 5px; display: block; }
    div#msgbody { float: left; display: block; width: 100%; }
    div.CB { float: left; width: 50px; }
    div.FR { float: left; width: 100px; }
    div.SB { float: left; }
    div.MR { float: left; display: block; width: 100%; font-size: 14px; }
    </style>
    <div class="MH">Message(s)</div>
    <div id="subjects">
    <div class="MR"><div class="CB"><input type="checkbox" name="mail[]"></div><div class="FR"><a href="">name</a></div><div class="SB"><a href="javascript:message('')">subject</a></div></div>
    </div>

     

    and this is the div I want floated:

     

    <div id="msgbody">
    </div>

    its not going to be moved but its going to popup in the center of a holder div (non of the above divs) that displays a message with AJAX.

     

    any help is appreciated

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.