0

I am trying to run a simple php code on my localhost and it seems to be acting wierd.

My HTML code

<html>
<head>
<meta charset="UTF-8">
<title>Cloud Computing</title>
</head>
<body>
<form action="url.php" method="post">
<table border="0">
<tr> 
    <td>Input</td>
    <td align="center"><input type="text" name="username" size="30" /></td>
</tr>
<tr>
    <td colspan="2" align="center"><input type="submit" value="Submit"/></td>
</tr>
</table>
</form>
</body>
</html>

my PHP code

<html>
 <head>
 <meta charset="UTF-8">
  <title>PHP Test</title>
 </head>
 <body>

<?php
date_default_timezone_set('America/Los_Angeles');
echo date_default_timezone_get() . ' => ' . date('e') . ' => ' . date('T');
?>


 </body>
</html>

My Localhost Screenshot

enter image description here

Tried

  1. http://howtoubuntu.org/how-to-install-lamp-on-ubuntu
  2. Ran php -r 'echo "\n\nYour PHP installation is working fine.\n\n\n";' Results in Your PHP installation is working fine.
  3. Restarted the server
  4. Referred Derek Banas's video on youtube and both the code seems fine.

Its weird as neither does it print the whole code and neither does it execute it.

Kindly help , I am using ubuntu 16.04, running my localhost from ubuntu itself.

I tried the solutions here too. Maybe I am doing something wrong (Newbie Alert !)

1 Answers1

2

The code was not an issue,

Just tried re-installing php as Ubuntu has moved to 7(even though I had 7)

1> sudo apt-get install apache2 php libapache2-mod-php

This seemed to work for me !

The link below helped . PHP script not executing on Apache server

Thank you all for your help. @Cyber_star "

I just ran the php code in my webserver and it worked so it has to do somthing with your webserver "

I followed your lead via this comment ! Thanks again!