-2

How to input data using php?

I already created code to input data from <form></form> html to mysql using external php, but when I try to run it, it looks like this:

when i try to run it

<code>phpfile</code>

<code>htmlfile</code>

Krzysztof Janiszewski
  • 3,763
  • 3
  • 18
  • 38
  • honestly, i am new in php. and i already try to find that problem, but cant explain what is the error type. and my english is not to good. – Tanto Wijaya Jun 06 '18 at 06:31
  • 2
    are you running it on a server ? if no do it and verify the url – Steve Ruben Jun 06 '18 at 06:33
  • Your sever need to execute PHP not render it – Lex Jun 06 '18 at 07:00
  • 1
    Don't open a php file directly in your brower with file:// but run it from the server and browse it. Do never post code as image. That's a pain to read and we can't copy paste anything. – Cid Jun 06 '18 at 07:14
  • @Cid, thats work my friend, so what iam doing is pen the file directly, without file:// .. what a mistake iam doing here, but are u have a fast way how to run it direct. – Tanto Wijaya Jun 06 '18 at 07:37
  • I suppose you are using WAMP or LAMP on your computer. Navigate to `http://localhost/yourphpfile.php` – Cid Jun 06 '18 at 07:39
  • By the way, you forgot to edit your post in order to remove the screenshots of your code and copy/paste it. That's **really** a pain to read. – Cid Jun 06 '18 at 07:42
  • @Cid okay i have try to used `localhost/yourphpfile.php` and thats work. big thanks for you. okay i will edit it ASAP – Tanto Wijaya Jun 06 '18 at 07:55
  • Please do not add code as a picture. – Krzysztof Janiszewski Jun 06 '18 at 08:42
  • @KrzysztofJaniszewski okay man, i will edit my questi later, i know that not good – Tanto Wijaya Jun 06 '18 at 09:58

2 Answers2

0

The first thing to understand, php codes do not execute by your browser, it is executed on your server, so the first thing you need is a server.

By looking at your URL, I can see you are using XAMPP. Replacing everything before Resolusi2018 by just localhost would do the job.

Put your files into the root directory then access your page by entering localhost/Resolusi2018/root/php/ngetes.php in your browser.

Luca
  • 296
  • 2
  • 19
Siraj Alam
  • 9,217
  • 9
  • 53
  • 65
  • You know he is (kinda) using XAMPP right? Else I don't know why he would have XAMPP in his URL. I think he is just not running it properly – Luca Jun 06 '18 at 06:34
  • Yeah right, I think she is opening the page directly not from localhost. – Siraj Alam Jun 06 '18 at 06:35
  • 1
    @Luca, yes iam using XAMPP but, iam not running that with the localhost, just direct to the `.html` with direct click from the folder. okay, here i want to big thanks for u guys, this is look simple but like dangeours. hehehe, and btw iam news in this forum. so i really happy u guys can understand what i mean – Tanto Wijaya Jun 06 '18 at 07:47
0

Ok, so I think your URL is just wrong.

You are opening the file directly, and not from the localhost.

Try something like this: localhost/Resolusi2018/root/php/mgetes.php

If this is also not working, check if your XAMPP is actually running.

Luca
  • 296
  • 2
  • 19
  • ohhhh, thats so simple but so dangerous. okay .. now its work.. thansk u my friend.. without u guys, i cant try how my code work – Tanto Wijaya Jun 06 '18 at 07:39
  • @TantoWijaya Great to hear it helped you! If any of the answers work, please do not forget to accept one! it helps other people a lot to see what answer worked – Luca Jun 06 '18 at 07:41