php - empty $_POST variables -
i know people had problem , many asked here no solution seems work me. have tried increasing post_max_size
etc. in php.ini
, found solution link remove line rewriterule ^(.*)$ http://www.whitemagicsoftware.com/$1 [r=301,l]
.htaccess
file can not find .htaccess
file in xampp
folder anywhere. looking solution 2 days , tried changing code nothing worked me. tried using $_get
, $_request
result same. can see values of variables being sent using firebug
variables empty. appreciated .
this code
<?php require ("database_connect.php");?> <!doctype html> <html> <body> <form method="post" action="<?php echo ($_server["php_self"])?>"> name : <input type="text" name="name"><br/> password : <input type="password" name="password"><br/> <input type="submit" name="login" value="log in"> </form> <?php //$name=$password="" ; if($_server["request_method"]=="post" , isset($_post["login"])){ $name = testinput($_post['name']); $password = testinput($_post['password']); echo $name."<br>"; }//if ends here //testinput function function testinput($data){ $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); }//testinput ends here if(isset($_post["login"]) && isset($_post["name"]) && isset($_post["password"]) && !empty($_post["name"]) && !empty($_post["password"])){ echo "name ".$name ."- pass ".$password."<br>"; if($result = mysqli_query($conn,"select * users" )){ //print "rows ".$result->num_rows."<br>";//number of rows if($result && mysqli_affected_rows($conn) >= 1){//if query successfull , has 1 or more 1 result //echo "you logged in<br>"; ($row = mysqli_fetch_row($result)); echo "$row[0] ".$row[0]."- $row[1] ".$row[1]."<br>"; if( $row[0]==$name && $row[1]==$password){ echo "welcome"; } }//if ends here /* free result set */ $result->close(); } else { print "wrong credentials "."<br>"; die(mysqli_error($conn)); } } //close connection $conn->close(); ?> </body> </html>
try change,
<form method="post" action="<?php echo ($_server["php_self"])?>"> <form method="post" action="">
Comments
Post a Comment