Jump to content

Ansego

Members
  • Posts

    151
  • Joined

  • Last visited

Everything posted by Ansego

  1. Hey guys I really appreciate you all and phpfreaks! Won't let me mark all solved so I've quoted all to solve, test code is as follows: Special thanks guys! TRQ: Thanks for the resource: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md | PHP Is your calling man! .josh: Thanks mate, always awesome and detailed. KevinM1: Thanks heaps for the detailed post very helpful. I will need to reread this post several times to taken in all the great input wow. Index.php function __autoload($classname) { $filename = "./inc/". $classname .".inc"; include_once($filename); } $myobjA = new testclassA(); $varstring = "test"; $myobjA->setmyvar($varstring); print "OUTPUT: " . $myobjA->getmyvar(); testclassA.inc class testclassA { protected $myvartest; public function __construct() { echo "testA class successfuly!"; } public function setmyvar($varstring){ $this->myvartest = $varstring; return $this; } public function getmyvar(){ echo "</br>test found </br>"; return $this->myvartest; } } ================================================================================================================ All contributed to a solved solution!
  2. I appreciate the feed back guys, I would like to recap to make sure I have this in my head correctly: Don't ever use globals Wrap it with a function ie get / set Below I have test code setup, but when I call the getmyvar it does not allow me to echo the var out? Why? Would this be the correct and safe setup? index.php function __autoload($classname) { $filename = "./inc/". $classname .".inc"; include_once($filename); } $myobjA = new testclassA(); $varstring = "test"; $myobjA->setmyvar($varstring); echo "OUTPUT: " . $myobjA->getmyvar(); inc/testclassA.inc class testclassA { protected $myvartest; public function __construct() { echo "testA class successfuly!"; } public function setmyvar($varstring){ $myvartest = $varstring; return $myvartest; } public function getmyvar(){ echo "</br>test found </br>"; return $this->myvartest; } } OUTPUT: testA class successfuly! test found OUTPUT:
  3. Hi guys, Having trouble with declaring a global variable, just getting into classes so having fun knocking some junk out; Q. Am I declaring this global variable correctly? Q. Should I be using global's to pass variables/values between methods? if NOT what should I be doing? $myvartest seems to get this error: Notice: Undefined variable: myvartest in ........ Line 13. <?php class testclassA { protected $myvartest = "</br>testING PRIVATE</br>"; public function __construct() { echo "testA class successfuly!"; } public function mytestA($str_passed){ isset($myvartest); echo "test found $str_passed"; echo "my test string: $myvartest"; } } ?>
  4. Hello all; might be a silly question but I need to ask it, I end up with 1000+ lines of code for 10 field forms, thinking to myself this cant be right, defiantly not using the KISS principle!, so I want to try using classes and not 100% on structure or use and hoping they may make my life easier. Below is MOCK up code and my questions are: Q: Is this best practise? (form->handler->classes->db) REF BELOW CODE! Q: How do you guys handle your forms -> classes -> db? Q: What is best practise? Q: In PAGE: index.php should it be including all 3 other pages? is that how you include a class? Q: Please share rules and thumbs, hints, theories, methodologies etc etc... MOCK CODE - CODE NOT TESTED & Prob won't work just general mock for structure and logic: PAGE: INDEX.PHP (MOCK CODE) include 'inc/frm_handler.inc.inc'; include 'inc/check_class.inc'; include 'inc/dbhandler_class.inc'; <form...> <input name='test' type='text' value=''/> <input type='button' value='&Submit'/> </form> PAGE: FORM_HANDLER.INC (MOCK CODE) $testcheck = new testcheck(); $myvar = $_Post['test']; if ($testcheck.test_check($myvar) == true){ $dbsqlsend = new dbsqlexecute(); $dbsqlsend.executeSQL($myvar); } PAGE: CHECK_CLASS.INC (MOCK CODE) class testcheck{ public test_check($str_check){ if (filter_var($str_check, FILTER_SANITIZE_STRING)){ return true; } else { return false; }; }; }; PAGE: DBHANDLER_CLASS.INC (MOCK CODE) class dbsqlexecute{ public executeSQL($str_sql){ // EXECUTE MYSQLI CODE HERE ETC }; };
  5. You can also stop legit bots indexing your webpages through a robot.txt file : Reference: http://www.robotstxt.org/
  6. How is it FTP'ing? Is there code written already? Can you paste in a post?
  7. I use them when ever I need to use them multiple times throughout the code. If I use something once or even twice I don't normally use unless it is for security and I am placing them outside the root of my web.
  8. Cheers thanks @Ch0cu3r - Sorry to high jack this thread.
  9. This any good to you? Just change it to how you need it. Reference: http://au1.php.net/time <?php $nextWeek = time() + (7 * 24 * 60 * 60); // 7 days; 24 hours; 60 mins; 60secs echo 'Now: '. date('Y-m-d') ."\n"; echo 'Next Week: '. date('Y-m-d', $nextWeek) ."\n"; // or using strtotime(): echo 'Next Week: '. date('Y-m-d', strtotime('+1 week')) ."\n"; ?>
  10. Just curious what's .= do? The dot before? Also seen :: ??
  11. Error: Notice: Undefined index: newsid in pathway on line 9 FIX: isset($_GET['newsid']); The SQL Statement error might be fixed by this above.
  12. Hi, Not 100% on the question, but I will try to help. In your input text fields they are setup for array ( ie <input name="foto[]" size="20"> ) A good reference for array's: PHP ARRAYS *(You can also count how many values in arrays search: array_count_values ) To upload your files this might be helpful: W3SCHOOL PHP MAILER : you can use this for reference: HERE Compile all your text fields into the body/message variable. Hope this helps you out.
  13. Least you are giving it ago Azercii. Every body shares code that is a norm with development, use a pen and paper before you start coding to workout what you want to build/do before you start hacking away. Some resources I recommend: W3Schools Php Google PhpFreaks Next time you ask a question might be an idea do share the code at your initial post of question to help phpfreaks help you, keep it simple (KISS principle), think about the question first and begin, everyone is learning and finding new things everyday so don't be scared to ask a question. The forum is for helping each other, even the guru's still use references and ask questions. I myself am newb and I learn by reading these forum posts and research and practise. Have fun coding!
  14. Do they have a RSS Feed? would that not have the data your looking for?
  15. Kinda little confused with the question. drop-down box? wah! use hidden field with value of member... well if you got it working that's cool too. Regards to the error: Failed to run query: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens Think you should try what TRQ suggested was that the password is reserved, change it.
  16. I am a newb plus late at night, so I might be reading it wrong. But the $_GET['i']; but the form is method='post' and the input is name='newsid' not $i. Or am I way off here?
  17. MOD PLEASE REMOVE THIS POST!!!
  18. Hehe @ JaysonDotPH The Back-tick ( ` ) was failing it!!!
  19. @Augury Spot on mate, error with the SQL when I ran it in WorkBench. Still working out why but I have a smile even for an ERROR! lol. I'll get back to you.
  20. Hi guys, Database connection is active SQLExecute($sqlstring) Is also been used from another form and works All fields are set OTHER then ID has been removed due to auto increment No Errors occurring Added $mysqli->select_db("dbleads"); still no change tested with other functional form and works All variables are set Don't know what else to do?
  21. Hi all, having some trouble working out whats going wrong here, don't get no errors to work from so I am stuck! Why is this NOT storing in the table? I have other code using the execution function and working, but this is failing but no errors. Please help! SQL Passing SQLExecute(" INSERT INTO `dbleads`.`offer` (`Username`, `Password`, `PWSalt`, `FullName`, `Email`, `Phone`, `Mobile`, `CompanyName`, `CompanyABN`, `Street`, `Suburb`, `State`, `Postcode`, `BStreet`, `BSuburb`, `BState`, `BPostcode`, `Comment`, `AgreeTC`, `TimeStamp`) VALUES (`$unop`, `$pwop`, `$salted`, `$fnop`, `$emailop`, `$phoneop`, `$mbop`, `$cnameop`, `$cabnop`, `$streetop`, `$suburbop`, `$stateop`, `$postcodeop`, `$Bstreetop`, `$Bsuburbop`, `$Bstateop`, `$Bpostcodeop`, `$commentop`, `$AgreeTC`, `$Timestamp`); "); Connection: function SQLExecute($sqlstring){ // CONNECTION $mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $mysqli->query($sqlstring); /* close connection */ $mysqli->close(); }
  22. lol @ fastsol. Yes maybe over kill, but still saves me time if they cannot put garbage in straight up. Clients are paying for these contacts so the last thing I want is to send them rubbish and have to spend more time fixing it later down the track. Safe then sorry. Have a captcha as well, simple math problem, should keep most the bots away... maybe. Also hear that by restricting what they put into the fields limits SQL injection etc. I have also limited the permissions on the database as well for simple insert/update and put the important includes in a folder outside the web folder for good measure. Thanks for your 2 cents, appreciated.
  23. Thanks heaps for everyone's input. @ phpzer | WORKS PERFECTLY! @ fastsol | Re why limit what users can put as full name: Clients don't want to receive gibberish, not met anyone with a number in their real name. I converted it to IF STATEMENT: FULL NAME: if (isset($_POST["Fullname"])){ $fnop = $_POST["Fullname"]; if (preg_replace("/[^A-Za-z\s]/", "", $fnop) == $fnop) { echo "</BR>PASSED! : FULLNAME : $fnop"; $statusflag = $statusflag + 1; } else { echo "</BR>FAILED! : FULLNAME : $fnop"; } }; PHONE: if (isset($_POST["Phone"])){ $phoneop = $_POST["Phone"]; if (preg_replace("/[^0-9]/", "", $phoneop) == $phoneop) { echo "</BR>PASSED! : PHONE : $phoneop"; $statusflag = $statusflag + 1; } else { echo "</BR>FAILED! : PHONE : $phoneop"; } }; Thanks heaps guys! Really 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.