Php opens as Text when usign "send" [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
So, i've be reading a lot of post here, but as my english is not that good, i cant understand all of it.
Sorry if this has been asked here before AND ANSWERED.
My problem is that, when i launch my html file wich contains a form it opens fine... but when i click the "send" buton, it opens the post.php file as a text and doesnt launch it.
I've managed since reading your posts, that it could be a link problem and it was. If i open it from the html file, the php opens at "file:///C:/wamp64/www/Pagina/Insertar.php" (and it fails) but if i type "Localhost/Pagina/Insertar.php" it opens just fine and upload the //empty// data to my database.
What can i do to make the "send" button work? i mean, make it goes to localhost instead of file://c.
Thank you in anticipate.
( and "insertar.php" is in the same folder)

PHP scripts are only executed when loaded through a server. It sounds like you're using a relative URL for the action attribute, and loading the HTML page from a local file instead of the server. So you need to change the action to point to the server.
<form action="http://localhost/Pagina/insertar.php">

Related

How to I keep a log of urls when a link is clicked? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a link called "Click Me" on 100 pages on my website. When a person clicks this link, I need to be able to write the url of where the click came from into a txt file or send me an email everytime the link is clicked.
Any ideas?
Fragments of code are requested here, please update your question. I will give you an idea on how to acomplish that:
In my opinion the general idea that will work best is:
Monitor user click with jQuery only if content is Click me.
When content of click is "Click me" load some php file via Ajax that will monit the click
Load this file with some parameters (?referer=...)
PHP file will append this $_GET['referer'] to a txt file
Remember that user can manually scam Your clicks (go to php file, and refresh it). You must think of some anti scam filter (for example after clicking lock IP clicks for few seconds or add some random hashes / etc to Your url).
Hope it helps, for more info, please upgrade your question with some code.

How to use php in html coding to reduce no. Of .html files? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have made the structure of a website. I have made three .html files named index.html, blog.html, posts.html. index.html is the home page and on that page their is a link for blog.html on the blog.html page thier are some posts heading and i have connected one post to posts.html. But now i'm in trouble that if i have to made one .html file for each post then it would be very difficult so what should i do so that i have to make only one posts.html and anyhow connect it to a php file or something else so that i don't have to make many .html file for every post.
Can i use php for it, is their any command that--> if you click on this post then this page will open and if you click on another post then another page will open. By this i will give the command for all the posts and it will help me alot.
Thank you
Try file_get_contents php, or create a small ajax client to load html.
$your_html_file = file_get_contents('./test.html', FILE_USE_INCLUDE_PATH);

Is it possible to edit a php file from itself? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Is it possible to edit a php file from itself? I would like to have a php file that a user can log into with their e-mail address and password then give them a several fields they can edit. Upon submitting their entries the actual php file they used to submit info is updated.
Lets say there are three fields displayed once logged in...
1. Email (can not be read when rendered in a browser or via source code)
2. Password (can not be read when rendered in a browser or via source code)
3. Textarea (contents you submit in the textarea would be visible if you load page in browser, in addtion, a blank username and password field would be visible in a browser, so the owner could login to edit the file)
With this system the user would be able to edit their login information and change information displayed on the page when viewed through a browser. Using the email in the file I guess I could include a sendmail function should they forget their password.
Is this possible. If so, does anyone know of a simple script that I can use to get started?
You are are better off storing the information you want to change in another PHP file. Then loading/editing it on request.
Editing the file you are using can cause issues. You could also loose all of your code if something is injected that corrupts the formatting code.

How do I open an url in a new tab via php? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Go!
like this code but using php thanks
You can change location with php:
header("location:somewhere.php");
but in the same tab - php will not tell the browser to open it in new tab. This must be done by javascript after reloading by the header function, but you will not know if it will open in new tab or in new window anyway - it is up to the browser settings!
Remember that you cannot output even single character to the browser (no echo, no html tags) before calling header function.
I'm not really sure that's what you want it, but it is what I understood.
<?php
echo 'Go!';
?>
Did you know you can name a file .php and still have php and html code on it? you just have to put at the start and end of the code and then just write rest on html outside of those code brackets.

What is it called when you use the <script> tag to link to link to a php file? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Our site is linking to php files containing javascript, so the javascript can use php to get data from the database. Here's an example of how these files are linked:
<script type="text/javascript" src="http://www.our-site.com/javascript.php"></script>
My question is what is this called? I've tried using google to help me with coding issues, but it's hard when you don't know what to search for.
Server-side-generated JavaScript would be an appropriate description. It even shows up on Google autocomplete, and there are many results. I am not a fan of this pattern. I find that it is better to keep JavaScript on the view-side completely and just inject the values you need via an init method of some sort.
It doesn't have a special name when it's PHP.
Just make sure you set the header in the PHP file.
Header("content-type: application/x-javascript");
What you have there is nothing special. It's not named somehow. You just include the PHP file, the PHP file gets interpreted and generates any kind of output which then gets included as regular JavaScript.
If you have issues you might just open up the link to the PHP file and search for your problem there.

Categories