$_POST not working perhaps

Alles, was PHP betrifft, kann hier besprochen werden.

$_POST not working perhaps

Postby laszlo673 » 20. August 2011 15:03

WindowsXP, Apache 2.2, PHP 5.3.6, MySQL 5.5.9 Community

This is the localhost\car\index.php

html>
<body>
<font size="5" face="sans-serif">Login</font>
<form action="login2.php" method="POST">
<table cellpadding="3" cellspacing="4" border="0">
<tr>
<td>
Username:
</td>
<td>
<input type="text" name="user" />
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<input type="password" name="pass" />
</td>
</tr>
<tr>
<td>
<input type="submit" name="submit" value="login" />
</td>
</tr>
</table>
</form>
</body>
</html>

localhost\car\login2.php file

<?php

include ("conn2.php");
echo "first ";
if ($_POST['submit']) {
//get data
echo "second ";
$username = $_POST('user');
echo "third ";
$password = $_POST('pass');
echo "fourth ";
if ($username && $password) {
echo "fifth ";
$query = mysql_query("SELECT username,password FROM users");
echo "sixth ";
while ($getrows = mysql_fetch_assoc($query)) {
echo "seventh ";
$dbuser = $getrows('username');
echo "eigth ";
$dbpass = $getrows('password');
}
if (($username == $dbuser) && ($password == $dbpass)) {
echo "nine ";
echo "Login Successful ...";
} else {
echo "ten ";
echo "Login Faiure ...";
}
} else {
echo "eleven";
die("The username and password fields should not be left empty");
}
}
?>

localhost\car\conn2.php file

<?php

$dbConnection = mysql_connect("localhost", "user", "userpw") or die(mysql_error());
mysql_select_db("mydata", $dbConnection);
$query = mysql_query("SELECT someThings FROM oneTable") or die(mysql_error());
echo "The table currently contains " . mysql_num_rows($query) . " row(s)"."<br />";

?>

The database access is good, because I have the number of the rows correct
If U can see, I put some echo to verify where is the problem
I erase the access.log and the error.log to have the minimum information of the problem
The last message I have is "second"
The next line is not executed from the login2.php
$username = $_POST('user');
I assume that the POST is not working between index.php and login2.php

Can U help me with this
I was looking for this on the net, but I have no answer.

the access.log is

127.0.0.1 - - [20/Aug/2011:16:22:47 +0100] "GET /car/index.php HTTP/1.1" 200 827
127.0.0.1 - - [20/Aug/2011:16:23:01 +0100] "POST /car/login2.php HTTP/1.1" 500 56
127.0.0.1 - - [20/Aug/2011:16:26:10 +0100] "GET /announce?info_hash=%a2%28O%3b%f1%879%92%db%f0%825I%06%1e%12GL%e7%f8&peer_id=M7-2-1--2bd9%3c%93%3f%b0.%92A%fd&port=11788&uploaded=565526528&downloaded=0&left=0&corrupt=0&key=20065F03&event=started&numwant=200&compact=1&no_peer_id=1 HTTP/1.1" 404 206
127.0.0.1 - - [20/Aug/2011:16:27:12 +0100] "GET /announce?info_hash=%ceqw%01A%5d%cc%92%8d%ab%12%ad%9a%93%eag%b0%10%8dR&peer_id=M7-2-1--2bd9%3c%93%3f%b0.%92A%fd&port=11788&uploaded=644473716&downloaded=0&left=0&corrupt=0&key=20065F03&event=started&numwant=200&compact=1&no_peer_id=1 HTTP/1.1" 404 206
127.0.0.1 - - [20/Aug/2011:16:30:34 +0100] "GET /announce?info_hash=Z%cd%09%8a%ea%e3%8b2x%be%c0%06%17%f1Fq%ae%e6%a7%fc&peer_id=M7-2-1--2bd9%3c%93%3f%b0.%92A%fd&port=11788&uploaded=542653533&downloaded=0&left=0&corrupt=0&key=20065F03&event=started&numwant=200&compact=1&no_peer_id=1 HTTP/1.1" 404 206
127.0.0.1 - - [20/Aug/2011:16:50:59 +0100] "GET /announce?info_hash=Z%cd%09%8a%ea%e3%8b2x%be%c0%06%17%f1Fq%ae%e6%a7%fc&peer_id=M7-2-1--2bd9%3c%93%3f%b0.%92A%fd&port=11788&uploaded=558414941&downloaded=0&left=0&corrupt=0&key=20065F03&event=started&numwant=200&compact=1&no_peer_id=1 HTTP/1.1" 404 206


and the error log

[Sat Aug 20 16:22:37 2011] [notice] Apache/2.2.19 (Win32) PHP/5.3.6 configured -- resuming normal operations
[Sat Aug 20 16:22:37 2011] [notice] Server built: May 20 2011 17:39:35
[Sat Aug 20 16:22:37 2011] [notice] Parent: Created child process 2796
[Sat Aug 20 16:22:38 2011] [notice] Child 2796: Child process is running
[Sat Aug 20 16:22:38 2011] [notice] Child 2796: Acquired the start mutex.
[Sat Aug 20 16:22:38 2011] [notice] Child 2796: Starting 64 worker threads.
[Sat Aug 20 16:22:38 2011] [notice] Child 2796: Starting thread to listen on port 80.
[Sat Aug 20 16:26:10 2011] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/announce
[Sat Aug 20 16:27:12 2011] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/announce
[Sat Aug 20 16:30:34 2011] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/announce
[Sat Aug 20 16:50:59 2011] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/announce
[Sat Aug 20 16:56:15 2011] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/announce
laszlo673
 
Posts: 3
Joined: 20. August 2011 14:30

Re: $_POST not working perhaps

Postby laszlo673 » 21. August 2011 08:03

I ceck the phpinfo and I see the followig:
REQUEST_METHOD GET

This is the problem? And if is, how can I solve this?
I'm new in php.
laszlo673
 
Posts: 3
Joined: 20. August 2011 14:30

Re: $_POST not working perhaps

Postby laszlo673 » 25. August 2011 04:57

SOLVED

I had alredy XAMPP, but I install apache and php.
It was obvious for me, becouse I have MySQL already installed before XAMPP.
laszlo673
 
Posts: 3
Joined: 20. August 2011 14:30


Return to PHP

Who is online

Users browsing this forum: No registered users and 21 guests