Jump to content

Not responding when register_globals is turned off


Bickey

Recommended Posts

Why won't this code work when register_globals is turned off (works fine when register_globals is on though).

 

<?php
$link = mysql_connect("localhost","un","pw");
mysql_select_db("the_db");

$username = $_POST['usernamex'];
$surname = $_POST['surname'];
$email = $_POST['email'];

$result =sprintf("SELECT * FROM tbl WHERE username ='%s' || email = '%s'", mysql_real_escape_string($username), mysql_real_escape_string($email));
$resultfin = mysql_query($result);
if (mysql_num_rows ($resultfin) > 0){
$register = "Retry.";
echo($register);
} else {
$go =sprintf("INSERT INTO tbl (username, email, surname) VALUES ('%s', '%s', '%s'", mysql_real_escape_string($username), mysql_real_escape_string($email), mysql_real_escape_string($surname));
$resultg = mysql_query($go);
$register = "Successful.";
echo($register);
}
?>

 

Thanks,

Bickey.

which by the way should *NEVER* be enabled.

 

cannot emphasis this enough.

 

Any ideas on why is this happening?

 

The code looks fine. Try enabling logging and errors?

 

EDIT: Is this line intentional?

 

$username = $_POST['usernamex'];

 

should it be $_POST['username'] ?

is there any other settings which I adjusted might be forcing to stop this code functioning? Truly appreciate your support.

 

Set as ON

engine On 

short_open_tag On

allow_call_time_pass_reference  On

display_errors  On

file_uploads  On

allow_url_fopen On

allow_url_include  On

 

Set as OFF

asp_tags Off

output_buffering Off

zlib.output_compression Off

implicit_flush  Off

safe_mode Off

safe_mode_gid Off

expose_php  Off

display_startup_errors Off

log_errors Off

ignore_repeated_errors Off

ignore_repeated_source Off

report_memleaks Off

track_errors Off

register_globals  Off

register_argc_argv  Off

magic_quotes_gpc Off

magic_quotes_runtime Off

magic_quotes_sybase  Off

sql.safe_mode Off

mysql.allow_persistent  Off

mysql.trace_mode  Off

There's probably something in your form that is affected by register_globals.

 

As thorpe already asked, what debugging have you done to find out exactly at what point your code and data has the expected values and exactly at what point they don't. I can guarantee that the problem is somewhere between those two points.

EDIT: Is this line intentional?

 

$username = $_POST['usernamex'];

 

should it be $_POST['username'] ?

 

Have you addressed this? Is there a actually form field with the name="usnernamex" attribute, or is that a typo?

Someone already suggested the problem could be your form. Posting all the code that reproduces the problem would be the quickest way of getting a solution. We could see exactly what you are doing that is being affected by the register_globals setting.

Thanks.

 

This is the exact script which is in my php file. The data is being to this file to pass them over to the mysql database.

 

<?php
$link = mysql_connect("localhost","un","pw");
mysql_select_db("the_db");

$result =sprintf("SELECT * FROM tbl WHERE username ='%s' || email = '%s'", mysql_real_escape_string($username), mysql_real_escape_string($email));
$resultfin = mysql_query($result);
if (mysql_num_rows ($resultfin) > 0){
$register = "Retry.";
echo($register);
} else {
$go =sprintf("INSERT INTO itc_applicants (username, password, surname, firstname, nickname, company, street, suburb, postal, phone, email, product, status, id) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'", mysql_real_escape_string($username), mysql_real_escape_string($watchword), mysql_real_escape_string($surname), mysql_real_escape_string($firstname), mysql_real_escape_string($nickname), mysql_real_escape_string($company), mysql_real_escape_string($street), mysql_real_escape_string($suburb), mysql_real_escape_string($postal), mysql_real_escape_string($phone), mysql_real_escape_string($email), mysql_real_escape_string($product), mysql_real_escape_string($status), mysql_real_escape_string($id));
$resultg = mysql_query($go);
$register = "Successful.";
echo($register);
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.