problems with php POST

hello, i?m new and i don?t understand a lot of this cms.

i have an issue whit my script: it alert me the input is null when they aren?t. so if you click register and you have completed all input it will alert you that you haven?t complete all box. can anyone help me , possibility for free ?


6th Sep 2010 at 3:14 PM   1704 Views

Hi Matteo,
can post u?r script at here ? Just post u?r script inside "[code] [/code]" tag…

6th Sep 2010 at 3:33 PM  

Hey matteo,
the function "filtra()" which u’ve used in u’r script, i think that is not a native PHP script. I think, that’s might have define in that "filtro.php" file.

Am i right ? If yes, then can u show us u’r "filtro.php" file code… ?

6th Sep 2010 at 4:32 PM  

sure, it’s a function for filter possibile exploit.
function filtra($testo) { // funzione che pulisce le stringe per prevenire exploit;
$array = array("", "?>", "", "", "", "", "", "", " $testo = str_replace($array, "", $testo);
}

?>
[/code]
OMG THE RETURN!

6th Sep 2010 at 4:41 PM  

Hope, now u can short out u’r problem… ;)
Any way, here is some info which will really help u in u’r work.
link: http://net.tutsplus.com/tutorials/php/getting-clean-with-php/

6th Sep 2010 at 5:13 PM  

What’s this matteo… ?

8th Sep 2010 at 12:34 PM  

Your site don’t allow over 5000 char.

8th Sep 2010 at 12:41 PM  

Check u’r mail & post u’r error report at here…

9th Sep 2010 at 11:02 AM  

Hi Matteo,
I feel u’ve some problem in u’r logic. SO, do one thing…

Just insert some dummy line like :    echo "All is well";  inside u’r registration script to detect how long u’r registration script is executing.

Ex:

Step-1
—————-
      echo "All is well";  //  it’ll help u to detect u’r registration script is really executing

include "config.php";
include "emailcheck.php";
include "filtro.php";
session_start();

if(isset($_SESSION[‘username’]) && isset($_SESSION[‘password’]))
{
  header("Location: index.php");
}
?>


Step-2
—————-
include "config.php";     
include "emailcheck.php";
include "filtro.php";
      echo "All is well";  //  it’ll help u to detect above 3 line will executing successfully & control coming to next line

session_start();

if(isset($_SESSION[‘username’]) && isset($_SESSION[‘password’]))
{
  header("Location: index.php");
}
?>

Similarly go step by step & try to detect the line from where u’r script is jumping out. This will definitely help to detect the error position. From me it’s getting difficult because due to some language problem in error code…

10th Sep 2010 at 10:59 AM  

thanks, i insert an echo whit variuous name in the script . i’m testing it.

10th Sep 2010 at 1:01 PM  

NOTHING .....

10th Sep 2010 at 8:48 PM  

Matteo, i don’t believe magic in codes… ;)
If u r getting error then there must have something going wrong some where in u’r script. OK, let me see once again to u’r script…

11th Sep 2010 at 1:41 AM  

Hey matteo, one thing i noticed in u’r registrati script that , from where u’r all those nested if are starting with this…

if($username == NULL
{
}
else
{
// This section is empty.  

But, there are nothing in it’s ELSE part. I mean, if user will not enter any thing in that username filed of form then u’r script has code to handle to those part but if one user will enter some thing in that username field then there is nothing in u’r code to handle that part…

11th Sep 2010 at 4:47 PM  

Awesome suresh, thanks a lot i resolved! Thanks!

11th Sep 2010 at 6:01 PM  

Wow!!!, glad to knew that. Now i can also sleep well… ;)

11th Sep 2010 at 8:56 PM  

Hi there, i’m came back to broke your relax :) i have a problem whit Session, it tell me this:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /homepages/35/htdocs/accedi.php:1) in /homepages/35/htdocs/accedi.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /homepages/35/htdocs/accedi.php:1) in /homepages/35/htdocs/accedi.php on line 2

i alredy now i can’t echo nothing before any header, but i didn’t find nothing ..


  session_start();
if(isset($_SESSION[‘username’]) && isset($_SESSION[‘password’])){
exit;
}


if (!empty($_SERVER[‘HTTP_CLIENT_IP’])) {
    $ip=$_SERVER[‘HTTP_CLIENT_IP’];
} elseif (!empty($_SERVER[‘HTTP_X_FORWARDED_FOR’])) {
    $ip=$_SERVER[‘HTTP_X_FORWARDED_FOR’];
} else {
    $ip=$_SERVER[‘REMOTE_ADDR’];
}

$lastdata = mktime();

if(isset($_POST[‘login’])){
$username= filtra(trim($_POST[‘username’]));
$password = filtra(trim($_POST[‘password’]));
$check_user_data = mysql_query("SELECT * FROM `members` WHERE `username` = ‘$username’") or die(mysql_error());
if($username == NULL OR $password == NULL){
$final_report="Accesso fallito: dati non inseriti.";
}else{
if(mysql_num_rows($check_user_data) == 0){
$final_report="Login failed!";
}else{
$get_user_data = mysql_fetch_array($check_user_data);
if($get_user_data[‘password’] !== $password){
$final_report="Login failed!";
}else{
$get_user_stato = mysql_fetch_array($check_user_data);
if($get_user_stato[‘stato’] == "0"){
$final_report="Failed: you are banned.";
}else{
$get_user_verificato = mysql_fetch_array($check_user_data);
if($get_user_verificato[‘verificato’] == "0"){
$final_report="Your account isn’t verified yet. check inbox.";
}else{
$start_idsess = $_SESSION[‘username’] = "".$get_user_data[‘username’]."";
$start_passsess = $_SESSION[‘password’] = "".$get_user_data[‘password’]."";
$update_ip = mysql_query("UPDATE `members` SET lastip =’$ip’ WHERE `username` = ‘$username’") or die(mysql_error());
$update_ip = mysql_query("UPDATE `members` SET lastdata =’$lastdata’ WHERE `username` = ‘$username’") or die(mysql_error());

$final_report=‘Please wait… .redirect’;
}}
}}}}
?>

thanks

30th Sep 2010 at 10:13 PM  

Hi Matteo,
That "headers already sent" error also shows due to unknown blank space which exist before HEADER. Check u’r "accedi.php" file’s 1st 3/4 lines(as error report showing error is coming from line-2) carefully for any unknown blank space.

1st Oct 2010 at 9:36 AM  

Mhhhh most likely you have reason, last night i made some correction ( including remove the blank line) and now it magically works. Thanks a lot Suresh, you have helped me another time

1st Oct 2010 at 10:51 AM