-6

i am trying to code a forum in php but whenever i try to register it returns the code i typed:

<?php
$username = $_POST["username"];
$password = $_POST["password"];

echo "register info : ";
echo $username. ;
echo $password. ; ?>

(this isn't the final code and is just a test to see if the code is working) but it should return what i inputted into the text box' for the username and password.

also dont know if this helps but the "wamp localhost server" i set up also isnt working i tried changing the port multiple times

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
  • 2
    if that's your real syntax; you can't just inject PHP into HTML markup tags like that. – Funk Forty Niner Apr 07 '18 at 14:45
  • I'm also wondering if you're trying to run this off as `file:///` rather than an explicit `http://` protocol(?). So, are you? – Funk Forty Niner Apr 07 '18 at 14:47
  • 1
    [Your starter for 1](http://www.php.net/manual/en/language.basic-syntax.phptags.php) – Mark Baker Apr 07 '18 at 14:47
  • The HTML/form is missing here, and details as to the server information. Check for errors; error reporting is there at your disposal, including `phpinfo()`. – Funk Forty Niner Apr 07 '18 at 14:52
  • i cant run in http:// because when i try my localhost server http://localhost:3306/ i get "This page isn’t working localhost sent an invalid response. ERR_INVALID_HTTP_RESPONSE" – TheEkhoedOne Apr 07 '18 at 14:54
  • 3
    3306 is almost certainly your MySQL server. You must run PHP code through the PHP interpreter to execute it. file:// will not work. – Peter Apr 07 '18 at 15:01
  • i looked it turned out to be localhost:3308 but that still didnt work – TheEkhoedOne Apr 07 '18 at 15:05
  • 1
    JUST USE `localhost` the default is PORT 80, ___as for ANY web server___ and you dont need to add that – RiggsFolly Apr 07 '18 at 15:21
  • it is not the default port because thats the default for Apache not MySQL also just typing localhost took me to microsoft.com – TheEkhoedOne Apr 07 '18 at 15:23
  • Correct, well you need to use Apache ( the web server ) When you come to use the database ( MySQL) you do that from within your PHP script, not via the URL in the browser – RiggsFolly Apr 07 '18 at 15:24
  • Not Found The requested URL /forum.php was not found on this server. Apache/2.4.33 (Win32) PHP/5.6.35 Server at localhost Port 8000 – TheEkhoedOne Apr 07 '18 at 15:26
  • Order of operations `browser > http://localhost > Apache > PHP > MySQL` In your Wamp Apache configuration check to ensure you have a configured virtualhost for your localhost, and `mod_php` is enabled. Otherwise your PHP code example will not help us to resolve the issue of it not working in your browser. Otherwise you would need to open a command line terminal and execute `php c:\wamp\www\path\to\script.php` – Will B. Apr 07 '18 at 15:28
  • Well if you moved Apache to listen on port 8000 use `localhost:8000` But WHY did you move it to port 8000 – RiggsFolly Apr 07 '18 at 15:28
  • because thats the port brackets suggested also i did put loaclhost:8000 – TheEkhoedOne Apr 07 '18 at 15:29
  • 1
    But it just causes these kind of problems! And who or what is `brackets` – RiggsFolly Apr 07 '18 at 15:30
  • the question is "what is brackets" and the answer is the software i use for web code – TheEkhoedOne Apr 07 '18 at 15:31
  • also wamp turns orange when the port is set to 80 – TheEkhoedOne Apr 07 '18 at 15:44
  • Ah well that at least thats a reason. I expect you have IIS installed. If you are not using it, uninstall it (MS for some reason install it on W10 by default) then Apache will be able to use port 80 as it should – RiggsFolly Apr 07 '18 at 15:53
  • im using windows 7 – TheEkhoedOne Apr 07 '18 at 15:54
  • Ok then the next most likely thing is that SKYPE is using port 80. You can reconefigure SKYPE in which case [have a look at this answer](https://stackoverflow.com/questions/21671456/wampserver-orange-icon/21678795#21678795), to find out how to reconfigure SKYPE so it does not use port 80 or 443 – RiggsFolly Apr 07 '18 at 15:58
  • Or just dont start SKYPE until you have started WAMPServer. SKYPE will then work out that it canot use port 80 and use another port automatically – RiggsFolly Apr 07 '18 at 15:59
  • i disabled IIS and Skype hasn't been opened on my computer in months, also do i need VS installed? – TheEkhoedOne Apr 07 '18 at 16:09
  • Not Visual Studio itself, but you do need all the MSVC Runtimes installed. See the post called `WAMPServer 3 All you need to know` on the [WAMPServer Help forum](http://forum.wampserver.com/list.php?2) – RiggsFolly Apr 07 '18 at 16:11

1 Answers1

1

PHP code has to be wrapped in a php tag like this.

You start the interpreter with a <?php and you stop it using ?>

<p>
<?php
    $username = $_POST["username"];
    $password = $_POST["password"];
    echo "register info : ";
    echo $username;
    echo $password;
?>
</p>
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • 1
    Bit of a Saturday treat. – Funk Forty Niner Apr 07 '18 at 14:48
  • @FunkFortyNiner Well you closed my last attempt at `Low Hanging Fruit` 10 seconds before I had finished typing the answer so thanks for the UV – RiggsFolly Apr 07 '18 at 14:49
  • It seems that this goes deeper, much deeper than any rabbit hole I've ever seen. – Funk Forty Niner Apr 07 '18 at 14:52
  • i did put at the end – TheEkhoedOne Apr 07 '18 at 14:52
  • I dont see it in your question? – RiggsFolly Apr 07 '18 at 14:52
  • @FunkFortyNiner How did you know that, before the comment was made. You are starting to frighten me a little. But thanks for the Rabbit Warren Warning – RiggsFolly Apr 07 '18 at 14:55
  • Call me "clairvoyant", or just "experienced" ;-) @Riggs in any case; I'm just weird like that. You know that. – Funk Forty Niner Apr 07 '18 at 14:56
  • focus and do the necessary, stop fighting. –  Apr 07 '18 at 15:04
  • @RiggsFolly you dont see it in my question because when i put it in the question stack overflow didnt allow it for some reason so i had to remove it – TheEkhoedOne Apr 07 '18 at 15:04
  • @TheEkhoedOne I think it was because it wasn't in a code block so it was rendered as it would have been HTML. You need to format code blocks. You should edit the question with your exact code. See https://meta.stackoverflow.com/questions/251361/how-do-i-format-my-code-blocks Additionally Riggs fixed your `echo` syntax which was incorrect and would have caused issues. – chris85 Apr 07 '18 at 15:06
  • @TheEkhoedOne Use https://stackoverflow.com/posts/49708531/edit to edit your question. – chris85 Apr 07 '18 at 15:14
  • @dean Who do you think is fighting? Not me an Funky I hope – RiggsFolly Apr 07 '18 at 15:18
  • @dean "Fighting"? huh?? Riggs, did I miss something here? Did I went and pull out my "Golden Gloves" or you without me/you knowing? Wow, I must be losing it. – Funk Forty Niner Apr 07 '18 at 15:29
  • ha haa haa haa haa you guys are truly funny, but please know that programming is not easy for some of us , please go easy when we ask a self explanatory question. –  Apr 07 '18 at 15:33
  • @dean I dont see any question that you asked. Did I miss something. And you look like a Senior Programmer to me – RiggsFolly Apr 07 '18 at 15:37
  • @dean about your *"please go easy when we ask a self explanatory question"* - Oh, so you think it's self-explanatory, I see. Well, I have news for you; it isn't and isn't *black & white*. You should think before acting. Same thing goes for [this comment](https://stackoverflow.com/questions/49708755/php-mysql-update-script-not-working#comment86431212_49708755) you left in another question. – Funk Forty Niner Apr 07 '18 at 15:38
  • 1
    @dean Funk and I just crack the odd joke now and again to relieve the boredom – RiggsFolly Apr 07 '18 at 15:39
  • @RiggsFolly may be you did. –  Apr 07 '18 at 15:44
  • Well, I won't argue with a senior/pro. – Funk Forty Niner Apr 07 '18 at 15:50