The requested URL [filename.php] was not found on this server - php

<?php
echo "hello";
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="/one1.php" method="POST" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit"/>
</form>
</body>
</html>
`
I have a Url on my server
This url is working. I have written echo "hello" in this.
but when i go through in this url i have written the html file upload code
It says The requested URL [one1.php] was not found on this server.
I checked my file_upload is on.

Make sure your 'action' attribute on form tag is set to /one1.php

I got the answer I contact the hosting team. They told to off the mod security in my panel and things the worked.

Related

No echo for form data using GET method in PHP

Fairly new to PHP. Have been trying a simple program to get data from 2 fields and display it using GET method.
Heres the HTML code
<html>
<head>
<title>Simple Form</title>
</head>
<body>
<form action="send.php" method="get" id="sample">
Name:<input type="text" name="user"/>
Message:<input type="text" name="message"/>
<input type="submit"/>
</form>
</body>
</html>
Heres the PHP code:
<html>
<body>
Welcome <?php echo $_GET["user"]; ?>
Message <?php echo $_GET["message"]; ?>
</body>
</html>
The GET method fetches the data as a QueryString in address bar of browser, but doesn't display anything in browser window.
The code works perfectly. Reinstalling WAMP server solved the issue.
You need to start the server.
Go to your directory where the index.html file of your website lives, then run the command line php -S localhost:5000.
5000 is the port where php is listening to, you can put any value there....
Install php if you haven't.. Or Wamp

POST and GET are unable to display user input values from HTML form

I have just started to learn HTML and PHP, but have run into a road block while following beginner tutorials. I am attempting to have the user input numbers into a form on the HTML page, then press submit to redirect to a PHP page that displays the values. The PHP page shows up and successfully displays prepared text but displays nothing for the values.
HTML code:
<html>
<body>
<head>
<title>Practice Page</title>
</head>
<h1>Numbers</h1>
<p>Put numbers in the boxes</p>
<form action="welcome.php" method="post">
NumOne: <input type="text" name="oynumone"><br>
NumTwo: <input type="text" name="oynumtwo"><br>
<input type="submit" value="Submit" id="SubmitRegister" name="submit" />
</form>
</body>
<html>
PHP code:
<html>
<body>
Number one is <?php echo $_POST["oynumone"]; ?><br>
Number two is <?php echo $_POST["oynumtwo"]; ?>
</body>
</html>
Both of the files are simply in the same folder in my documents. I understand that I need a server to host PHP content; I have downloaded MAMP for this, but I don't yet understand how to use it.
Any help would be most appreciated.
Store both file name with .php extension AND/OR update Welcome.php like below -
Welcome.php
<?php
if isset($_POST['submit'])
{
$oynumone = $_POST['oynumone'];
$oynumtwo = $_POST['oynumtwo'];
echo "Number one is ".$oynumone;
echo "Number two is ".$oynumtwo;
}
?>
Also check this

Upload file doesn't neither try to upload

I have a very simple script:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<!-- this is up.php -->
<form action="up.php" method="post" enctype="multipart/form-data">
<input type="file">
<input type="submit">
</form>
<?php print_r($_FILES); ?>
</body>
</html>
When I select a file and I click on "Submit" the page is istantly reloaded and nothing happens.
I'm trying with this little script because in a more complex page with other fields everything works well except for the file form. I mean, the database is filled with all the informations provided by my form, but images are not uploaded.
The problem is that the page neither try to upload them, I mean, it should upload them (see the percentage on bottom of page) and then pass it to PHP.
In my case instead the page is istantly submitted and reloaded without the attempt of load pictures.
I have other scripts on my server that upload images, and them works.
Why this one does not work? Thanks.
Edit: live demo here:
http://allise.net/up.php
Actually your file needs to be named most probably.
Try
<input type="file" name="file">
or whatever is set in your up.php file
You need <form method="post" ...> for the form to work.
And the file input should have a name attribute.

PHP script not returning a variable

I've taken the following code and placed them in their respective files. I've opened up register.html in Firefox and after entering the required details to the form it loads welcome.php albeit with out the entered information. The loaded page simply reads: "Welcome! You are years old!"
Both files are stored in the same folder.
Any suggestions on what I'm doing wrong?
register.html
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html>
welcome.php
Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years old.
</body>
</html>
For Apache:
1) Ensure the mime module is on.
2) Try making an .htaccess file in the same directory, with the following contents:
AddType application/x-httpd-php .php
This will only work if the rewrite module is on.
3) Otherwise, if you have access to the httpd.conf file, try adding that line somewhere in it, without the .htaccess file.
Make sure to restart the server any time you make changes to httpd.conf.
Edit:
I should have also mentioned to view source of the page, to see if the PHP code is in it. which would make these steps necessary.
Another troubleshooting technique is to add <?php error_reporting(E_ALL); ?> at the top of the page, in case PHP actually is running and since there are no errors. If it is disabled, it will enable reporting an Undefined index notice. It seems highly unlikely that it would be the case, but it also seems like a useful step that could help us understand exactly what's going on. Then again, I'm pretty sure PHP just isn't executing.
Close your body tag.
<body>
not
<body
I used the code as you posted it exactly, even with the broken body tag, and it still worked.
You should take a look at your apache installation and check that it's working correctly.
I'd recommend you run a simple phpinfo test, which is basically a document (ending with .php) with only this in it:
<?php phpinfo(); ?>
You can use this
<?php
if ($_POST) {
extract($_POST);
if (!empty($fname) || !empty($age)) {
echo 'First Name: '.$fname.' Age: '. $age;
} else {
echo 'Enter first name and age';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form</title>
</head>
<body>
<form action="" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html>

html form-php question

This is my html form and below this i included my php text.
But I am not getting correct output,i don't no where the problem is ?
I also included the output ,please suggest me what shuld i do?
<html>
<head>
<title>
Entering data into text
</title>
</head>
<body>
<h1>
Entering data into text
</h1>
<form action="text.php" method="post">
What is ur name ?
<input type="text" name="data" />
<input type="submit" value="send" />
</form>
</body>
</html>
This is my php text:
<html>
<head>
<title>
Reading data from textfields
</title>
</head>
<body>
<h1>
reading data from text field
</h1>
Thanks for answering,
<?php echo $_POST["data"];?>
</body>
</html>
Output:
reading data from text field
Thanks for answering,
problem is that ,data send is not included after response of sever
please help me as fast as possible
I can only speak for my own experience, but this works on my server. I'd suggest, then, that one of the following is true:
Your server isn't set up to handle php (though this would surprise me), also, as #gAMBOOKa noted (in the comments), if your server's not set up to handle php the script wouldn't output anything other than the raw text-contents of the php script, literally "<?php echo $_POST["data"];?>".
You're trying to access the pages through the filesystem (file:///path/to/file.html), rather than through your server (http://localhost/file.html).
If '2' is correct, move your web-page and php script into a directory within your server's document root, on *nix this could be something like /var/www/directoryName/ and access the page via http://localhost/directoryName/dataEntryForm.html. If you're on Windows, with IIS it could be C:\inetPub\directoryName\ accessed, as above, with http://localhost/directoryName/dataEntryForm.html.
Incidentally, please forgive me for not linking to a demo of the page running, it's just that I'd prefer not to run the risk of exposing my server to, presumably, vulnerable scripts.
Your full code is like this and I tested it, working perfectly.
<html>
<head>
<title>
Entering data into text
</title>
</head>
<body>
<h1>
Entering data into text
</h1>
<form action="text.php" method="post">
What is ur name ?
<input type="text" name="data" />
<input type="submit" value="send" name="btn_save" />
</form>
</body>
</html>
text.php
<?php
if(isset($_POST['btn_save']))
{
$data=$_POST['data'];
}
?>
<html>
<head>
<title>
Reading data from textfields
</title>
</head>
<body>
<h1>
reading data from text field
</h1>
Thanks for answering,
<?php echo $_POST["data"];?>
</body>
</html>
working perfectly.

Categories