Jump to content

[SOLVED] inside .. outside IF statement problem


alvinchua

Recommended Posts

if you notice there is 2 echo.. one is before if and another is inside if statement .. the before if statement will echo the $Username2 value and ...the echo inside the if statement will not echo the $Username2 value ... the $Username2 is pass from a .php to this .php form how to make the value is available inside the IF statement ? pls advice

 

<?php
$Username2=$_POST['username'];
//echo $Username2;
if (isset($_POST['enter']))
{
echo $Username2;
$year  = $_POST['select'];


echo $year;
echo $myrow["Year"];
$Year = $myrow["Year"];

$query2="SELECT * FROM transaction where Year = $year";

cant also .. the variable only can be display outside the if ... this is some code from login

 


if (mysql_num_rows($result) == 1) {
	// the user id and password match, 
	// set the session
	$_SESSION['db_is_logged_in'] = true;

	// after login we move to the main page
	header('Location: transaction.php');
	exit;
} else {
	$errorMessage = 'Sorry, wrong user id / password';
}

include 'library/closedb.php';
}
?>
<html>
<head>
<title>Basic Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
if ($errorMessage != ' ') {
?>
<p align="center"><strong><font color="#990000"><?php echo $errorMessage; ?></font></strong></p>
<?php
}
?>
<form action="transaction.php" method="post" name="frmLogin" id="frmLogin">
<table width="400" border="1" align="center" cellpadding="2" cellspacing="2">
  <tr>
   <td width="150">Username</td>
   <td><input name="username" type="text" id="username"></td>
  </tr>

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.