Jump to content

Is Php And Mysql Really That Straightforward?


gameboyz

Recommended Posts

I'm planning to create an online petition site just for fun, I am halfway done learning PHP and not yet started on MySQL although I browsed through the tutorials (for MySQL under PHP's tutorial) several times. Just want to ask, is creating a PHP webpage with MySQL as straightforward as:1) PHP2) Database with tables, entries and stuffRegistering merely writes usernames and passwords to the tables, logging in merely verifies input in fields with database and sending a cookie to the browser?Or is there more to it?

Link to comment
Share on other sites

What you describe is the basic breakdown, yes.However, once you login, there's a need to maintain the user's session cookie. The actual cookie also needs to be unique so that no user can impersonate another. To help with that, there's PHP sessions, which are one of the most confusing parts of PHP programming... especially if you want to make secure applications with it.If your application doesn't require a login, just verifying the inputs, and adding them in the database is as straightforward as it gets.

Link to comment
Share on other sites

I want to create a simple PHP site after my exams in a couple of weeks :)I know of this free hosting site, but the thing is my plans to implement javascript are dashed - I forgot javascript already although I learnt it few months back. Is it normal to actually forget your codes and syntax after a few months? I hate to relearn everytime I want to use certain languages :)

Link to comment
Share on other sites

Is it normal to actually forget your codes and syntax after a few months?
It is if you don't keep practicing...
Link to comment
Share on other sites

It is if you don't keep practicing...
That explains it :) :) I'm a student, naturally I don't get to practice it often, but at least when I "re-learn" it it's easier than the previous time :)P/S: synook do you use j/s, php, css, etc frequently?
Link to comment
Share on other sites

Another thing regarding cookies:http://www.w3schools.com/JS/js_cookies.asphttp://w3schools.com/php/php_cookies.aspFrom the URLs above, PHP cookies are much more straightforward. Compare the part on retrieving cookies, the PHP one is a one line code:

echo $_COOKIE["user"];

while the javascript one is one chunk of mess:

function getCookie(c_name){if (document.cookie.length>0)  {  c_start=document.cookie.indexOf(c_name + "=");  if (c_start!=-1)	{	c_start=c_start + c_name.length+1;	c_end=document.cookie.indexOf(";",c_start);	if (c_end==-1) c_end=document.cookie.length;	return unescape(document.cookie.substring(c_start,c_end));	}  }return "";}

:) So are PHP cookies easier to deal with?

Link to comment
Share on other sites

PHP cookies are easier to deal with, generally, but you must remember to send them because outputting any content.If you're going to store passwords in databases, you should encrypt them. Otherwise, people won't trust you because you can see their passwords in your database, and also, if your database was hacked somehow the hacker would have everybody's password.

Link to comment
Share on other sites

PHP cookies are easier to deal with, generally, but you must remember to send them because outputting any content.If you're going to store passwords in databases, you should encrypt them. Otherwise, people won't trust you because you can see their passwords in your database, and also, if your database was hacked somehow the hacker would have everybody's password.
So as long as I use the PHP setcookie function before the html codes I'll be okay? Oh another thing. As mentioned here (http://www.w3schools.com/tags/tag_DOCTYPE.asp) under XHTML 1.0 Strict:
The markup must also be written as well-formed XML.
Is the XML referring to "written as well-formed XHTML"? Or is it saying to write the whole page in XML and then use XSLT to transform it into HTML?
Link to comment
Share on other sites

So as long as I use the PHP setcookie function before the html codes I'll be okay?
Yes
Is the XML referring to "written as well-formed XHTML"? Or is it saying to write the whole page in XML and then use XSLT to transform it into HTML?
XHTML is a form of XML. When you write XHTML, you are writing XML, so yes, the statement just means to keep your XHTML well-formed.
Link to comment
Share on other sites

YesXHTML is a form of XML. When you write XHTML, you are writing XML, so yes, the statement just means to keep your XHTML well-formed.
Why is XHTML considered XML? In XML you have to create your own tags, however in XHTML there are already pre-defined tags right? So why is XHTML considered a XML language?Edit: Is anybody willing to be my mentor? Add me on skype (fabianterh) if you're.. I'm looking for a mentor who I can ask any queries and get an answer asap :)
Link to comment
Share on other sites

Think of XML as "a set of rules for defining your own markup language". Anyone defining a markup language following those rules can be sure that generic XML tools will be able to get ahold their document.W3C are the creators of XML. They have also made themselves their own markup language following that previously defined set of rules - XHTML. They actually have quite a few others too - XSLT, SVG and MathML, to name a few.So, XHTML is XML with tags that were defined by its creators in terms of "what does this do?". In the same sence, you can create your own markup language (let's call it MyML) that will predefine your own tag names, doing some different stuff. What exactly would they "do" depends on what you do once you parse the XML document containing MyML markup. You do that wil an XML parser. An XML parser is also used by browsers to read XHTML* documents, after which they render a page based on the markup.*If served with the correct MIME type, but that's another question you're probably not yet ready to read the answer to. Leave this part for now, at least until the above sinks in.

Link to comment
Share on other sites

So as long as I use the PHP setcookie function before the html codes I'll be okay? Oh another thing. As mentioned here (http://www.w3schools.com/tags/tag_DOCTYPE.asp) under XHTML 1.0 Strict: Is the XML referring to "written as well-formed XHTML"? Or is it saying to write the whole page in XML and then use XSLT to transform it into HTML?
you should use the mysql function SHA(). it encrypts your password into a 40 character length string, and you cant decrypt it.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...