I've been trying to solve this same problem that the user has http://bytes.com/topic/php/answers/2068-form-post-doesnt-work . However, I don't know how he managed to fix it, he says "He just abstracted the $_POST as Request() and it worked.." Any idea how to do it? Thanks in advance!
how to abstract $_POST?
Collapse
X
-
Whats wrong with $_POST??
If you use function like Request, you will face a different problem, say if you send data in GET and POST method in the same request and somehow you have the same variable in uri and in post value with different value, your application will lost one value
$_POST and $_GET is global. From anywhere it can be used. -
One Solution is:
Code:function Request($var) { if(isset($_GET[$var])==true) return $_GET[$var]; if(isset($_POST[$var])==true) return $_POST[$var]; return ""; }
Creating another class or array is pointless because whether you want or not $_GET and $_POST is thereComment
-
Thank you for an immediate reply.. :D
umm.. still I can't get it to work.. here's a simple code that simply won't run :( .. It use to work when I'm using php4 but when I upgraded to php5.3, I can't get it to work.. Am I missing something?
# home.php
<form action = "logfilter. php" method = "POST">
Username: <input type = "text" name = "t1"/>
Password: <input type = "password" name = "t2"/>
<input type = "submit" name = "submit" value = "Log In" style="width:60 "/>
<input type = "submit" name = "submit" value = "Sign Up" style="width:60 "/>
</form>
# logfilter.php
<?php
include 'conn.php';
$user = $_POST['t1'];
$pass = $_POST['t2'];
$status = "Activated" ;
$query=mysql_qu ery("Select * from tbluser where username = '".$user."' and password = '".$pass."' and status = '".$status."'") ;
$result=mysql_f etch_array($que ry);
if($_POST['submit']=="Sign Up")
{
header('locatio n:signupform.ph p');
}
else if($_POST['submit']=="Log In")
{
if($user=="" or $pass=="")
{
?>
<script type = "text/javascript">
alert("Your Login Detail is Invalid");
window.location ="index.php"
</script>
<?
}
else if($user==$resu lt['username'] and $pass==$result['password'] and $status==$resul t['status'])
{
session_start() ;
$_SESSION['code']="User";
$_SESSION['id']=$result['id'];
header('locatio n:myaccount.php ');
}
else
{
?>
<script type = "text/javascript">
alert("Your Login Detail is Invalid");
window.location ="index.php"
</script>
<?
}
}
?>
It says "Parse error: syntax error, unexpected $end in C:\xampp\htdocs \fb\logfilter.p hp on line 46"Comment
-
Comment