Submit button just displays the .php file

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 5068 Views - Last Post: 04 August 2013 - 01:08 PM

#1 Hiatus  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 81
  • Joined: 27-May 09

Submit button just displays the .php file

Posted 02 August 2013 - 09:39 PM

Hey all,

Working on a website to learn and I made a login box and wanted to display the user's login name and password when the submit button is pressed.

HTML:
<html>
<head>
<title>TEST WEBSITE</title>
</head>

<body>
<div class="header">

<h1 id="welcomebanner">Welcome to my Website</h1>

</div>
<form class="loginbox" action="loginphp.php" method="POST">
	<h1><span class="log-in">Log In</span> or <span class="sign-up">Sign Up</span></h1>
	
	<p class="loginfield">
		<input type="text" name="login" placeholder="Username or email">
	</P>
	
	<p class="loginfield">
		<input type="password" name="password" placeholder="Password">
	</p>

	<div id="buttonzone">
		<input type="submit" value="Log In" id="submit">     <--- BUTTON IS HERE!!
		<a href="signup.html" id="signupbutton">Sign up</a>   
	</div>
</form>
</body>
</html>



The PHP:
<?php

$loginname = $_POST["login"];
$password = $_POST["password"];

echo $loginname;
echo $password;

?>



Any reason as to why when I click the submit button all I see on the new page is just my PHP code?

Thanks so much!

This post has been edited by Hiatus: 02 August 2013 - 09:41 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Submit button just displays the .php file

#2 Sho Ke  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 110
  • View blog
  • Posts: 250
  • Joined: 13-October 11

Re: Submit button just displays the .php file

Posted 02 August 2013 - 10:41 PM

If the PHP is showing up in plain text, it's likely you aren't going through the server at all. Does the address bar start with file:/// ? If you have your server setup on your current machine, make sure it looks something like localhost/login.php and NOT file:///C:/wamp/www/login.php etc.
Was This Post Helpful? 1
  • +
  • -

#3 nandureddy  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 129
  • Joined: 31-January 11

Re: Submit button just displays the .php file

Posted 02 August 2013 - 11:13 PM

I have tested your code and it works fine.
Check if your php server is running.
Was This Post Helpful? 1
  • +
  • -

#4 Hiatus  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 81
  • Joined: 27-May 09

Re: Submit button just displays the .php file

Posted 03 August 2013 - 07:55 AM

View PostSho Ke, on 02 August 2013 - 11:41 PM, said:

If the PHP is showing up in plain text, it's likely you aren't going through the server at all. Does the address bar start with file:/// ? If you have your server setup on your current machine, make sure it looks something like localhost/login.php and NOT file:///C:/wamp/www/login.php etc.



View Postnandureddy, on 03 August 2013 - 12:13 AM, said:

I have tested your code and it works fine.
Check if your php server is running.


Thanks so much guys.

I was just running it off my laptop :'(

I didn't know that I needed a server or something to run PHP (Complete noob here)

Is there a way for me to set up a PHP server for free or is this where webhosting comes into play?

Thanks again for the awesome catch!
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3322
  • View blog
  • Posts: 11,234
  • Joined: 12-December 12

Re: Submit button just displays the .php file

Posted 03 August 2013 - 08:17 AM

You can install a LAMP stack which includes MySQL, PHP, Apache Server, and a number of other tools. Basically, all you need in one setup.

There is one called XAMPP, WAMP (I believe targetted at Windows) and a number of others. I've used a few, they are very similar.

This post has been edited by andrewsw: 03 August 2013 - 08:20 AM

Was This Post Helpful? 1
  • +
  • -

#6 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 926
  • View blog
  • Posts: 3,205
  • Joined: 19-January 10

Re: Submit button just displays the .php file

Posted 03 August 2013 - 08:24 AM

Yes, actually. And there are tools to make it very easy. I was in the same boat as you and bought webhosting to first start coding on the web.

Download WAMP. It'll set up Apache (web server), MySQL (database), PHP (you know, lol), phpMyAdmin (web-based mysql manager), an a couple other tools. Just run WAMP and it'll be in your taskbar with a nice interface when you click on it.

It's the bomb. However letting other people access your stuff WILL require a webserver, unless you want to mess with port forwarding and running your laptop 24/7.

You can get pretty damn lenient web servers for free in fact. 1freehosting is the best I've found so far. I went from >$130/year hosting to them and it has been the best decision I've made so far lol. hell i get more services now than I did before.
Was This Post Helpful? 1
  • +
  • -

#7 Hiatus  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 81
  • Joined: 27-May 09

Re: Submit button just displays the .php file

Posted 03 August 2013 - 07:38 PM

View Postcreativecoding, on 03 August 2013 - 09:24 AM, said:

Yes, actually. And there are tools to make it very easy. I was in the same boat as you and bought webhosting to first start coding on the web.

Download WAMP. It'll set up Apache (web server), MySQL (database), PHP (you know, lol), phpMyAdmin (web-based mysql manager), an a couple other tools. Just run WAMP and it'll be in your taskbar with a nice interface when you click on it.

