IE8 has no $_POST data - php

I am currently working on a login page, using Dreamveaver CS4.
My form looks like this (I have kept the code complete):
<form id="login" name="login" method="POST" action="<?php echo $loginFormAction; ?>"
enctype="multipart/form-data">
<input type="hidden" name="loginnow" id="loginnow" value="go">
<table border="0" cellpadding="5" cellspacing="0">
<tr>
<td rowspan="4"><img src="images/icons/login_icon.jpg" width="240" height="218" alt="login-icon"></td>
<td>Benutzername</td>
<td><input name="usern" type="text" class="fieldSm" id="usern"></td>
</tr>
<tr>
<td>Passwort</td>
<td><input name="passwrd" type="password" class="fieldSm" id="passwrd"></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="submit" type="submit" class="button" id="submit" value="Anmelden"></td>
</tr>
<tr>
<td colspan="2">Hier können Sie sich registrieren</td>
</tr>
</table>
</form>
Now the php script checks for the hidden field
<?php if (isset($_POST['loginnow'])) {
# do some DW magic ;)
}
?>
With Firefox it works nicely and I can login properly, however is fails with IE8.
So, I was checking with:
<pre>
<?php print_r($_POST); ?>
</pre>
This results in and empty array when using IE8. $_REQUEST only has only the PHPSESSID.
I have searched several sites, with no results or hints (mostly the issues are with graphical submit buttons).
If anyone could give a hint where my error is, I would be very grateful.

All of your pages are with the suffix php? are you using a mamp/wamp or real webserver with php?

Related

Displaying HTML form values on PHP

This is test.html
<!DOCTYPE html>
<html>
<body>
<form method="POST" action="test.php">
<table>
<tr>
<th>content_id</th>
<th>title</th>
<th>image</th>
</tr>
<tr>
<td><input type="text" name="content_id" size="26"></td>
<td><input type="text" name="title" size="26"></td>
<td><input type="text" name="image" size="26"></td>
</tr>
</table>
<input type="button" id="cancel" name="cancel" value="Cancel"> <a href="index.php"/></a>
<button type="submit" id="submit" value="Submit">Submit</button>
</form>
</body>
</html>
This is test.php
<?php
error_reporting(E_ALL);ini_set('display_errors','1');
echo $_POST["content_id"];
echo $_POST["title"];
echo $_POST["image"];
?>
I want to pass the form's value to the PHP and display it but it shows this instead.
EDIT: I apologize for the vague and confusing question, thanks for the assistance everyone!
An error (500) occurs because your syntax is invalid. You can't mix text and commands.
There are two methods of sending data to PHP; GET and POST. GET sends information in URL parameters, and POST sends data in headers. You must use the appropriate PHP method to get data in each format. Given you set the method in the HTML form as POST, you should use _POST in PHP:
<?php
echo "Welcome ".$_POST["content_id"];
echo "Welcome ".$_POST["title"];
echo "Welcome ".$_POST["image"];
?>
In the future, you should look at the error_log, or enable error reporting so that you can see the actual results from the PHP runtime. Details on this can be found here.
The 500 error is because Welcome is not executable PHP code. Put it outside the <?php ?> tags
Your form method is using GET, your test.php should be:
<?php
echo $_POST["content_id"];
echo $_POST["title"];
echo $_POST["image"];
?>
And your form misses its end tag and a submit button:
<form method="POST" action="test.php">
<table>
<tr>
<th>content_id</th>
<th>title</th>
<th>image</th>
</tr>
<tr>
<td><input type="text" name="content_id" size="26"></td>
<td><input type="text" name="title" size="26"></td>
<td><input type="text" name="image" size="26"></td>
</tr>
</table>
<button type="submit">Submit</button>
</form>
Here's the form screenshot: https://imgur.com/a/3ST9k
And here's the php script result: https://imgur.com/a/YUUl4

PHP: File upload move_uploaded_file() method not working for IIS7

When I was using XAMPP server and MySQL database that time it was working, but I have to use MSSQL database IIS7 server where its not working. See This is the html form:
<form action="bookentry.php" enctype="multipart/form-data" name="myForm" id="myform" method="post">
<table width="90%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td align="right">Book Image</td>
<td>
<label>
<input type="file" name="fileField" id="fileField" />
</label>
</td>
</tr>
<tr>
<td> </td>
<td>
<label>
<input type="submit" name="button" id="button" value="Add This Book Now" />
</label>
</td>
</tr>
</table>
</form>
And this the php code
<?php
$bid="MyImageName";
$newname = "$bid.jpg";
move_uploaded_file( $_FILES['fileField']['tmp_name'], "../inventory_images/$newname");
header("location: inventory.php");
exit();
?>
I don't understand the problem and where it occurs!
Check whether you've write permission to the folder in which you're trying to move that file.(inventory_images).
EDIT
as per your comment to check permissions in windows OS:
right click that folder go to properties and then go to security tab
From that you can also give the permission by simply checking the checkbox and then clicking on apply button.
Here is screen shot to help:

how to send data of all the forms in a page using one submit button?

