|
AFAIK, PHP is a server side scripting language.
If you want to move to Object Oriented programming, its better to try .net (C#) or Java.
You will get a lot of examples over the internet.
Life is a computer program and everyone is the programmer of his own life.
|
|
|
|
|
Welcome to 2004.
Quote from Wikipedia: On July 13, 2004, PHP 5 was released, [...] PHP 5 included new features such as improved support for object-oriented programming, ... and it's advanced a lot more since then.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
|
Object-oriented-ism is a concept, not a tool. Any platform can have it if they start following the rules of Object-oriented programming - Wikipedia[^].
Secondly, C# is not a pure object-oriented language either, it just uses the concepts.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Sorry dude but php is OOP
Kribo
|
|
|
|
|
Yeah I got a response long back. Thanks for confirming it again.
Life is a computer program and everyone is the programmer of his own life.
|
|
|
|
|
Did you try to Google? A simple Google for "oop in php" would have yielded the following,
Object Oriented Programming in PHP[^].
Quote: And what project will be suitable for me to learn things quickly and smartly .... i.e e-commerce or else?? ? I recommend build applications for your own use. Your own online notes keeping application, your online to-do list, etc. This gives a flexible time to learn and experiment.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
thanks ...its really helpful
|
|
|
|
|
YO dude...
If you wanna master PHP - OOP - MVC then I sugest to try creating your own Php - Mvc - Framework.
And if you need some idea of what one looks like have a look at the one I created for the same reason. You can download the source code from bitbucket. bitbucket And if you can improve it even better...
So dude have @ it....
kribo @ ScorpioCoding
Kribo
modified 5-Dec-16 12:34pm.
|
|
|
|
|
|
Hello Programmers,
Ho are you all ? I am slowly getting well. However that will speeden up as soon as I start learning Php 7.
MY PHP 7 LEARNING PROBLEM
Most tutorials I find assume I know Php 5 and only mention what's new in Php 7 and just teach the new things added into Php 7. Those tutorials are no good to me since I don't know Php 5 or any previous versions. I need a tutOrial that would teach me orthodox Php 7 (and not frameworks, etc.) and object oriented php (OOP) which would teach me right from the beginning starting from the "Hello World!". I think you know what I mean.
(NOTE: Not interested in learning Php 5 or any previous versions. Why learn old timers which are about to go extinct. Plus, in Php 7, you write less code compared to previous version and the page loading are thrice as fast.
I do have some programming background but not in Php. Only in Ubot Studio which is a visual bot programming tool.
Q1. For beginners:
* Do you recommend any free/paid tutorials on php 7 be it text or video ?
* Do you recommend any free/paid online course on php 7 where we can take online exams and get certified that employers would recognize and value ?
I am at a loss on where to start learning php 7.
I was wondering if you programmers could kindly recommend to me:
1. A good php 7 free tutorial (text or video) website;
2. A good php 7 online course (text or video) to get ceritified as a php developer/programmer.
TUTORIAL/COURSE REQUIREMENTS
1. Tutorial/course must be on Php 7 only and not 5.6 or lower.
2. Tutorial must teach the full language (basic and fundamentals and all commands & functions) and not just the parts that deal with Web design only (Php & Mysql).
3. The tutorial/course must first teach the basics of the php 7 language and then move-on to the intermediate then the advance level.
4. Not interested in Frame Works as of now. Especially, not interested in Frame Works that are not developed by the official Php language developer (php.net). (Eg. Not interested in third party Frame Works such as Zend or Laravel since they're not officials like php.net is). Must teach the core of the language first. Can move-onto Frame Works later, if I wish.
5. Must be OOP (Object Oriented Php).
MY AIM/DREAM
I want to become a php developer/programmer. A php expert. A php guru, who knows all the default & official commands and functions of the language.
I am interested in becoming a professional Php programmer and a freelancer so I can build professional dynamic websites for myself and my clients. I wish to become expert enough to build my own websites and platforms using my own codes that I write and not need to rely on other programmers. Not need to hire any php programmer or borrow php codes from anywhere.
PHP CAREER DREAM
I may get into freelancing where clients outsource me jobs/tasks/assignments to build dynamic websites with Php 7. Hence, I need to learn Php 7 properly to become a Pro Php freelance programmer.
I need to become professional enough to rely on myself and to build my own:
* Forum (phbb, etc.)
* Chat
* Instant Messenger
* CMS (like Word Press, Dolphin, Drupal, Joomla, etc.).
* Social Networks (like Youtube, Facebook, Twitter, Del.icio.us, Reddit, Digg).
It is my hobby to learn things and build things on my own according to my own needs (custom design & features) even if that means re-inventing the wheel a little or even if the work doesn't result upto standard at first. You will agree that, it feels great to build things all by yourself top to bottom from scratch and give life to it even if it isn't upto standard.
I have been researching internet marketing ever since 2004 and have gained a fair understanding of what works and what not online. I have a lot of great concepts and I wish to give life to them in the form of dynamic websites. Hence, the need to learn Php 7.
In short, whenever I come-up with a good concept (good Social Networking concept) then I wish to immediately start programming in Php 7 and make my dream website come true.
NOTE: (I wish to learn how to walk first, then jog, then run in Php programming and not jump into the deep end at the beginning (jumping into frameworks, etc.). I think you understand what I mean.
Hearing all this, can you be kind enough to recommend us your article/blogwebsite audience some tutorials both text and video for complete beginners like me ? I mean, which tutorial sources cover Php 7 from top to bottom for beginners so I can launch my Php 7 programming career ? As a beginner, I don't want to get into Php frameworks just yet as I first want to learn the basics of the Php 7 language then move-on the intermediate level. You may count me as a complete beginner, if you like.
Would also appreciate you recommending us some intermediate level text & video tutorials so we can move-on to them after the beginning levels end. Not interested in learning Php 7 in anybody’s way (Zend’s way or Laravel or this or that organisation's or company’s way) but interested in learning it the “Main Stream’s way” (The Way). The default way. The orthodox way. I think you know what I mean.
Also, which WAMP or XAMP should I install to use Php 7 ?).
Thank you in advance for your reply.
Ali
|
|
|
|
|
Hi there!
I've been developing a small tool to test PHP code snippets online.
Here it is: Online PHP Debugger
Now I want user can choose the version. So I think I should install multiple PHP versions on same server.
Has anyone done it?
Please give me a comment or your ideas.
|
|
|
|
|
I recently uploaded my wordpress website into a live free hosting server 000webhosting but realized that only my home page is showing.I have tried all i could to get other pages to show to no avail. After uploading my wordpress files, database file, wp_options in myphpadmin and editing the wp-config file to point to the web address i have tried editing my .htaccess file, yet the other pages wont show.Could this be as a result of the free hosting plan or what?I will appreciate all the help i can get please. Steve
|
|
|
|
|
|
|
We can't see anything at all so I would suggest contacting your hoster first.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Greetings experts.
I think I made this more complicated than it needs to be.
Users are required to log in to take a test.
If a user tries logging in, the system checks to see if the user has taken the test or not.
If the user has taken the test, s/he is redirected to a page called registered.php which displays benefits of membership.
If no record exists for this user, the user is taken to the called register.php so s/he can take the test.
The scenarios described above works fine.
However, we are running into a problem where if a user mistakenly enters incorrect username/password, the system assumes the user has logged in correctly but has not taken the test and redirects her to register.php.
We would like to modify the code to perform three checks.
If username/password is not correct, display a message to user that either username or password is incorrect.
If username/password is correct and the user has not taken the test, redirect to register.php.
If username/password is correct and the user has taken the test, redirect user to registered.php.
Any ideas how to modify the code below?
I have spent so much time trying to fix this but it is not working for me.
Thanks a lot in advance for your help.
$strSQL = "SELECT u.empl_first, u.username, u.empl_first +' '+ empl_last as fullname, e.Department, e.UnitName, e.empnum FROM users u inner join Employee e on u.Employee_Id = e.EmpNum inner join tblTBA t on u.Employee_Id = t.Employee_Id WHERE USERNAME = '".ms_escape_string($_POST['user'])."'
and PASSWORD = '".ms_escape_string($pass)."' ";
$sqll = sqlsrv_query($con, $strSQL);
if ($objResult = sqlsrv_fetch_array($sqll, SQLSRV_FETCH_ASSOC)) {
$firstname = $objResult["empl_first"];
$_SESSION["username"] = $objResult["username"];
header('location:registered.php?user=' . urlencode($firstname));
}
If ($user == $_SESSION["username"]) {
header("location:register.php?user='".ms_escape_string($user)."'&pass='".ms_escape_string($pass)."' ");
}
else
{
echo "Username and Password Incorrect!";
}
|
|
|
|
|
First off, your urgently need to fix the SQL Injection[^] vulnerabilities in your code.
Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^]
How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^]
Query Parameterization Cheat Sheet | OWASP[^]
Next, fix your password storage. You're currently storing password in plain text, which is an extremely bad idea. You should only ever store a salted hash of the user's password, using a unique salt per record.
Secure Password Authentication Explained Simply[^]
Salted Password Hashing - Doing it Right[^]
Also, NEVER put the user's password in the URL. The browser retains a history of every URL visited, making it trivial for someone with access to the user's history to discover their password.
Finally, to fix your problem, you need to split your validation into two steps:
- Is the username and password valid?
- Has the user completed the test?
Currently, you're trying to do both at once, which is why you're getting confused.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You to the rescue again. Thank you very much sir.
First off, I am using a hash.
$pass = md5($pass);
I did not paste it as part of my initial code.
Second, I created this custom script that I thought helps keep my code from sql injection attack:
</<pre lang="PHP">
function ms_escape_string($data) {
if ( !isset($data) or empty($data) ) return '';
if ( is_numeric($data) ) return $data;
$non_displayables = array(
'/%0[0-8bcef]/',
'/%1[0-9a-f]/',
'/[\x00-\x08]/',
'/\x0b/',
'/\x0c/',
'/[\x0e-\x1f]/'
);
foreach ( $non_displayables as $regex )
$data = preg_replace( $regex, '', $data );
$data = str_replace("'", "''", $data );
return $data;
} pre>
However, I can change it to use parameterized query:
$strSQL = "SELECT u.empl_first, u.username, u.empl_first +' '+ empl_last as fullname, e.Department, e.UnitName, e.empnum FROM users u inner join Employee e on u.Employee_Id = e.EmpNum inner join tblTBA t on u.Employee_Id = t.Employee_Id WHERE USERNAME = ?
and PASSWORD = ? ";
$params = array($_POST["user"], $_POST["pass"]);
$sqll = sqlsrv_query($con, $strSQL, $params);
Now, if I am on the right track on those two, could please be kind to help with the last part where I am trying to check whether username and / or password is correct and redirecting to appropriate page as described?
Thanks again for your help.
|
|
|
|
|
samflex wrote: First off, I am using a hash.
$pass = md5($pass);
An unsalted MD5 hash doesn't offer much protection:
Troy Hunt: Our password hashing has no clothes[^]
samflex wrote: check whether username and / or password is correct and redirecting to appropriate page
As I said, use two steps:
1) Validate the username and password:
SELECT
u.empl_first,
u.username,
u.empl_first +' '+ u.empl_last as fullname,
e.Department,
e.UnitName,
e.empnum
FROM
users u
INNER JOIN Employee e
ON u.Employee_Id = e.EmpNum
WHERE
u.USERNAME = ?
And
u.PASSWORD = ?
If no data is returned, then the username or password is invalid.
2) Check whether the user has completed the test:
SELECT Employee_Id FROM tblTBA WHERE Employee_Id = ?
If no data is returned, then the user has not taken the test.
NB: If the Employee record doesn't get created until the user has taken the test, then you'll need to move that part of the query from step 1 to step 2.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
ahhh got!
I am slow.
Thanks so much. I learn so much when I am fortunate to get your help.
I would not have thought of doing it this way.
Thanks a lot Richard.
|
|
|
|
|
Sorry Richard,
I tried doing it separately like you spec'ed it out and it is just not working.
The first part which validates username/password works but when I added the second part, then it doesn't matter whether I have correct username and password, it just takes me to login page.
The code you see here shows I am doing them together again with if...else but that's just what I am trying since separating them isn't working.
$user = trim($_POST["user"]);
$pass = trim($_POST["pass"]);
$tsql = "SELECT u.empl_first, u.username, u.empl_first +' '+ empl_last as fullname FROM users u WHERE u.USERNAME = ? and u.PASSWORD = ? ";
$params = array($user, $pass);
$result = sqlsrv_query( $con, $tsql, $params, array(), array( "Scrollable" => 'static' ));
$row_count = sqlsrv_num_rows($result);
if ($row_count == 0){
header('location:login.php?msg=1');
exit;
}
else
{
$tSQL = "SELECT u.empl_first, u.username FROM users u inner join tblTBA t on u.Employee_Id = t.Employee_ID WHERE USERNAME = '".ms_escape_string($user)."'
and PASSWORD = '".ms_escape_string($pass)."' ";
echo $strSQL;
$sqll = sqlsrv_query($con, $tSQL);
}
if ($objResult = sqlsrv_fetch_array($sqll, SQLSRV_FETCH_ASSOC)) {
$firstname = $objResult["empl_first"];
$_SESSION["username"] = $objResult["username"];
header('location:donetba.php?user=' . urlencode($firstname));
}
else
header("location:registered.php?user='".ms_escape_string($user)."'&pass='".ms_escape_string($pass)."' ");
sqlsrv_close($con);
?>
|
|
|
|
|
Nothing obvious in the code, although you still need to parameterize the second query in the same way as the first, and you're still passing the password in the query-string to the registered.php page.
You could probably remove the else , since you've got an exit; in the if block.
Are you sure it's this page that's redirecting the user to the login page? Try tracing the network requests in your browser's developer tools, to see if either registered.php or dotnetba.php is doing the redirection instead.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
That was it!!!
Removing the else since I have exit seems to have fixed it.
I have fixed the parameterized query stuff.
Thanks so much Richard.
I really, really am grateful for your help.
|
|
|
|
|
I'm not sure what I'm doing wrong, but for some reason my page works fine only after hitting the submit button twice.
Below is the code. Any help or a point in the right direction would be greatly appreciated.
The removejob.php is a small page that just makes a connection and updates a single field based on the jobid.
<html>
<head>
<title>Phoenix Metals Job Interface</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
function like(Job)
{
$.ajax({
url: "RemoveJob.php",
type: "POST",
data: { 'JobID': Job },
success: function()
{
window.location.reload();
}
});
}
</script>
<style>
body
{
font-size: 200%;
}
table
{
width: 900px;
font-size:40px;
font-weight: bold;
}
td
{
text-align: center;
vertical-align: center;
border: 1px solid black;
padding: 10px;
}
.button
{
background-color: #ff3386;
color: white;
width: 175px;
height: 65px;
text-align: center;
vertical-align: middle;
font-size: 20px;
font-weight: bold;
}
</style>
</head>
<body>
<?php
$con=mysqli_connect('localhost', 'xxxxxxx', 'xxxxxxx','xxxxxxx');
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$JobResults = mysqli_query($con,"SELECT * FROM JobInterface WHERE Completed is null ORDER BY JobNumber");
echo"<table>";
echo"<tr>";
echo"<tr><td colspan='3'>Phoenix Metals Job Interface</td></tr>";
echo"<td>";
echo"Job Number";
echo"</td>";
echo"<td>";
echo"Project Name";
echo"</td>";
echo"<td>";
echo"Account";
echo"</td>";
echo"<td>";
echo"Edit";
echo"</td>";
echo"<td>";
echo"Remove";
echo"</td>";
echo"</tr>";
$JobRow = array();
while($JobRow = mysqli_fetch_array($JobResults))
{
$back = 'white';
$message = 'Not Finished';
if(($JobRow['Sheets'] != 1) && ($JobRow['Burned'] != 1) && ($JobRow['FormUp'] != 1) && ($JobRow['CoilLine'] != 1) && ($JobRow['Liner'] != 1) && ($JobRow['Vanes'] != 1) && ($JobRow['Assembled'] != 1) && ($JobRow['Wrapped'] != 1) && ($JobRow['HandFab'] != 1) && ($JobRow['Welded'] != 1) && ($JobRow['Supplies'] != 1) && ($JobRow['WardFrames'] != 1) && ($JobRow['Special'] != 1))
{
$back = 'aqua';
$message = 'Possibly Done';
}
echo"<tr>";
echo"<td>";
echo $JobRow['JobNumber'];
echo"</td>";
echo"<td>";
echo $JobRow['ProjectName'];
echo"</td>";
echo"<td>";
echo $JobRow['AccountName'];
echo"</td>";
if ($JobRow['RTS'] == 0)
{
echo"<td style='background-color:".$back.";'>";
echo"<form style='margin-bottom:0; align:center;' name='EditJob' action='JobEdit.php' method='POST'><input type='hidden' name='JobID' value='".$JobRow['IDJob']."'/><input class='button' type='submit' name='submit-btn' value='Details'/></form>";
echo"</td>";
echo"<td>".$message."</td>";
}
if ($JobRow['RTS'] == 1)
{
echo"<td style='background-color:aqua;'>";
echo"RTS";
echo"</td>";
echo"<td bgcolor='#FF0000'>";
echo"<form style='margin-bottom:0; align:center;' name='ReloadJob' action='JobInterfaceMain.php' method='POST'>";
echo"<input class='button' type='submit' name='submit-btn' onclick='like(".$JobRow['IDJob'].")' value='Gone'/>";
echo"</form>";
echo"</td>";
}
echo"</tr>";
}
echo"</table>";
?>
</body>
</html>
|
|
|
|
|