0

I have a login.html in which the form is defined as follows:

<form method="post" action= "do_authorize.php"  name="lform">
  <span class="style1">First Initial Plus Last Name :</span>  
    <input type="text" name="user" size="25">
    <input type="submit" value="login">
</form>

My do_authorize is as follows:

<?
session_start();

require('../databaseConnectionFileFolder/dbconnection.php');

$user             = $_POST["user"]; 

var_dump($user);

$_SESSION['username']=$user;

var_dump($user);

$sql="SELECT * FROM $table_name_users WHERE username = \"$user\"";

var_dump($sql);

$result=@mysql_query($sql,$connection) or die("couldn't execute query");

$num=mysql_numrows($result);
if ($num != 0) {

/*$cookie_name="$user";
$cookie_value="ok";
$cookie_expire=time()+86400;
$cookie_domain=".columbia.edu";

setcookie($cookie_name, $cookie_value, $cookie_expire, "/", $cookie_domain, 0);
*/
    print "<script>";
    print "self.location='somethingelse.php';";
    print "</script>";

} else {
echo "<p>you're not authorized";
}


?>

I have included var_dump($user); and var_dump($sql); at appropriate places and it doesn't seem to print the user value and sql. All it prints every time on the browser is the following:

"; print "self.location='somethingelse.php';"; print ""; } else { echo "
you're not authorized"; } ?>

I was referring to this post and I did the sanity check as mentioned in the following comment by Dan Nissenbaum and it works for me:

For sanity checking, does the same problem occur in an independent .php file in the same webroot - something simple like <?php $x = array(1,2,3); var_dump($x); ?>?
Community
  • 1
  • 1
Tan
  • 1,433
  • 5
  • 27
  • 47

2 Answers2

0

Try to write your php code inside

<?php //code ?>

instead of

<? //code ?>

And i guess a better alternative to print data is echo. Not print.

Siamak Motlagh
  • 5,028
  • 7
  • 41
  • 65
-1

First of all, let's enable showing errors, notices, etc.:

display_errors = On
display_startup_errors = On
error_reporting(E_ALL);

This way, if any notice is being emmited by PHP, you'll know.

Now, try this:

ob_start();  
var_dump($user);  
$out = ob_get_clean();  
echo $out;  

And tell us if it works.

Good Luck.

Vinicius Dias
  • 664
  • 3
  • 15