It's the bomb. However letting other people access your stuff WILL require a webserver, unless you want to mess with port forwarding and running your laptop 24/7.

You can get pretty damn lenient web servers for free in fact. 1freehosting is the best I've found so far. I went from >$130/year hosting to them and it has been the best decision I've made so far lol. hell i get more services now than I did before.


Thanks for the tip!

Quick question though, if I already have mysql downloaded/installed on my laptop should I uninstall that before starting the wampserver installation?

Edit: I got wampserver installed (I think...)

And so now my question is how do i get my files in the right locations/where do I put my files?

This post has been edited by Hiatus: 03 August 2013 - 07:52 PM

Was This Post Helpful? 0
  • +
  • -

#8 nandureddy  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 129
  • Joined: 31-January 11

Re: Submit button just displays the .php file

Posted 03 August 2013 - 09:45 PM

You should save the .php,.html files to the 'www' directory under the wamp installation folder.
Was This Post Helpful? 0
  • +
  • -

#9 Hiatus  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 81
  • Joined: 27-May 09

Re: Submit button just displays the .php file

Posted 03 August 2013 - 10:05 PM

View Postnandureddy, on 03 August 2013 - 10:45 PM, said:

You should save the .php,.html files to the 'www' directory under the wamp installation folder.


Easy enough!! :D

So when I edit my files I just open them through the www directory right? So c:/wamp/www/mystuffhere!!
Was This Post Helpful? 0
  • +
  • -

#10 nandureddy  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 129
  • Joined: 31-January 11

Re: Submit button just displays the .php file

Posted 03 August 2013 - 10:14 PM

Correct.
Was This Post Helpful? 0
  • +
  • -

#11 exiles.prx  Icon User is offline

  • D.I.C Head

Reputation: 65
  • View blog
  • Posts: 239
  • Joined: 22-November 10

Re: Submit button just displays the .php file

Posted 03 August 2013 - 10:40 PM

Just to quickly add on, Hiatus you should think about reading some material on configuring vhosts. It will be very beneficial in the long run.

Apache Virtual Host documentation: http://httpd.apache....ocs/2.2/vhosts/

This post has been edited by exiles.prx: 03 August 2013 - 10:44 PM

Was This Post Helpful? 0
  • +
  • -

#12 Hiatus  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 81
  • Joined: 27-May 09

Re: Submit button just displays the .php file

Posted 04 August 2013 - 08:09 AM

View Postexiles.prx, on 03 August 2013 - 11:40 PM, said:

Just to quickly add on, Hiatus you should think about reading some material on configuring vhosts. It will be very beneficial in the long run.

Apache Virtual Host documentation: http://httpd.apache....ocs/2.2/vhosts/


Thanks so much for the tip! I'll definitely be checking it out!

Just a question though, I'm using MySQL and that documentation is for apache right? Is the info applicable? Or do i have to seek out a MySQL tutorial or something?

I'm having trouble "turning on" the database. In the bottom right hand toolbar, the MySQL dolphin icon is red...
http://gyazo.com/f33...20794529e0a1c8b
Was This Post Helpful? 0
  • +
  • -

#13 Atli  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3715
  • View blog
  • Posts: 5,972
  • Joined: 08-June 10

Re: Submit button just displays the .php file

Posted 04 August 2013 - 08:20 AM

Apache is a HTTP server, MySQL is a database server. Two totally different things. Virtual hosts are a HTTP server thing; they have nothing to do with database servers like MySQL.

If you use that icon to turn the MySQL server on, does it do something? Does it pop up an error after a few seconds? - If you right-click the icon, does it tell you the server status in the context menu?
Was This Post Helpful? 0
  • +
  • -

#14 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5227
  • View blog
  • Posts: 27,006
  • Joined: 10-May 07

Re: Submit button just displays the .php file

Posted 04 August 2013 - 08:33 AM

This isn't a php issue, this is a web server issue.

Moving to Web Servers & Hosting.
Was This Post Helpful? 0
  • +
  • -

#15 Hiatus  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 81
  • Joined: 27-May 09

Re: Submit button just displays the .php file

Posted 04 August 2013 - 08:57 AM

View PostAtli, on 04 August 2013 - 09:20 AM, said:

Apache is a HTTP server, MySQL is a database server. Two totally different things. Virtual hosts are a HTTP server thing; they have nothing to do with database servers like MySQL.

If you use that icon to turn the MySQL server on, does it do something? Does it pop up an error after a few seconds? - If you right-click the icon, does it tell you the server status in the context menu?


Yes. It goes from Off -> Pending. Pending -> Off. Then the message:
http://gyazo.com/234...fca98bd8260adb3


View Postno2pencil, on 04 August 2013 - 09:33 AM, said:

This isn't a php issue, this is a web server issue.

Moving to Web Servers & Hosting.


Oops sorry about that! This kinda went off topic. Thanks for the thread move!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2