Thread: Php example

Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    244
    Rep Power
    12

    Php example


    Trying to reference this post....the code in the first entry you read...I can follow it and everything....

    http://forums.devshed.com/php-faqs-and-stickies-167/how-to-program-a-basic-but-secure-login-system-using-891201.html

    But I am having a hard time getting this to actually work....I assume that I have to create an html page and then place the code in that?

    have all the php files created and then created a HTML page and simply right clicking it and open in CHROME

    Can anyone help....
    I did create a .html page and pasted some code in it (see below) but its moving me to a page and displaying all the php code in the login.php page..WHY...please help if you can...trying very hard to learn here.
    Thanks

    Code:
    <!DOCTYPE html>
    <html lang="en">
    
    
    <head>
            <meta charset="utf-8">
            <title>Hello World</title>
        </head>
        <body>
    		<h1>Login</h1> 
    		<form action="login.php" method="post"> 
    			Username:<br /> 
    			<input type="text" name="username" value="<?php echo $submitted_username; ?>" /> 
    			<br /><br /> 
    			Password:<br /> 
    			<input type="password" name="password" value="" /> 
    			<br /><br /> 
    			<input type="submit" value="Login" /> 
    		</form> 
    		<a href="register.php">Register</a>
        </body>
    </html>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,619
    Rep Power
    595
    Probably because PHP is not installed/enabled on your httpd server.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    244
    Rep Power
    12
    duh that would make sense.....
    is it a simple install? is that going to interfear with IIS, existing websites etc I am running on the server?
    do you have an idea of what exactly i have to install?
    Thanks
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,619
    Rep Power
    595
    Try here.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    244
    Rep Power
    12
    If I have IIS and a couple websites running on this server will installing PHP cause any issues?
  10. #6
  11. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Why do you use a live server for testing??

    Install XAMPP on your local computer, start it, and you're done.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    244
    Rep Power
    12
    So if I install that I install php and MySQL and pretty much everything in need to create and push the web site? Sorry for the stupid questions here....

    Still quite confused...looking to create an HTML 5 app that allows for user login, thats why I was using the example i posted... and that example uses php..I assume I use HTML 5 as the front end and the php as the workhorse behind the scenes....
    Can you run php and javascript at the same time?

    I guess I can install locally...so this is a one stop shop for what I need to start...just dont want to get to far into it and realize that I have to write all my code over.

    Only one server available to me to get this out to other departments...this server is running another application, although I have successfully installed a silverlight app on it and its working fine....ALL within our firewall not public...
    Last edited by jaykappy; February 1st, 2013 at 12:51 PM.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,619
    Rep Power
    595
    PHP is server side and Javascript is client side (browser). One has nothing to do with the other. PHP outputs HTML to a browser while Javascript runs in the browser.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    244
    Rep Power
    12
    1. So if my target was tablets/phones (android and IOS) is this the right path...
    Using HTML 5 with php and java script. From what I understand one application will cross both Android and IOS

    2. AND installing XAMPP... this gets me going with a development environment... Using IIS, php, and using MYSQL for the db locally...I supposed I can simply copy this to the live server (that contains XAMPP) and go live.

    3. so a website would run a mixture of both php and JS or one or the other....

    Just want to make sure that I dont go down a path and invest time only to find out I should have taken another path.

    Trying to make a web site that is accessible by PC, android and IOS.

    Thanks
  18. #10
  19. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    XAMPP is an installer package that includes Apache, MySQL, and PHP. Apache is an alternative to IIS - you would not run Apache and IIS on the same server (in fact, you can't, unless you run one on a non-standard port).

    The point of XAMPP is to let you set up a local development environment on some machine that is not your production server. For your production environment, if you want to continue using IIS, you would install PHP and MySQL but not Apache. Installing PHP and MySQL and getting them configured to work with a web server like IIS or Apache is not the easiest thing to do on Windows, which is why XAMPP is normally recommended for development environments.

    Installing PHP or MySQL (or anything actually) does have the potential to disrupt a server, which is why you shouldn't use a production machine to learn how to do it. XAMPP won't help you get PHP and MySQL working with IIS.

    You can build a complete application with HTML, PHP and MySQL. HTML and HTML5 are the same thing, except HTML5 has a few additional features which you probably won't use much, if at all. An application built using HTML will work on any device that has a web browser, which is most everything.

    JavaScript and CSS can be used to significantly enhance the client-side part of the application, but neither are required. Virtually any device that supports HTML will also support JavaScript and CSS.

    HTML is a requirement for building browser based applications, but PHP and MySQL are not. There are various server-side languages you could use instead of PHP (Python, Ruby, Perl, Java, C++, ASP.NET, etc.) and there are various databases that you could use instead of MySQL (MSSQL, Postgresql, Oracle, etc.).

    You could actually use JavaScript on the server-side (in addition to on the client-side), but that is not very common for production environments.

    So, bottom line, I don't fully know your constraints, but it is possible (and very common) to build an application that works on any device with a browser using HTML+JavaScript+CSS+PHP+MySQL.

    Comments on this post

    • jaykappy agrees
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    244
    Rep Power
    12
    Thanks for your explanation...sort of have a handle on that but that makes more sense in my mind...

    1. I have IIS running on my local machine so would just like to stay with that....so I would just install PHP and MYSQL?
    Thank make sense?

    2 .Although one more scenario...if I had Appache on my local machine and developed there would I have any issues moving the code to a production server that was running IIS instead of Appache

    Thanks again for your time and help
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,619
    Rep Power
    595
    1. Yes
    2. Possible but minimal.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    244
    Rep Power
    12
    Originally Posted by gw1500se
    1. Yes
    2. Possible but minimal.
    Are the calls to a db different when leveraging Apache vs IIS?
    I mean the code should not change?
    What would be the major differences that would cause a problem?

    Just trying to research and find the right solution before I invest time and resources to start this...thanks again
    Last edited by jaykappy; February 1st, 2013 at 04:10 PM.
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,619
    Rep Power
    595
    If you use PDO, the only thing that needs to change is the connect parameters. All the underlying OS interfaces are handled by the drivers and libraries.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2008
    Posts
    244
    Rep Power
    12
    The example gave me this...think they were using MYSQL

    my server name is mgtestserver

    Does the below make sense for IIS and trying to connect to SQL Server 2008 R2

    //MY SQL - EXAMPLE

    $username = "dbusername";
    $password = "dbpassword";
    $host = "mgtestserver";
    $dbname = "HTML5Testing";

    $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');

    $db = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password, $options);


    I AM TRYING THIS

    $username = "dbusername";
    $password = "dbpassword";
    $host = "mgtestserver";
    $dbname = "HTML5Testing";

    // SQL SERVER
    $options = array(PDO::MSSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');

    $db = new PDO ("mssql:host={$host};dbname={$dbname};charset=utf8","$username","$password", $options);
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo