Jump to content

Don E

Members
  • Posts

    996
  • Joined

  • Last visited

Everything posted by Don E

  1. Are you working with two pages? If so, do you have session_start(); at the very top of your code for both pages?
  2. In the if condition inside the foreach, instead of !isset(), try !empty(). isset doesn't really determine if there is a value or not. All it really means that a variable has been initiated. So for example, if you have: <input type="text" name="username" />$_POST['username'] WILL be set even if it did not have a value entered (assigned) to it. (even if the user did not enter anything in the text box)Using empty() is more helpful in this situation because empty sees if there is anything that indicates a variable is empty, like an empty string '', or false, null, 0, etc.
  3. Is what's contained in $_SESSION['error'] suppose to be an array? First argument of foreach is suppose to be the array you want to loop through.
  4. I skimmed through the code and noticed this: $id=$_GET['id'];$sql="SELECT * FROM forum_question WHERE `id`='".$_GET['id']."'"; Try changing to: $sql="SELECT * FROM forum_question WHERE id=".$_GET['id']; // you can use $id here as well since $id is given the value of $_GET['id']. Also make sure $_GET['id'] contains a value.
  5. You would use them as you would as you would from a regular form POST. For example: 'payer_status' => 'verified', would be $_POST['payer_status'] and 'payment_status' => 'Completed', would be $_POST['payment_status']; So if you have a column in your database table that keeps track of each users status on payment, for example the column could be called 'payment_status' and it's fault value could be NULL or whatever you want to give to indicate they haven't paid yet. Then once they do pay and you get a 'VERIFIED' result like in the above script, you update that record for that user 'payment_status' to $_POST['payment_status'] which would be 'Completed'.
  6. Hello MarkT, Interesting you bring this up because the past a couple of weeks, I've been experimenting with exactly what you mentioned with PayPal with a project I'm currently working on. I'll try to summarize:To have a listener known as in paypal which is called: instant payment notification(ipn), you're going to have to upgrade(or get) to a business account. You'd go to 'Profile' -> My Selling Tools and then look for 'instant payment notification' and click on 'update' to set the info for that. You're going to have to insert a url that points to a script on your site where the info regarding the most recent payment will be sent to from paypal letting you know if it's 'VERIFIED' or 'INVALID'. Then from there, you'd update your database for that user indicating they have paid if the return status is 'VERIFIED'. Update: If 'VERIFIED' is returned, it only means that the transaction was a 'VERIFIED' transaction. In other words, it means a valid transaction took place BUT does NOT MEAN the payment_status is good. You must check the payment_status in $_POST['payment_user'] to determine if the payment was successful or not. The reason you need a business account to do this is because either they changed it or something else happened, but I noticed in the 'Personal' account, they don't have the 'instant payment notification' option anymore. I believe along time ago they did. Upgrading to business account is free, but the only thing is, per transaction, they will take like 30 cents from it I believe. The good news is, paypal has a 'sandbox' site where you can use to test everything out before you go 'live'. You will need to go to the developer site(developer.paypal.com; can login in using your current actual paypal account) to create the sandbox accounts. There you can create 'seller' or/and 'buyer' accounts. You'd then go to the sandbox site: https://www.sandbox.paypal.com per which ever sandbox account you created to set up the account as you would do on a real account. So for example, you'd log into the seller account and create the button for the item you want to sell. Then you'd go and setup the instant payment notification settings as mentioned above for that pretend seller account. You would then paste the 'Buy Now' button code paypal supplies to you upon creating your button onto your site. To test the button, you'd go to your site (by the way, this can't be done on a local site, has to be live. Best to create a 'test' subdomain perhaps for all this to test everything etc) and click on the button to buynow, paypal will then redirect to their site to complete transaction. As that happens, you will enter the email and password you created for the 'buyer' account you created at the sandbox site. Once you log in, review what you're about to purchase, click 'pay'. As this happens, paypal will send information regarding this transaction to the 'instant payment notification' url you provided for the seller account. You will check to see if the payment is 'VERIFIED', if so, all is well, update database indicating user has paid, etc. (See above 'Update') Below is my 'testing' ipn script I currently have going. It uses cURL(recommended) to communicate with paypal for the transaction: <?phpclass Paypal_IPN{ private $_url; public function __construct($mode = 'live') { if ($mode == 'live') { $this->_url = 'https://www.paypal.com/cgi-bin/webscr'; } else { $this->_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; } } public function run() { $postFields = 'cmd=_notify-validate'; foreach($_POST as $key => $value) { $postFields .= "&$key=".urlencode($value); } $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => $this->_url, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postFields, CURLOPT_HEADER => true, )); $result = curl_exec($ch); curl_close($ch); if(strpos($result, 'VERIFIED') != FALSE) { //this is just to see what is being outputted but most likely this is where you'll want to update database if payment was 'VERIFIED' // see above 'Update'; VERIFIED only means there was a valid transaction and NOT // if the payment was successful or not. file_put_contents('result.txt', $result . ' - ' . var_export($_POST, true)); } }}$paypal= new Paypal_IPN('sandbox');$paypal->run();?> This is what an output looks like for the transaction in the result.txt file: HTTP/1.1 100 ContinueHTTP/1.1 200 OKDate: Sun, 23 Mar 2014 04:36:08 GMTServer: ApacheX-Frame-Options: SAMEORIGINSet-Cookie: c9MWDuvPtT9GIMyPc3jwol1VSlO=t9cdRlHmh810vJqbRP414pqaQg7Y8XgwzDjtEp8HtQXHNMU7BrDjs1miWA0RMHBAHZ1gGhvI-RklC1JSWfK2cVz3Mx1jGyxhEJehjxroFMXIro9CtpKJJxvvtSstV3dSm-aI88cK4_6K60gqC0dbi-zHtvWSV4-E8s1sWpt5NcLTnIfeEGutWWuUTsEZbGI8Wx1_Nix_GaN16djn00Vdyx1VJXHnMKjhiKQZ9vseF8XkpDKJvkSry3IRy80C3aEMn3DqAIJOcTwP2YbdFXT1Gg6YAe26oHHdE9BfhnGvGG5Q7IdqXGiklTfG5ShD1kZFB14OiOy7YFDlXRPjP_LLf-KkWPvhMp5k_WzADSL5IP93RO4fTbAn6gvh2pHzOcYh4DRWBF9Ii8yprM3w4hGNw-j5YZkdyXICuQYSnE40mKaB0pZJHoGfbu8QWV4; domain=.paypal.com; path=/; Secure; HttpOnlySet-Cookie: cookie_check=yes; expires=Wed, 20-Mar-2024 04:36:08 GMT; domain=.paypal.com; path=/; Secure; HttpOnlySet-Cookie: navcmd=_notify-validate; domain=.paypal.com; path=/; Secure; HttpOnlySet-Cookie: navlns=0.0; expires=Tue, 22-Mar-2016 04:36:08 GMT; domain=.paypal.com; path=/; Secure; HttpOnlySet-Cookie: Apache=10.72.109.11.1395549368157218; path=/; expires=Tue, 15-Mar-44 04:36:08 GMTX-Cnection: closeSet-Cookie: X-PP-SILOVER=name%3DSANDBOX3.WEB.1%26silo_version%3D880%26app%3Dslingshot%26TIME%3D3093573203; domain=.paypal.com; path=/; Secure; HttpOnlySet-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMTSet-Cookie: Apache=10.72.128.11.1395549368142336; path=/; expires=Tue, 15-Mar-44 04:36:08 GMTVary: Accept-EncodingStrict-Transport-Security: max-age=14400Transfer-Encoding: chunkedContent-Type: text/html; charset=UTF-8VERIFIED - array ( 'mc_gross' => '10.00', 'protection_eligibility' => 'Eligible', 'address_status' => 'confirmed', 'payer_id' => '77FWLVRQMKQTU', 'tax' => '0.00', 'address_street' => '1 Main St', 'payment_date' => '21:35:54 Mar 22, 2014 PDT', 'payment_status' => 'Completed', 'charset' => 'windows-1252', 'address_zip' => '95131', 'first_name' => 'Bruce', 'mc_fee' => '0.59', 'address_country_code' => 'US', 'address_name' => 'Bruce Wayne', 'notify_version' => '3.7', 'custom' => '', 'payer_status' => 'verified', 'business' => 'd.nu-facilitator@gmail.com', 'address_country' => 'United States', 'address_city' => 'San Jose', 'quantity' => '1', 'verify_sign' => 'ABr7TF1VNJRHrFfJkVMfCcSa87ETA-vHI9gkqlaorJcID4GyrIyuZUoN', 'payer_email' => 'whocares_sowhat@yahoo.com', 'txn_id' => '9J104269XA701392G', 'payment_type' => 'instant', 'btn_id' => '2923468', 'last_name' => 'Wayne', 'address_state' => 'CA', 'receiver_email' => 'd.nu-facilitator@gmail.com', 'payment_fee' => '0.59', 'shipping_discount' => '0.00', 'insurance_amount' => '0.00', 'receiver_id' => 'FGA7J2A7XH3BA', 'txn_type' => 'web_accept', 'item_name' => 'Product', 'discount' => '0.00', 'mc_currency' => 'USD', 'item_number' => '', 'residence_country' => 'US', 'test_ipn' => '1', 'shipping_method' => 'Default', 'handling_amount' => '0.00', 'transaction_subject' => '', 'payment_gross' => '10.00', 'shipping' => '0.00', 'ipn_track_id' => 'd4b4a4bf77bb5',) As you can see, it's 'VERIFIED' meaning payment was good. Payment_status determines if a payment was good or not. There you can also see all the info. You can see what's returned from curl_exec() in the $result which is where you'll check to see if it's 'VERIFIED' or 'INVALID'. For the sake of seeing what paypal POSTs back to your ipn file, I var_export $_POST to get an idea of the info (See above). All of that can be accessed like this for example: $_POST['first_name'], $_POST['shipping'] etc etc if you wish to do that to use certain info upon updating database table per transaction per user, etc. The script above is a class, you don't necessarily need to have it as a class but I decided to go with that from a tutorial I came across on the net. A couple of things to remember: On the 'live' site, since payal is posting back to your site, it is required for you to have a SSL certificate. For that, you're going to have to add to the cURL options like the following: $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => $this->_url, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => true, //this set to true CURLOPT_SSL_VERIFYHOST => 2, // this set CURLOPT_CAINFO => "api_cert_chain.crt", // path to your SSL certicate here CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postFields, CURLOPT_HEADER => true, )); Make sure your port number 443 is open which most likely it is. Another way to test the ipn script is by going to paypal sandbox site and going to the ipn simulator. It's a way to test your ipn script without having to make a buynow button, then going to the site clicking on it, etc. Well hopefully this was of some use to you. Good luck! Edited: see 'Update'.
  7. Don E

    JS Mysql Alert box

    Right. I was hinting that he should look at that.
  8. Don E

    JS Mysql Alert box

    Are you connecting to a database anywhere in the code? Also, make sure your query is correct.
  9. You have to pass a value to the constructor when you create a new instance of the class car(); For example: $myCar=new Car('BMW'); So instead of having this line:$myCar->ime="My car"; Just do:$myCar=new Car('My Car'); When you create an instance of the class car, since the constructor is expecting an argument, you have to pass it in. For the start function, looks like you forgot the keyword this-> for $ime; should be $this->ime public function start($time){ echo $this->ime." starts at ".$time.".";}
  10. Don E

    create class

    When you create a new instance of Animal, you're not passing anything to the construct: $obj = new Animal('Lion'); Also, $color is not being given a value anywhere it looks like.
  11. Probably best to use only one jquery.min.js and the most recent version if possible. IF one of those two scripts requires a specific version of jquery.js for that script to work, then use that jquery.js instead and see if it works with the other script as well. Usually though in most cases both scripts should work when you call to one(same) jquery file.
  12. Don E

    www vs. non-www

    Hello everyone, I thought I'd post on here and get the opinions and insights on using www. or not using www. in a domain name upon visit a site. It's a question that's often asked on the net and I've searched around and it boils down basically to "personal preference" so to speak.. but now what I realized from browsing the net these days etc, is that most websites specifically choose to have the www. in their domain name.(I know www. is automatically in the domain name when registering a domain name; I'm referring to when a user visits, if a site chooses to have the www. appear in the address bar or not for their domain name. I recall years ago or so it was a "trend" or something to NOT have the www. in a domain for a site, but nowadays it seems having the www. is the 'proper' way to go. Big websites, such as facebook, yahoo, google, bank sites, etc etc, always direct users to the www. when typing in facebook.com or yahoo.com etc in a browser. Do these sites REQUIRE to have the www. because of their infrastructure(the way the site was built/developed) so to speak of their site or is it something to do with search engines perhaps nowadays? Or is it because many of those sites have so many subdomains like sports.yahoo.com or movies.yahoo.com etc? Thanks.
  13. I don't think it's the code itself. Could be a variety of other reasons. Sometimes it's the server the site is hosted on if it doesn't have enough resources for example, like CPU, memory. If you're on a shared hosting plan, that could be a reason but for what you have, it shouldn't take 10 minutes to send. The problem may be somewhere else all together as to why it takes 10 minutes. Are you saying when you send the email via the form, the webpage takes 10 minutes to finish sending the email where you see something like "waiting for... " in the status bar at the bottom of your web browser OR... the email gets sent but 10 minutes later you check your inbox and it's finally there after 10 minutes?
  14. You have this:$interest = $_POST["interest1"];$interest = $_POST["interest2"];$interest = $_POST["interest3"]; but for the Project type line, you have:Project Type: $type - $interest1 $interest2 $interest3 Appears you forgot 1, 2, 3 for the $interest variables: $interest1 = $_POST["interest1"];$interest2 = $_POST["interest2"];$interest3 = $_POST["interest3"]; I believe you will get a 'undefined index' PHP warning error if you don't first make sure the check boxes are 'set'(checked) or not. You can try/do: $interest1 = isset($_POST["interest1"]) ? $_POST["interest1"] : 'Interest 1 not checked(Solar Electric).';$interest2 = isset($_POST["interest2"]) ? $_POST["interest2"] : 'Interest 2 not checked(Solar Water).';$interest3 = isset($_POST["interest3"]) ? $_POST["interest3"] : 'Interest 3 not checked(Pool/Spa).'; You can also use the same name for the name attribute for the check boxes by adding [] to the name, it becomes an array and you can loop through it to find the 'set'(checked) check box: name="interest[]". Below is an example: <?php if(isset($_POST['submit'])) { $interests = ''; foreach($_POST['interest'] as $inter) { if(isset($inter)) { $interests .= $inter . ' '; } } echo 'Interests are: '. $interests; }?><!doctype html><html><head><meta charset="UTF-8"><title>Check Boxes</title></head><body><form method="post" action="checkBoxes.php"><input type="checkbox" name="interest[]" value="Solar1"/>Solar1<br/><input type="checkbox" name="interest[]" value="Solar2"/>Solar2<br/><input type="checkbox" name="interest[]" value="Solar3"/>Solar3<br/><input type="checkbox" name="interest[]" value="Solar4"/>Solar4<br/><input type="submit" name="submit" value="Submit"/></form></body></html> Hopefully this was of some help.
  15. Have you tried adding this.draw = function(){ // code to run here }; to the var GameObject function(object)?
  16. Here's updated code based on what you mentioned. I commented out certain parts from the previous code. <!doctype html><html><head><meta charset="UTF-8"><title>Phone Number Phrase</title> <script type="text/javascript"> function checkPhrase(/*form*/) { var number = ''; //var phrase = form.phrase.value; var phrase = document.getElementById('numPhrase').value; for(var i = 0; i < phrase.length; i++) { switch(phrase[i]) { case 'a': case 'b': case 'c': number = number + '2'; break; case 'd': case 'e': case 'f': number = number + '3'; break; case 'g': case 'h': case 'i': number = number + '4'; break; case 'j': case 'k': case 'l': number = number + '5'; break; case 'm': case 'n': case 'o': number = number + '6'; break; case 'p': case 'q': case 'r': case 's': number = number + '7'; break; case 't': case 'u': case 'v': number = number + '8'; break; case 'w': case 'x': case 'y': case 'z': number = number + '9'; break; } } document.getElementById('numPhrBut').innerHTML = "Submit is: " + phrase; document.getElementById('dispNum').innerHTML = "Phrase converted is: " + number; //alert(number); //return false; } </script></head><body><label>Enter phrase number:</label><input id="numPhrase" type="text" name="phrase" size="10"/><br/><button id="numPhrBut" type="button" onClick="checkPhrase()">Submit</button><br/><span id="dispNum"></span><!--<form method="post" action="#" onSubmit="return checkPhrase(this)"><label>Enter phrase number:</label><input type="text" name="phrase" size="10"/><br/><input type="submit" name="submit" /></form> --></body></html>
  17. The following is an example of what immediately came to mind in trying to accomplish what you're asking. I'm sure there are other ways as well and you don't have to use a form either. Hopefully it will give you an idea that sets you in the right direction. <!doctype html><html><head><meta charset="UTF-8"><title>Phone Number Phrase</title> <script type="text/javascript"> function checkPhrase(form) { var number = ''; var phrase = form.phrase.value; for(var i = 0; i < phrase.length; i++) { switch(phrase[i]) { case 'a': case 'b': case 'c': number = number + '2'; break; case 'd': case 'e': case 'f': number = number + '3'; break; case 'g': case 'h': case 'i': number = number + '4'; break; case 'j': case 'k': case 'l': number = number + '5'; break; case 'm': case 'n': case 'o': number = number + '6'; break; case 'p': case 'q': case 'r': case 's': number = number + '7'; break; case 't': case 'u': case 'v': number = number + '8'; break; case 'w': case 'x': case 'y': case 'z': number = number + '9'; break; } } alert(number); return false; } </script></head><body><form method="post" action="#" onSubmit="return checkPhrase(this)"><label>Enter phrase number:</label><input type="text" name="phrase" size="10"/><br/><input type="submit" name="submit" /></form></body></html>
  18. When you say phone number phrase, you mean: three one three five five five three two one six?
  19. Yes, you would need a server-side language like PHP or ASP.NET to process the entered text and send the mail. What you described is how most email/contact forms work. http://www.w3schools.com has tutorials on getting you started with that. Most popular server-side language on this forum is PHP if you decide to go with that.
  20. Don E

    search engine

    You can move $i = 0 from the foreach loop and put it right before it.
  21. Don E

    Encryption

    http://ssl.com/ has affordable SSL certificate if interested, $49 a year.
  22. See this link: http://www.w3schools.com/php/php_mail.asp on how to send mail with PHP. Also see the 'secure' way: http://www.w3schools.com/php/php_secure_mail.asp
  23. Try removing .event. from this: edit_btn.event.onclick=view_lead_save_field(json_param); edit_btn.onclick=view_lead_save_field(json_param);
  24. From what I understand and could be wrong, I am sure mysqli prepared statements prevent SQL injection as well like PDO prepared statements.
  25. Don E

    Forum Issues?

    The question should be... when is this going to be fixed?
×
×
  • Create New...