Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

secure php onclick

Posted on 2013-06-11
6
Medium Priority
?
255 Views
Last Modified: 2013-07-03
I am new to php and  mySql.

I have a calendar that is generated by PHP, for a particular userID.  When someone clicks a date on the calendar, I need a "detail" page to open up, showing the detail for that date for that userID.  But if I use Javascript to handle the onClick, is that very secure?  Can't someone view the source and change the userID to something else to see someone else's detail?  But you can't handle client-side onClicks in the php page, so how is this done?
0
Comment
Question by:KCTechNet
  • 2
  • 2
  • 2
6 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39240249
Two things.  Why does a calendar pop-up need to be secure?  And onClick is a javascript event, nothing else.

If you are using 'userID's then you should be having a login.  If you have a login with a username and password, then you should be using sessions on the server to keep track of the users.  So even if that 'userID' is stolen, it should not work when that user is not logged into the application on the server.  And if you are using sessions to track your users, you can store the 'userID' there instead of putting in the HTML code.  You would then write the PHP code to use the 'userID' stored in the user's session to fetch the calendar data for that person.

And if security actually is important, your connection should be encrypted with an SSL/TLS certificate on your server to prevent people from reading your traffic on the network.
0
 

Author Comment

by:KCTechNet
ID: 39240260
So a session will stay active while I navigate through the various pages of the site?

I will start researching sessions.  any suggested links for beginners before I start my google exploring?

When I say secure, I wasn't thinking "extremely secure", I was just thinking that I didn't want to use a URl parameter or something "easy".  But I guess in the long run I should invest research time understanding encryption.
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 1000 total points
ID: 39240300
Sessions will stay active if you keep them active.  Here is everything you need to know:  http://us1.php.net/manual/en/book.session.php  The first most important thing you need to know about sessions is that session_start() must be at the top of every page which means that the pages in the session have to be PHP pages.  The default timeout is 24 minutes.  That means if there is no activity that resets the session timer in 24 minutes, then it is available to be expired.

And you don't have to understand encryption to use SSL/TLS.  You do have to buy the certificate and install it on your website.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1000 total points
ID: 39240963
You have a lot of moving parts here, and being new to PHP may somewhat complicate the work process.  This article teaches some of the ways to get started with PHP and SQL, and leads you to some learning resources.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html

HTTP is a client-server protocol.  The use of JavaScript can "blur" this fact.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/A_11271-Understanding-Client-Server-Protocols-and-Web-Applications.html

If your server performs some kind of client authentication, you can set the client-id in the session.  When there is a request for a calendar entry, your script can check the client-id and the calendar data base, and use a rules-based approach to determine whether it is OK to display the calendar information.  This is not rocket science, but it's rather advanced design and programming.  You might want to have a data-base administrator help you set this up.

HTH, ~Ray
0
 

Author Comment

by:KCTechNet
ID: 39297982
Thanks for your help.  Sessions and cookies were definitely the solution.  And Ray, your articles on Login and Registration have been extremely helpful.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39298007
Thanks for the points and for your kind words! ~Ray
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question