PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am having a problem with a php script I have re-used from a linux server to a windows server. I am getting the following error:
Notice: Undefined variable: submit in c:\program files\apache group\apache\htdocs\support\desk\dlogin.php on line 17
<?php
session_start();
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="Adobe">
<title>Welcome to iTouch Europe Support</title>
</head>
<?php
if (!$submit)
{?>
// some html stuff
<table width="689" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10"></td>
<td>
<form name="FormName" action="<?php echo $php_self; ?>" method="post">
<p><b><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="4">Please enter your Username and Password:</font></b></p>
<table border="0" cellpadding="2" cellspacing="2" width="271">
<tr>
<td colspan="2" bgcolor="#ff6600" width="275">
<div align="center">
<font size="2" color="white" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>The page you have requested is available to registered user only. If you are already registered, please enter:</b></font></div>
</td>
</tr>
// more html stuff
<?php }
else
{
include('connect.php');
$connection = @mysql_connect($host, $user, $pass) or die ("Unable to connect to database");
mysql_select_db($db) or die ("Unable to select database: $db ");
//etc.
//etc.
?>
<?php
session_start();
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="Adobe GoLive">
<title>Welcome to Europe Support</title>
</head>
<?php
$today = date("Y-m-d H-i-s");
?>
<?php
if (!isset($_REQUEST[ "submit" ]) )
{?>
//some html stuff
<form name="FormName" action="<? $_SERVER[ 'PHP_SELF' ] ?>" method="post">
//more html stuff
<?php }
else
{
//this is the bit I do not like the look of
$username = $_POST['username'];
$password = $_POST['password'];
include('connect.php');
$connection = @mysql_connect($host, $user, $pass) or die ("Unable to connect to database");
mysql_select_db($db) or die ("Unable to select database: $db ");
$query = "select username, password from users where username = '$username' and password = '$password' and desk = 'Yes'";
$result = mysql_query($query) or die ("Error in query: $query " . mysql_error() );
I tried to run the following query but came back with a syntax error from php:
$query = "select username, password from users where username = $_POST['username'] and password = $_POST['password'] and desk = 'Yes'";