Here is my index.php
<!doctype html>
<html>
<head>
<title>welcome to vikash general shop</title>
<link rel="stylesheet" type="text/css" href="css/table_styling.css">
</head>
<body>
<table>
<tr>
<td>Item</td>
<td>Amount(kg)</td>
<td>Amount(gm)</td>
</tr>
<tr>
<td>Sugar</td>
<td><form method="POST" action="process.php"><input type="text" name="sugar_amount_kg"/></form></td>
<td><form method="POST" action="process.php"><input type="text" name="sugar_amount_gm"/></form></td>
</tr>
<tr>
<td>Rice</td>
<td><form method="POST" action="process.php"><input type="text" name="rice_amount_kg"/></form></td>
<td><form method="POST" action="process.php"><input type="text" name="rice_amount_gm"/></form></td>
</tr>
</table>
<form method="POST" action="process.php">
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>
actually i want to send data of all the forms in page using one submit button it is not working. It's obvious because submit button is only sending it's own form tag(quite selfish :P). So i want to know how to send data of all the forms using one submit button...
or if you have any other solution for my code then please tell me...
Just make one form. Wrap your table with form tags, because it's all being processed by process.php anyway.
<form method="POST" action="process.php">
<table>
<tr>
<td>Item</td>
<td>Amount(kg)</td>
<td>Amount(gm)</td>
</tr>
<tr>
<td>Sugar</td>
<td><input type="text" name="sugar_amount_kg"/></td>
<td><input type="text" name="sugar_amount_gm"/></td>
</tr>
<tr>
<td>Rice</td>
<td><input type="text" name="rice_amount_kg"/></td>
<td><input type="text" name="rice_amount_gm"/></td>
</tr>
</table>
<input type="submit" name="submit" value="submit" />
</form>
You do not need to add the form tags multiple times. Just wrap it around the input fields and add the action attribute in it like so:
<table>
<form action="process.php" method="post">
<tr>
<td>Item</td>
<td>Amount(kg)</td>
<td>Amount(gm)</td>
</tr>
<tr>
<td>Sugar</td>
<td><input type="text" name="sugar_amount_kg"/></td>
<td><input type="text" name="sugar_amount_gm"/></td>
</tr>
<tr>
<td>Rice</td>
<td><input type="text" name="rice_amount_kg"/></td>
<td><input type="text" name="rice_amount_gm"/></td>
</tr>
<input type="submit" name="submit" value="submit" />
</form>
</table>
And then you can get the inputs in process.php as follows:
if(isset($_POST['submit'])){ //checking if form was submitted
$sugar_amount_kg = $_POST['sugar_amount_kg'];
...
}
Hope this helps!
This question has been asked a few times. Do a quick search and you will see ways of doing this with JS/jQuery. Examples here and here.
Doing it in one form really might make more sense though for your specific use.

$_SERVER['PATH_INFO'] ..Undefined index: PATH_INFO

I am using a code to be put as a header:
$fullurl=$_SERVER['PATH_INFO'];
echo '
<form action="'. $fullurl .'" method="POST">
<table width="1000" border="1" cellpadding="10" id="navigationBar">
<tr>
<td> Register</td>
<td> Control Panel</td>
<td> Donate </td>
<td align="right">name:<input name="name" type="text" /></td>
<td>password:<input name="pass" type="text" /> <input name="login" type="submit" value="Login" /> </td>
</tr>
</table>
</form>
';
I include the header across page files with the require once. What I want is that the fullurl variable to obtain the full url of the page it is "required_once" on, and when I click submit, I want it to redirect to the page the header is on.. I added the url onto the action of the form..
But what I get is this:
Undefined index: PATH_INFO
I tried to use those instead:
explode('/', substr(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),1));
$_ENV['PATH_INFO'];
But they didnt work too :(
<form action="" method="POST">
that's all
also, there is no point in echoing raw HTML
use this code instead of yours
?>
<form action="" method="POST">
<table width="1000" border="1" cellpadding="10" id="navigationBar">
<tr>
<td> Register</td>
<td> Control Panel</td>
<td> Donate </td>
<td align="right">name:<input name="name" type="text" /></td>
<td>password:<input name="pass" type="text" /> <input name="login" type="submit" value="Login" /> </td>
</tr>
</table>
</form>
You can also try:
<form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
<input type="submit" name="form-submit" value="Submit" />
This will cause the form to submit on itself (current page). Use a variable in your form to detect submission or 'regular page load'. E.g.
if (isset($_POST['form-submit'])){
//do stuff
}
In a more recent environment, with Apache / PHP-FPM you need to enable the following option in php.ini to avoid "Undefined index: PATH_INFO"
cgi.fix_pathinfo=1

Troubles with html-forms

index.php:
<form action="update_db.php" method="post">
<?php
require_once 'modules/' . $currentModule . '.php';
?>
</form>
modules/some_module.php
...
<input type="submit" />
...
update_db.php:
#extract( $_POST );
print_r( $_POST );
After loading index.php i see need form. But during submitting i'm coming to the same page (index.php). Why?
http:/****/admin/
Here is html-code generated: http://dpaste.com/93396/
It's so strange, but form generates 2 times... I removed all part of code and rewrited it. Now everything is fine. Thanks all.
I took a look at your site. Your form action is index.php and that is why you keep seeing the same page after you click submit. If your code above is correct, ensure that you do not have <form> tags in your module containing the submit button.
<form action="index.php" method="post">
<table align="center">
<tr>
<td>Логин: </td>
<td><input type="textfield" name="login" /></td>
</tr>
<tr>
<td>Пароль: </td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit" name="submit" value="вход" /></td>
</tr>
<table>
</form>
you have this:
<form action="index.php" method="post">
not this:
<form action="update_db.php" method="post">
Change it and your form will post to update_db.php

Categories