ryantroop 177 Practically a Master Poster

So it seems that during my upgrade from Win7 to 8.1, my timezone got set to Pacific. This, of course, would probably destroy any time based encryption (or ssl / handshake / cookie seting) simply because it would be out of sync.

Further, when I changed it to my local time zone, it happily gave me a +x hrs thinking I was simply changing time zones.

The solution:

Change to proper time zone, resync with time.windows.com, clear cache and login again.

I appologize for the error on my end. It was an oversight due to... well... ignorance I guess.

Thanks for looking into it :)

Ryan

ryantroop 177 Practically a Master Poster

Same response.

Key Value
Content-Type    text/html; charset=UTF-8
Date    Sat, 14 Dec 2013 09:13:23 GMT
X-Powered-By    PHP/5.3.10
Response    HTTP/1.1 500 Internal Server Error
Connection  close
Server  Apache/2.2
Content-Length  984

Ill try a few different settings tomorrow (XSS/Cookie setting/etc) and see if it will make a difference.

Im curious to know what is causing the Server Error... if I knew what was the problem (even if it's just the field that Im sending, or whatever it is that's being rejected) I can start to figure out where it's going wrong :-/

ryantroop 177 Practically a Master Poster

What's weird about it, though, is that the "Like" button works just fine, and the JS api keeps track just fine... LinkedIn also bombs out just as hard as FB for me on oAuth. I can only assume it's some kind of XSS prevention that I just dont see :-/ Either that, or maybe I need to remove the app from FB and try again fresh?

ryantroop 177 Practically a Master Poster

the "placeholder" attribute (while not supported in all browsers) is a fancy way of giving a "hint" to the user as to what is supposed to go into the field. A place holder is usually something like "First Name" or "Phone Number" so when the user clicks the field, they know what they are supposed to type there. The value there ("First Name", etc..) is not the actual value of the field. If you want a default value passed in, you will need to set the value of the input, but then your placeholder would not be visibile unless the value is empty.

If you you want the GET to be passed to the form, instead of:
placeholder="<?echo ($_GET['message']);?>"
use
value="<?echo ($_GET['message']);?>"

Hope that helps!

Ryan

ms061210 commented: Yes. It helps. A lot :) Thank you so much :) +1
ryantroop 177 Practically a Master Poster

IE11 Via FB Login:

REQUEST HEADERS

