What are some good simple projects for practicing PHP and mysql work?? Also implementing Ajax??
I am fairly new to PHP and mysql, and would like to gain more experience, I also enjoy using Ajax and xml
The most simple one is a Signup/Login Form.
While, signing up use JS to validate the form, and ajax call to submit the form data. And while taking a userId as input, you can use ajax call "onchange" to verify it's existence.
Then go for an Quiz App.
Self issuing Online Library.
And, the best one Online Pizza Ordering System.
How about trying to implement things that Facebook does, for example-
Tagging a person as you type their name
A simple chat box. Also take a look at this SO discussion
Some more googling gives you 25 Excellent Ajax Techniques and Examples
Related
I am making a game with PHP and jQuery, but I have some problems with security. It's a typing game, and when player types combination correctly, jQuery sends ajax request to PHP and PHP adds 10 points to session. Here is my code:
$('body').on('keyup','.codes_input',function() {
if($('.codes_input').val() == $('.code').html()) {
$.post(url+'/save_results',{_token:token});
points=points+10;
$('.code').html(randomString());
$('.codes_input').val('');
$('.points').html(points);
}
});
However, my friends could simply do many such $.post(url+'/save_results',{_token:token});requests in chrome extention (if I understood correctly) and got 1000 or even more points (cheating). Is there a way to avoid this? I can't find other way of programming this... Thanks for your help, sorry for my poor english :)
Move the logic of evaluating and awarding points to you PHP layer.
Use the jQuery with HTML Websockets just to submit the answer .
As an example architecture, you can have a look at the following:
Javascript and PHP for real-time multiplayer <- Join this SE network
Real Time Multiplayer in HTML5
Javascript can always be seen by the user, so you cannot really build a secure application like this.
The way to go would be to check via Javascript whether the code is correct (as you already do), and then send the code to the PHP script and validate it there as well.
I want to create a fairly simple webpage where a user logs in and can manipulate a calendar that I create (perhaps with a HTML table?). I've already created a simple login service with a few HTML and php pages and have basic user info stored in a MAMP server.
Correct me if I'm wrong, but from here I would need to layout a calendar in HTML and maybe have link table cells to an edit page where the user can create a new event. The real question here is what is the best way to go about storing information like this on my server? Using PHP and MAMP like I did with the form data at registration?
I'm still fairly new to databases and working with servers and such, so just looking for a little guidance so I don't waste time learning a completely incorrect approach to this.
MySQL and PHP are definitely the way to go in my opinion. I would look into Javascript and AJAX if I were you also. Using AJAX, you could have a user enter information into the calendar directly and store it in the database without having to leave the page. jQuery is a very nice and simple library for working with Javascript and AJAX and I would very highly recommend it. It greatly simplifies working with Javascript.
As for the calendar itself, using a table seems like the best approach to me.
For storing information in MySQL, I'm seeing a table somewhat like this:
UID|EntryID|Date|Time|Event|etc.
You could store this table separately from your users table and join them easily when making requests. For instance, when a user logs in, you can pull the users UID from the users table you have set up, then pull all entries out of the calendar table with matching UID's and manipulate and display this information with PHP and Javascript.
There may be (and most likely are) better ways to set up your database, but this is kind of just a general concept of how you could get it to work. There are certainly people here with much more experience in MySQL and database design than myself.
Overall it sounds like you have a good idea working for you and have a pretty good idea of what it will take to make it happen. I wish you the best of luck on your project!
I'm looking for some advice. I have been given a paper form with various criteria. I need users to be able to select a type of transport (Bus, Train, Taxi, Tram, Other).
Upon the selection, I need more fields to be produced in a form based on the user's choice. So questions about Bus times would be produced if the user selected bus.
The fields will be generated using PHP and MySQL. I have seen some JQuery solutions but I'm a little confused as to what my approach should be.
Can I use JQuery, PHP and MySQL together or can my problem just be achieved using just PHP and MySQL. Please note, the fields will be stored in my MySQL database already, I just them to be generated after the selection from the dropdown menu has been displayed.
No source code sorry everyone as I'm just asking about the approach I should take. I hope I've provided enough detail!
There is no way to achieve this solution with just PHP & MySQL. You would need to Ajax/JQuery to achieve this. Based on user's selection you need to send the data to server using JQuery Ajax and then server will send back the response that you need to show to the user.
This link should help you.
i think,
actually you can achieve this by only using php and mysql, jquery makes you easier when you play with DOM, with out it you can achive that goal, but need extra work with native javascript.
CMIIW
I am trying to create a website that will allow users to login with their email and password. To prepare for this I am attempting to learn the languages that will best help me. I have a knowledge of HTML/CSS and am wondering whether to learn PHP or Javascript first. I understand that PHP is server based, does this mean that I will need to provide a server that, for example, their user names/passwords will be stored on? Also, I have been told that Javascript will sometimes be used in PHP, is it necessary that I learn Javascript first?
The only way to secure a login is to have the server do the validation. If you do it on the client, anyone can view the page source and see the code. They can even execute arbitrary javascript code, bypassing any client-side validation.
You will need PHP & some database (MySQL is most common) to create a login system.
You will need to use forms, send the
username and password to a script.
Receive the data and compare the
username & password to the one in
the database
If the login credentials are valid,
create a session variable that keeps
them logged in.
It is worth noting that doing things with only HTTP instead of HTTPS allows hackers (read: Script Kiddies) to hijack your user's sessions if they are on an unsecured network such as open Wi-Fi in Starbucks.
As you say, PHP is server side (executed on a web server), whilst JavaScript is executed on the client side (in the web browser). JavaScript can't be used "in" PHP, but it's often used to improve the user experience on many web sites. However, for the majority of purposes, it can be considered as a separate concern to PHP.
However, let's take a step back. If you think about your problem, you'll probably come to the conclusion that you need to store the information about the users somewhere on the server side, so that you can check the information supplied in the form against the user data you have stored to see if the details are correct. (Once you learn more, you'll most likely decide to store the information in a database, such as the popular MySQL, which PHP can talk to and interrogate using the SQL language.)
However, at this stage of things I'd recommend getting hold of a good book on PHP, or perhaps having a look at the introduction section of the PHP manual, which contains some basic tutorials.
Yikes.
At the minimum you want some sort of server-side language. I'd also highly recommend using a pre-built system, depending upon needs, since security is not easy.
JavaScript is not required.
You will need a host to use for a webserver and for a DB, this can also be your pc check out wamp
Javascript is not required, but using jQuery can certainly help your UI look a lot better. There are a lot of very simple examples of forms (including a login form) inside the jquery site.
Javascript is client-side, it can't auth a user alone, that's were you need PHP. Usually web auth pages don't need javascript, only a client side language, like PHP.
Start with PHP. Javascript is occasionally used for working with PHP on the page (ie., get database info without having to click a "submit" button or navigate to another page.) It is used, for example, to make people's Facebook statuses appear on your homepage in real time. I programmed PHP for years and haven't learned any JS until just recently, so don't worry about it for now.
The posted tutorials (especially on w3) are excellent. There is an excellent tutorial that describes exactly what you are trying to do at devarticles, but it requires a VERY basic understanding of SQL. The example in the tutorial is also fairly unsecure, but it'll teach you the basics of working with MySQL and PHP sessions.
You'll need to run the scripts on a sever that has PHP and MySQL on it, so pay attention to these things when you're looking for hosting.
i have a page on which i have some rating function like people who like the post can rate up or who don't can rate down.
on that link im calling a php file with some parameters passed in the anchor tag. Then in that php file im saving that rating with +1 or -1 (whichever is the case) in the database and after doing that im redirecting to that first page from where we have rated.
Now this whole function is reloading my whole page which i dont want.Is there any way with which i can do this rating without reloading the page,i want that when a person clicks on rate then just after click the rating should be shown according to what the user just did(+ or -) and that too without reloading the whole page.Is there any way to do that in php???????
Yes, it's called "Ajax". However, you don't do this on the server-side with PHP, you do it on the client-side with JavaScript. There are plenty of tutorials around, I suggest you take a look.
Note that there are many JavaScript libraries out there to make this extremely easy. I'd recommend taking a look at jQuery because I've personally found it to be the easiest to learn and use.
It seems a few answers have already been posted recommending different libraries. If you would like the avoid the (admittedly minimal) overhead of an included library, the following tutorial shows how to use a simple XMLHttpRequest object.
http://www.xul.fr/en-xml-ajax.html
The "xhr.responseText" is what you would receive back from the php processing (which would typically be done in a small, single-purpose script seperate from the primary page).
You can do this using Javascript or AJAX. There are plenty of free scripts online that can help you to do this without building the whole thing from scratch.
This page (http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=364) has a good list of different star rating scripts you can choose from. You can Google for more.
Here's another relevant tutorial I came across when answering some other question:
http://docs.jquery.com/Tutorials:Getting%5FStarted%5Fwith%5FjQuery#Rate%5Fme:%5FUsing%5FAjax