Key Value
Request GET /members/authorize/facebook HTTP/1.1
Accept  text/html, application/xhtml+xml, */*
Referer http://www.daniweb.com/members/lost_password
Accept-Language en-US,en;q=0.5
User-Agent  Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; rv:11.0) like Gecko
UA-CPU  AMD64
Accept-Encoding gzip, deflate
Host    www.daniweb.com
DNT 1
Connection  Keep-Alive
Cookie  __utma=77199232.1274735774.1386749453.1386749453.1386817892.2; __utmz=77199232.1386749453.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __qca=P0-2017402461-1386749453013; __gads=ID=5432d9eabbd00e6b:T=1386742542:S=ALNI_MZV6wua-tP4PkLN1IXbt7A0KbXBQg; __utmb=77199232.9.8.1386817908800; __utmc=77199232; dani_session=UWdROlJiAztUd19zBmkAZ1JiAWhcJVMkAWQLeg4uD2cFNgNjAwgFOFFiBnVRbFQlUTMHawRjUT1WdABgD2NVYAIwUzdVZ1tqUzsOYgRmVTRRNlFmUjYDNVRtX2IGYQBvUmsBN1xiU2ABNwtqDjkPNgVuA24DMgU0UTIGdVFsVCVRMwdpBGFRPVZ0ADoPJFUOAmNTNVViWyhTag5zBCNVI1E9UXNSbgMwVD9fOgZxAGFSYwF8XDVTZAE4CycOag85BXcDPANlBWhRJAZsUSRUbFE4B2gEa1ElViMAIA8xVSMCXVMwVWFbP1NhDnQEclU6UXVROlJjAzJUNl8iBh4AOVIoATtca1M7AWALJg5oDyAFaQMtA38FBlFvBjlRM1Q5UX4HKwRxUUlWAgBzD2JVfwIxU2pVJlsNU2YObgRmVTVRPVEgUiwDN1Q4XzsGcwACUiABO1xjUzIBbwt9DnIPOQV3Az0DbAVxUXQGIVFtVGdROAd2BGFRLlZ2AD8PPVU6AmdTcVVBWz9TbA5rBD9VI1E9UXNSbgMwVD9fOgZxADpSMwEhXHNTCAFgC2oOKQ9nBS8DZAMjBShRJAZsUT5UbFE4B2sEaVExVm4AYg9kVWcCN1NhVT1bKVM1DjkEalUjUXNRc1IxA3NUU19kBjIAIlIzAXBcPFMkATsLOQ5nDywFewM2AyQFa1E3BmFRbVR0UW8HNAQwUXRWPgBpDztVPQJmU2tVaFs1U3sOaQQzVWRRJFE7UicDO1Q9XzMGaQB0Uj0BM1xyUyMBaQtWDjsPbwUwA2EDIgUjUWMGdVFsVCs%3D; bsau=13867497783979781352; geolocation=US; OX_plg=swf|sl|shk|pm; referer=http%3A%2F%2Fwww.daniweb.com%2F

RESPONSE HEADERS:
Key Value
Response    HTTP/1.1 302 Found
Date    Thu, 12 Dec 2013 01:11:38 GMT
Server  Apache/2.2
X-Powered-By    PHP/5.3.10
Set-Cookie  csrf_cookie=b2bf8578da2f3ca4d67c39c547db84f5; expires=Thu, 12-Dec-2013 03:11:39 GMT; path=/; domain=www.daniweb.com
Set-Cookie  dani_session=BjAFbgEyU2sDIAcrB2gLbFJiUDlcJQF2UDUBcA8vXTUAM1MzCANWa1FiAnEBPANyUDIHa1YxVjoEJgVlD2NXYgEzAGQPPVloXTVSPgVnUjMGYQUyAWVTZQM6BzoHYAtkUmtQZlxiATJQZgFgDzhdZABrUz4IOVZnUTICcQE8A3JQMgdpVjNWOgQmBT8PJFcMAWAAZg84WSpdZFIvBSJSJAZqBScBPVNgA2gHYgdwC2pSY1AtXDUBNlBpAS0Pa11rAHJTbAhuVjtRJAJoAXQDO1A5B2hWOVYiBHEFJQ8xVyEBXgBjDztZPV1vUigFc1I9BiIFbgEwU2IDYQd6Bx8LMlIoUGpcawFpUDEBLA9pXXIAbFN9CHRWVVFvAj0BYwNuUH8HK1YjVk4EUAV2D2JXfQEyADkPfFkPXWhSMgVnUjIGagV0AX9TZwNvB2MHcgsJUiBQalxjAWBQPgF3D3NdawByU20IZ1YiUXQCJQE9AzBQOQd2VjNWKQQkBToPPVc4AWQAIg8bWT1dYlI3BT5SJAZqBScBPVNgA2gHYgdwCzFSM1BwXHMBWlAxAWAPKF01ACpTNAgoVntRJAJoAW4DO1A5B2tWO1Y2BDwFZw9kV2UBNAAyD2dZK107UmUFa1IkBiQFJwFiUyMDBAc8BzMLKVIzUCFcPAF2UGoBMw9mXX4AflNmCCE%3D; expires=Sat, 12-Dec-2015 01:11:39 GMT; path=/; domain=www.daniweb.com
Set-Cookie  dani_session=VmBbMFFiBj5WdVF9BmlRNlZmB24OdwN0VzJUJQEhWTFWZVAwBwxSb1JhUyBQbQBxA2FUOAViUj4BIwFhCmYANQs5C28AMgg5Bm4OYlEzBGVWMVtsUTUGMFZvUWwGYVE%2BVm8HMQ4wAzBXYVQ1ATZZYFY9UD0HNlJjUjFTIFBtAHEDYVQ6BWBSPgEjATsKIQBbC2oLbQA3CHsGPw5zUXYEclY6W3lRbQY1Vj1RNAZxUTBWZwd6DmcDNFduVHgBZVlvViRQbwdhUj9SJ1M5UCUAOANqVDsFalImAXQBIQo0AHYLVAtoADQIbAY0DnRRJwRrVnJbMFFgBjdWNFEsBh5RaFYsBz0OOQNrVzZUeQFnWXZWOlB%2BB3tSUVJsU2xQMgBtAyxUeAVwUkoBVQFyCmcAKgs4CzIAcwheBjMOblEzBGRWOlsqUS8GMlY6UTUGc1FTViQHPQ4xA2JXOVQiAX1Zb1YkUG4HaFImUndTdFBsADMDalQlBWBSLQEhAT4KOABvC24LKQAUCGwGOQ5rUWoEclY6W3lRbQY1Vj1RNAZxUWtWNwcnDiEDWFc2VDUBJlkxVnxQNwcnUn9SJ1M5UD8AOANqVDgFaFIyATkBYwphADILPgs5AGgIegZgDjlRPwRyVnRbeVEyBnZWUVFqBjJRc1Y3B3YObgN0V21UZgFoWXpWKFBlBy4%3D; expires=Sat, 12-Dec-2015 01:11:39 GMT; path=/; domain=www.daniweb.com
Location    https://www.facebook.com/dialog/oauth/?display=page&client_id=135220243179040&redirect_uri=http%3A%2F%2Fwww.daniweb.com%2Fmembers%2Fauthorize%2Ffacebook&state=b2bf8578da2f3ca4d67c39c547db84f5&scope=email,user_birthday
Keep-Alive  timeout=10, max=400
Connection  Keep-Alive
Content-Type    text/html; charset=UTF-8
Content-Length  20




HEADER FB OAUTH REQUEST:

Key Value
Request GET /dialog/oauth/?display=page&client_id=135220243179040&redirect_uri=http%3A%2F%2Fwww.daniweb.com%2Fmembers%2Fauthorize%2Ffacebook&state=b2bf8578da2f3ca4d67c39c547db84f5&scope=email,user_birthday HTTP/1.1
Accept  text/html, application/xhtml+xml, */*
Referer http://www.daniweb.com/members/lost_password
Accept-Language en-US,en;q=0.5
User-Agent  Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; rv:11.0) like Gecko
UA-CPU  AMD64
Accept-Encoding gzip, deflate
Host    www.facebook.com
DNT 1
Connection  Keep-Alive
Cookie  datr=avqnUoS2fYcF2BUwKKDR3HCf; c_user=725937120; csm=2; fr=0UGtSwkBzfc9VIRgR.AWWnTkCarip5W3eLhIIna3ElGo0.BSp_qg.Ny.FKn.AWXG3R8b; lu=ggPj4xWfn0_C5EFK6XrFdpog; s=Aa5jC7kOnGM4UdHn.BSp_qg; xs=250%3AxEmX_rH7W7Gogw%3A2%3A1386740384%3A3281


FB OAUTH RESPONSE HEADERS:

Key Value
Response    HTTP/1.1 302
cache-control   private, no-cache, no-store, must-revalidate
content-length  0
content-type    text/html; charset=utf-8
date    Thu, 12 Dec 2013 01:11:39 GMT
expires Sat, 01 Jan 2000 00:00:00 GMT
location    http://www.daniweb.com/members/authorize/facebook?code=AQBPjzLAkRWAEmYVK12U7XxFUiH9rP8cd_oDw-2Y11ooK2nAlgjCU3grXygrkJXxkcI7evoMSQAf1zxOKysLfxJynaUtVirSiiB1lNVE8nz8Q2UfmddBkrGU3YtMVAT4xofGfkOIXj4g6_H0GrFItqzyOJk1PKNwQHnyYNMjRC2z-tWxFx42L0vwE2cDx5h8JdiFwvzYyLQcb0dZAIXsXuSYqx9KqQ-M9VwcMwSAIaJMg36Ld1lKVKKMEZ9wJ8Af5s0Y6kHW0rLIzPVOhVFZr35RpP_tAzmwZYtTPVu-UgSUI8a3ol6WJ-0P9Gh5jCWU1AY&state=b2bf8578da2f3ca4d67c39c547db84f5#_=_
pragma  no-cache
x-content-type-options  nosniff
x-frame-options DENY
x-xss-protection    0
x-fb-debug  lZnLGQ+5EwdhU8CTZZJVqXjtnY815szPID7brCoEYIs=

From there it's the lost PW page, and a series of 304s (cahced css/js etc...) and a few akamai aborts from FB.

DW Login (modified for usr/pw):

REQUEST HEADER:
Key Value
Request POST /members/login HTTP/1.1
Accept  text/html, application/xhtml+xml, */* …
ryantroop 177 Practically a Master Poster

While it may certainly seem "lazy" I spend a large portion of my time in javascript and I like the syntax for arrays.

I cant seem to figure out if I can "prototype" the array "object" and give it methods that simply returns the appropriate function:

i.e.

$aMyArr = array();
$aMyArr->push($iNum);

where

array->push = function ($Foo) { if isset($Foo) { this[] = $Foo; }; }; // I am quite aware this is not valid. Demo purposes

if this is possible, is this going to make a large overhead just for ease of use?

The only other thing I can think of doing is making a new class that has one protected var that is an array, and cloning all the methods... which is basically what Im doing, but I don't want to call it class "myArr"... and then I have to make a constructor that will iterate what is passed in... and stuff... :-/

ryantroop 177 Practically a Master Poster

So... had a bit of trouble logging in with IE11 (32 and 64 bit) on windows 8.1 pro. Even tried spoofing UAS and changing the compatability modes.

There were no script errors, and the "information" in the console for FB and g+ are no different than the ones I safely ignore at work.

While it's still in its infancy, I figured I would give you a heads up. Consistently got a 500 response regardless of login method (facebook, linkedin, or usrnm/pw)

I had to download chrome just to login and post :-/

Im guessing IE11s XSS checker or "safe browsing" settings is really going to be a headache in the near future...

Maybe Im just unlucky :-/

ryantroop 177 Practically a Master Poster

ahh my mistake I misread your question.

Yes, you can have both in the same file. PHP is quite good at this.

You simply need to check the $_POST vars coming at the top of the file, and process things as needed.

You can check
isset($_POST)

and that will let you know if something is coming in for an update, otherwise you can run the script normally.

so..

if (isset($_POST) && $_POST['search'] != '')
{
  //run update sql
}
else
{
  //show form? do whatever...
}

//you can even do the rest of the page here, and still show the page after the update :)
ryantroop 177 Practically a Master Poster

Line 20 says action='search.php' where your script Name for the processing page seems to be Update.php
Try changing it and see if that helps.

ryantroop 177 Practically a Master Poster

I don't know how to do it in JQuery, but the XMLHTTPObject has an abort method. Im sure you can look into jquery's version of that method.

Also, look into using the Date() object to get a random number instead of Math.random() as it's possible (however unlikely) that you get the same result twice.

ryantroop 177 Practically a Master Poster
function onLoad()
{
  makeDisable();
}

<body onload="onLoad();">
...
</body>

Should do the trick...

Ryan

ryantroop 177 Practically a Master Poster

the two mentioned here (for php) are quite well done.

http://stackoverflow.com/questions/6019139/php-socket-tutorials

ryantroop 177 Practically a Master Poster

ActiveX objects, as far as I know, requires some sort of Microsoft intervention or emulation... that is, you probably need to do more than just create an active X object in script.

I assume, then, that you are running this in IE and on Windows, or are familliar with this type of object (I am not).

However, a quick lookup to MSDN says:
http://msdn.microsoft.com/en-us/library/2z9ffy99

Looks like you are close. GetFile seems to require an absolute path. Try instead:

fileObj = fso.GetFile("C:\foo.txt"); //this assumes the file lives on the C:\ drive.

Hope that helps.

Alternatively, as I had suggested above (and others also tried to build upon), is you upload a file to your server using a traditional file input (<input type="file" name="upload" .... />), and let the server process the file for you, then spit out a return value that can be JSON encoded or any other encoding you like, and then store that in a javascript variable. This would be cross browser / cross platform, and allow you to do a bit more with the data coming in.

Ryan

ryantroop 177 Practically a Master Poster

The only way I can think of doing it is to submit a file (via ajax or iframe) and then the callback or whatever method you prefer sets the value of a variable.

Javascript is abstracted from the OS/File System for security reasons. The user needs to "give" you the file before you can do anything with it. However, you are setting a "cookie" or local storage variable, you may be able to do something there. However, I think it would be fairly limited due to size contraints and the fact that you need to set the file before you can edit it.

Perhaps if you explained what you were trying to do someone can give a good starting point for research or code example?

ryantroop 177 Practically a Master Poster

parseInt and parseFloat does not guarantee a number. If either of those return undefined and you do any arithmetic on it, you will get NaN.

You have here a product of bad code design.

declare your variables. check them for values after assigning them. Then do math.

ex:

var fVal;
var fPrice1, fPrice2, fPriceTotal;

fVal = document.getElementById("price1").value;
fPrice1 = fVal ? fVal : 0.00;
fVal = document.getElementById("price2");
fPrice2 = fVal ? fVal : 0.00;

//the math...

fPrice3 = fPrice1 + fPrice2; //intrinsic type check based on math operator.

If that is not your problem, I don't see anything else wrong and will have to reread it.

ryantroop 177 Practically a Master Poster

Im not very good with JQuery, but Im guessing it's this fine feller:

$(document).ready(function(){

    //This keeps track of the slideshow's current location
    var current_panel = 1;
    //Controlling the duration of animation by variable will simplify changes
    var animation_duration = 2500;

    $.timer(6000, function (timer) {
        //Determine the current location, and transition to next panel
        switch(current_panel){
            case 1:
                $("#slideshow").stop().animate({left: "-960px", top: "0px"}, {easing: 'easeOutBack', duration: animation_duration});
                current_panel = 2;
            break;
            case 2:
                $("#slideshow").stop().animate({left: "0px", top: "-350px"}, {easing: 'easeOutBack', duration: animation_duration});
                current_panel = 3;
            break;
            case 3:
                $("#slideshow").stop().animate({left: "-960px", top: "-350px"}, {easing: 'easeOutBack', duration: animation_duration});
                current_panel = 4;
            break;
            case 4:
                $("#slideshow").stop().animate({left: "0px", top: "0px"}, {easing: 'easeOutBack', duration: animation_duration});
                current_panel = 1;
            break;  
            timer.reset(12000);
        }
    });

});

this is found in the file: image-rotator.js

someone who knows jquery better may be able to help...

ryantroop 177 Practically a Master Poster

you can use javascript and check the inputElem.value.length > 0
you can use PHP to check isset($_POST['pw']); //validates false if empty

lastly, you can use ^$ to match an empty string...

I hope that helps...

Ryan

ryantroop 177 Practically a Master Poster

erm..

$_GET["id"];

sorry.

ryantroop 177 Practically a Master Poster

are you sure that id is a column in the myaduan table?

is it upper cased? ID?

is it rowID?

Also, I would encourage you to sanitize your data before inserting it into your database.

<?php include'e.php';
    if(!isset($_POST['submit'])) //this is confusing
    {
        $id = mysql_real_escape_string($_GET[id]); //since the data you seem to care about is a GET....
        $q="SELECT * FROM myaduan WHERE id=" . $id;
        $result=mysql_query($q);
        $myaduan=mysql_fetch_array($result);
    }
?>

also, you may want to consider migrating from this proceedural, and now outdated, method and instead look into mysqli which is very similar in syntax but has future support for PHP.

http://php.net/manual/en/book.mysqli.php

ryantroop 177 Practically a Master Poster

... erm... is this remote server a database? an api?

So many questions :-/

ryantroop 177 Practically a Master Poster

I hated ODBC on PHP with GoDaddy's windows servers, so much in fact that I abandoned it even after I got it working.

This worked for me, I am assuming it will be a starting point for you. If not, I appologize for wasting your time.

PHP5 has spotty support for ODBC, and even their documentation gives misleading code.

I really hope this works for you,

Ryan

please note, the query function will probably need some adjustments for all cases. If you pass in "null" as a param, it may fail hard. The prepare/exec combo should sanitize for you, but you will want to be sure before putting this into production.

function DBConnect()
{
  $usr = "usr";
  $pw = "pw";
  $dbURL = "url.com";
  $dbname = 'name';
  return odbc_connect("Driver={SQL SERVER};Server=$dbURL; Database=$dbname;", $usr, $pw);
}

function sql_query($rConn, $cStmt, $aValues)
{
  if (!rConn)
    return;

    $cArgs = "";
    $iParams = count($aValues);
    for ($iLup = 0; $iLup < $iParams; $iLup++)
        {
            if ($iLup > 0)
                {
                    $cArgs .= ",";
                }

            $cArgs .= "?";
        }

  if ($iParams == 0)
    {
      $cFullStmt = "EXEC $cStmt";
      $oResult = odbc_exec($rConn, $cFullStmt);
    }
  else
    {
      $cFullStmt = "EXEC $cStmt $cArgs";
      $oResult = odbc_prepare($rConn, $cFullStmt);
        $bExec = odbc_execute($oResult, $aValues);
    }

  if ($bExec && $iParams > 0)
    return $oResult;
    else if ($oResult && $iParams == 0)
        return $oResult;
    else
    {
          return $oResult;
    }
}


$rConn = DBConnect();
$cStmt = "select * from tbl_user";
$aValues = array();
$Results = sql_query($rConn, $cStmt, $aValues);

if (count($Results) > 0)
{
  //do stuff here...
  for ($i=0;$i<count($Results);$i++)
    { …
ryantroop 177 Practically a Master Poster

only thing I can think of is that cellak does not contain any elements, and since you are starting at 1 you are essentially doing:

null.getAttribute("id");

I don't know why you are doing it that way anyhow since id is a directly accessable property.

edit: alternately, since you initially did "i=1" instead of "var i=1" for the for loop, you may have caused a problem with a global variable and lost yourself in scope.

maybe try:

function check ()
{
    //note inclusion of "var" -- otherwise you are making globals.
    var kepek = document.getElementsByTagName("img");
    var cellak = document.getElementsByTagName("td");
    var db = 0;
    for (var i=1; i<cellak.length; i++)
        {
            if (cellak[i])
                {
                    if ((cellak[i].id) != (kepek[i-1].id))
                    {
                      db++;
                    }
                }
        }

        if (db == 0)
        {
            pontszam = pontszam + mp * 10 + 6 * 100 - klikk * 10;
            $("pont").innerHTML = pontszam;
        }

}

note the added "var" before your variables (and, I encourage you to do this to all variables when you instantiate them; global or not).

Also, note the check to see if the item exists first before acting upon it.

Good luck,

Ryan

ryantroop 177 Practically a Master Poster

interesting cereal...

I get that you are doing that because they would validate, but wouldnt this require that it compares each record by hashing (and reading, anyway) it in order to compare?

How would hashing the string be faster than simply checking if the string is the same, especially when you are dealing with potentially thousands or hundreds of thousands of records?

why not just sanitize the post and then

select * from table where title = 'POST' limit 1

and then, I agree, check for mysql_num_rows() > 0;

This way, I believe, you are allowing the database to work off indexes naturally, and if you create a clustered index on ID then you can just replace * with ID and that should work too...

ryantroop 177 Practically a Master Poster

It depends on your perspective...

Python is an incredible development tool if you are working with a team that is developing in Python.

The major PROs of Python are:
1) It's memory managed for you (for 99% of typical uses).
2) It can be used to quickly expand various portions of your project quickly, and since it is all written with a strict format all team members will be able to read what you are doing and how.
3) It can "easily" compile down to C++ using the right tools, but doing so will probably not reduce overhead since the python package is included in the binary/executable.

The drawbacks to this are:
1) You lose the understanding of "why." By this I mean, you are no longer using true pointers, and most of your data types are loosly written (meaning they can change on the fly. If you need a var to be an int it's an int, but in the next line it needs to be a string, then woot! You got a string! (this is different than CASTING in C++ or other string type languages.)

2) You are trusting the python run time VM to memory manage for you. There really isn't anything wrong with this, other than the overhead of a VM running.

3) You really aren't going to want to edit that C++ code that the python compiles to (as it is "optimized"), and I am not entirely sure you can edit …

ryantroop 177 Practically a Master Poster

I took the O'Rielly classes for Python and I loved them. The guy I worked with was amazing, easy going, and was very open to discussion. In fact, I learned quite a bit from him.

The down side is that it's a "pay to learn" service. The upside is that you get a real working environment to learn in (a sandbox) and you learn real world working concepts, as well as "good code design" and patterns.

If you are willing to shell out some cash,
http://www.oreillyschool.com/

Otherwise, http://www.tutorialspoint.com/python/index.htm is good, and picking up a book on Python is never a bad thing.

Also, while old and I think it requires you use python 2.3 to complete (due to library issues), http://www.pythonchallenge.com/ was very fun to go through for a while. It's like a puzzle for coders. It's old, so many (if not all) the solutions are available through a quick google search if you get stuck.

ryantroop 177 Practically a Master Poster

If I understand the question correctly, I believe you are trying to use PHP as an intermediary between two systems.

If that is the case, this may help:
http://forums.devshed.com/php-development-5/help-using-fopen-and-fwrite-with-a-url-53394.html

ryantroop 177 Practically a Master Poster

the other option is to simply submit the page to the URL you want to move to and use POST as the method instead of a GET.

If you plan on allowing bookmarking, then I can see the issue... otherwise:

<form method="POST" action="/search/whatever.html">
<input type="text" name="myVar" value="" />
<input type="submit" value="Submit" />
</form>

from there, your URL will change, and all your data will move along with the form submission.

Messing with the URL as both a GET and POST at the same time is generally bad mojo, if that's what you are planning on doing.

Changing the URL after a GET kinda defeats the purpose of the GET (sorta), unless you are getting rid of the key in the key=value... in which case a mod rewrite in .htaccess is your only good option.

Good luck!

Ryan

ryantroop 177 Practically a Master Poster

Your "question" is very confusing.

Are you looking for AJAX only website examples?

A specific problem you are trying to tackle with AJAX?

Please clarify.

Thanks,

Ryan

ryantroop 177 Practically a Master Poster

empty is a function to check the state of a variable.

you can use it as such:

<?php
 if (empty($_SESSION['MM_Username']))
   {
     echo ("<h4>please log in before adding to BASKET</h4>");
   }
</php>

see: http://php.net/manual/en/function.empty.php

however, most people use isset() instead of empty, as it checks for a variable being NULL as well.

<?php
  if (!isset($_SESSION['MM_Username']))
    {
      //do stuff
    }
</php>

see: http://www.php.net/manual/en/function.isset.php

notice the ! before the function? that means NOT, so the line reads "if variable $_SESSION['MM_Username'] is NOT set then do stuff".

good luck,

Ryan

ryantroop 177 Practically a Master Poster

Is this for a class? I would assume that you have guidelines for what is expected. If not, feel free to ask your teacher :/

ryantroop 177 Practically a Master Poster

so... soap box moment... using flash as your only method of displaying information is probably not a good idea. While it is now pretty much all over the place, I know for a fact windows phones will cause you problem, and Im pretty sure iOS may cause you some grief too.

However, flash is good as a suppliment for your site, and creating dynamic content or games.

If that is your plan, you need to get Adobe's Flash developer tools (aka, Flash Professional CC, or any of the prior CS versions...).

I am under the impression that creative cloud now has it bundled.
http://www.adobe.com/products/creativecloud/tools-and-services.html

Once you get into the developer studio, you have many toys and options to play with, and there is even some export tools that will make a page that showcases the flash applet on the page.

As suggested above, you can easily google "Flash tutorial" and you can make it more specific from there. You are bound to find many, and much more than you will ever want to know.

Good luck!

Ryan

ryantroop 177 Practically a Master Poster

You are doing nothing wrong.

As long as you understand what the redirect is doing (basically clearing your GET/POST stack), you're fine :)

He suggested doing a POST (instead of a GET, which uses the URL), as it allows for more flexibility, and the ability to do a bit more behind the scenes without cluttering up a URL.

Generally, you use the URL (or, GET) when you want to allow linking. So, a specific product can be:

https://www.mycoolsite.com/products?ProdID=121

however, lets say you keep up with this, and you decide to keep using GET (or the URL) for adding stuff...

https://www.mycoolsite.com/products?ProdID=121&AddOns=1,2,3,5,6,9,10,11&ReferalSite=foo123&SomeOtherParam=areallylongurlencodedstringwith%20forspacesorpossibly+forspaceandalotofotherweirdstuff

that URL is far from pretty and annoying to remember. Sure, you can learn about URL rewrites and all the good stuff that makes a site scalable with a data driven back end, but that comes with practice and learning about how the technologies work. You could also "hide" a lot of that and make a POST through a form, and use hidden fields as necessary, etc...

In short - there is more than one way of doing things. Some are just more "right" for the job than others.

To repeat - you are doing nothing wrong.

All of us have our own idea of good development. In this particular case, I would side with diafol and actually store a user's activty in a database to keep track. It's much safer if the data is potentially going to give you money, and when you are dealing …

ryantroop 177 Practically a Master Poster

This in javascript can be tricky depending on its location.

inline:
<input type="text" value="" onclick="someFunction(this);"> //=> refers to the input.


<script type="text/javascript">

//outside of a function or object:
var myVar = this; //refers to window.

//in a function
function myFunction()
{
  var myFunc = this; //refers to the function.
}
//note if your function is a "class" instantiation, "this" changes scope within each method of your class. 

function myClass()
{
  var _that = this; //refers to function

  var myMethod = function()
  {
    var myMethod = this; //refers to this particular function.
    _that; //refers to myClass.
  }

  return this;  //the function and all properties.
}

//in an object "singleton"
var myObj = {
  someVar: this, //refers to the object.
  someMethod: function () {
    var i = 0;
    this.someVar = i; //refers to object as well...
  }
}
</script>

hope that helps

Ryan

ryantroop 177 Practically a Master Poster

Either way. Pick your Tool. The code is the same otherwise.

ryantroop 177 Practically a Master Poster

That would likely be the HUGE margin from the media query.

Your CSS is a little broken. I would encourage you to revisit it, and rethink the use of media queries if you can.

Start simple and get the site working on a PC as you need, then worry about tweaking for mobile or whatever other medium you plan on having used.

ryantroop 177 Practically a Master Poster

well.. couple things...

without knowing how you make $opt_count, Im gonna make a wild assumption that you are going to be missing an item as arrays start at 0, and you are starting $i at 1 (so your first item will be missing. If that's expected then ignore this).

As for the JS, you have script attached to "onchange" for the text field. That means when someone types in a value then moves off that field the script will fire.

However, with what you have on the page, it does not seem that you are keeping track of the price per item anywhere "usable" and your naming convention seems odd.

Instead, consider this..

<?php
 for($i = 0; $i <= $opt_count; $i++){
        $desc = $options['description'][$i];  //these seem a little weird
        $prc = $options['price'][$i];         //without seeing your data
        $type = $options['type'][$i];         //it's hard to explain why
        $size[$i] = '&nbsp;';  //?? What is this for?
        $option_text = '<tr>';
        $option_text .= '<td>$desc</td>';
        $option_text .= '<td style="text-align:center">' . $size . '</td>"';
        $option_text .= '<td style="text-align:center"><input type="text" name="qty ' . $i . '" price="' . $prc . '" onchange="calculate(this)" size="2" /></td>';

        $option_text .= '<td style="text-align:right">' . $prc . '</td>';

        $option_text .= '<td class="right_align"><input type="text" style="text-align:right" name="total' . $i . '" id="total' . $i . '" size="2" readonly="readonly" /></td>';
         $option_text .= '</tr>';
TABLE;
        echo $option_text;
    } // for loop
    ?>

From here, since we now have a "price" attribute on the input element, we can access it via javascript and use it...

in the head …

ryantroop 177 Practically a Master Poster

Without a working model and an actual step by step view of what you are doing, this is hard to figure out what exactly is going on.

If you are saying that you fill out a form that posts to a new page, then after the post you hit the back button and the form is all filled out still, then.. woot! That's kinda what is expected. That's not so much a server cache as much as the browser knowing what values were there and putting them back.

If you do an ajax call to a new page and get a result, then hit a back button, you are not in any way dealing with the ajax call, you are dealing with the http request for the page you are on (or the page you previously came from).

Like I said.. it's difficult to understand your problem without seeing it... but that's my best explanation. It's normal behavior, not server caching...

As for your question about GET method (and POST, PUT, DELETE, etc...) not a whole lot of people actively enforce these methods (in fact, the only company that I deal with that actively enforces these at all is LinkedIn). A get is a request with a param stack just like a post, just the post has some perks over a get and vice versa.

I hope that helps..

Ryan

ryantroop 177 Practically a Master Poster

Fair. But what if other params on the stack are also being tested. You have now blown away the stack. It's not that his script is wrong, its that he didn't understand the method of gets and posts. I would discourage a redirect, as it would just lead to further confusion and frustration down the line (unless that is a desired behavior.)

ryantroop 177 Practically a Master Poster

Heh.. welcome to the world of "stored" values and URL management.

Since you are doing a GET (or a POST), the value gets stored in the URL. When you refresh the page, you are basically resending the URL with the parameters still in place.

So, your session variable (where you "store" the value) is simply doing what you are asking it to - the $_GET is set, so update the session variable by +1.

Tada!

The solution to your problem? Don't refresh. :-/

Or, you can play with URL rewrites, but then you are sort of defeating the use of "GET" as a way to keep a "trail" to a location...

There is nothing wrong with your code. Instead of refreshing, get rid of the the ?add=1 in the URL and hit enter.

Keep in mind, if you did this with a "POST" you would get a message telling you that you are "resending" data. It would not in any way solve your problem.

Hope that helps,

Ryan

ryantroop 177 Practically a Master Poster

It depends on which method you plan on using...

The basics of it:

Make a form that takes their name, billing address, (zip is most important), CC number, CID (optional), exp date.

That form posts to a page you control (you are free to store that data, but I encourage the heck out of you not to, as it's a crap ton of responsibility and if someone cracks your database, it's on you for all those credit card numbers).

That page's sole purpose is to send a cURL forward to paypal.

You need to also send your vendor ID, or whatever they call it.

In all fairness, I have only used their Classic API which is based off name value pairs, and they do a send back... it's far easier to follow than their current RESTful API.. you may want to start there...

https://developer.paypal.com/webapps/developer/docs/classic/

ryantroop 177 Practically a Master Poster

They have examples in them. You are basically using cURL to send user info to PayPal, then parsing the response.

ryantroop 177 Practically a Master Poster

So... what you seem to have just asked is "How do I make a premium membership for a service that emails me when my server goes down using php and paypal."

Im going to assume, then, that you are instead asking how to use paypal to accept payments using PHP.

They have documentation showing how to do it.

https://www.x.com/ <= paypal developer stuff. Docs and other goodness.

however, you may instead want to start at:

https://developer.paypal.com/ <= paypal sandbox/developer site.

ryantroop 177 Practically a Master Poster

By the sound of it... you seem to know the answer...

Yes. Use an HTML table.

Use CSS to style it.

If you really want to do something off the wall wonky, you can use DIVs and all the other HTML dohickeys and make it look all pretty....

Maybe ask something a little more specific so we can help a little more?

ryantroop 177 Practically a Master Poster

looks like line 14 has an extra comma...

erm.. of the output php (server 2 ajax.php).

...
'web' => 'http://jonemaxtest.com',
);

ryantroop 177 Practically a Master Poster

just because you output JSON from your PHP code it does not mean the variable will automagically evaluate to JSON Object notation. It is, as far as I know, still just a string. It needs to be parsed or evaled.

You can, before loading, run an AJAX script and eval or JSON.parse() into a variable the array of objects you are expecting, then let events: yourvar, ....

ryantroop 177 Practically a Master Poster
select 
  e.employee_id --get the ids
from 
  employees e --from employees table aliased as e
where
 ( --begin sub query...
   select 
     count(*) --get the total number of rows
   from 
     employees f --from employees table aliased as f
   where 
     f.employee_id < e.employee_id -- where.. I believe this will return n-1 results where n is the total rows.
 ) < 5; -- where the values of the subquery are less than 5

Essentially, you're asking for all rows, but only give you the first 5. This is, I believe, a terrible query.. if I understand it right, it's hitting the same table 5 or 6 times for something that is much simpler to do as a straight up query... the only reason I can see doing this at all is if you have a TON of users and over time something has messed with the index... but even then you could just do:

 select employee_id from employees limit 0, 5; (in MySQL)
 select top 5 employee_id from employees (in MSSQL)

And quite frankly... if something's wrong with your indexing or ordering, you have bigger issues...

without your data, and being lazy to not build a fake table and trying it, it's difficult to see exactly what it is returning. If you have direct access to the SQL Server, you can always try to see if you can check the execution plan and try to figure it out that way. Lastly, you can always run a sub query yourself …

ryantroop 177 Practically a Master Poster

You are very likely going to be ignored as this is a "do this for me" "question" as opposed to you trying it first and getting help when you get stuck. The purpose of the classes you are taking is to apply what you have learned...

These are pretty straight forward word problems... if you are doing these queries by hand, as a single run call, these should be very simple as they are pretty basic SQL mixed with SQL Math.

It looks like all of them will require some sort of join between a customer table and a sales rep table. Perhaps you could work on getting the data first, then do the math after...

if you are indeed doing triggers on your first week of SQL, then this page will help you as it has a nice example as the first comment, and you can base your work off of it.

http://dev.mysql.com/doc/refman/5.0/en/triggers.html

If you have specific questions I will be happy to answer them if I am able.

ryantroop 177 Practically a Master Poster

also, why do temp tables persist outside of the sproc? Especially when engine=memory?

ryantroop 177 Practically a Master Poster

Im working through sprocs with MySQL and I came across something that made me quite uncertain...
I learned sprocs with MSSQL and I am used to declaring as such:

create ... myProc (@var type, @var2 type(xxx))
as
....

and for declares, we declare vars as
declare @var3 type(xxx), @var 4 type() .....

With mysql I have resigned to the missing @ in the proc declaration, and variables are not called via @var...

However, in order to skirt the whole "cant pass a variable into a limit" issue, I basically made a prepared statement inside the proc, and execute it.

However, the declare requires @, where other vars do not require, and in fact seem to error out, when using @ in the declaration.

What am I missing here?

Thanks!

Ryan

ryantroop 177 Practically a Master Poster

Yeah.. sooo.. I feel silly.

Probably a better way..

$query = "whatever($var, $var)";
mysqli->real_escape_string($query);
$res = mysqli->query($query);

my bad... :-/