login page error

Started on the old forum in December 2009 · view the original in the archive · old links redirect here

10 replies · 686 views · started 16 years ago · 1 min read

5 participants
cobusbo Developer · 117 posts #1

Hi I have a little problem with this page

parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\login.php on line 12

can you guys maybe help me please

<?php
require_once("dbConfig.php");  //database connection

// Catch field data
$username = $_POST['uname'];
$password = $_POST['pword'];
$submitted = $_POST['submitted'];

if ($username | $password)(
//////////////////////////////////
$query = sprintf("SELECT * FROM users_cb where uname ='$username' and pword = '$password'")
$result = @mysql_query($query);
$rowAccount = @mysql_fetch_array($result);
//////////////////////////////////
)

if ($rowAccount)(
				 
echo "The record exists so you can enter ";

)elseif($submitted)(

echo "You dont exist in the system so your npt getting in!";

)

?>

<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
  <table width="200" border="2" align="center">
    <tr>
      <td>Username:</td>
      <td><label>
        <input name="uname" type="text" id="uname" maxlength="20" />
      </label></td>
    </tr>
    <tr>
      <td>Password</td>
      <td><label>
        <input type="text" name="pword" id="pword" />
      </label></td>
    </tr>
    <tr>
      <td colspan="2" align="center" valign="middle"><input name="submitted" type="hidden" id="submitted" value="1" />
        <label>
          <input type="submit" name="login" id="login" value="Login" />
      </label></td>
    </tr>
  </table>
</form>
</body>
</html>
crazybrumi Super moderator Principal · 1,064 posts #2

surround the variables like this

 '".$var."' 
than instead of this 
 '$var' 

so this is it implemented in your coding.

  <?php 
require_once("dbConfig.php");  //database connection 
 
// Catch field data 
$username = $_POST['uname']; 
$password = $_POST['pword']; 
$submitted = $_POST['submitted']; 
 
if ($username | $password)( 
////////////////////////////////// 
$query = sprintf("SELECT * FROM users_cb where uname ='".$username."' and pword = '".$password."'") 
$result = @mysql_query($query); 
$rowAccount = @mysql_fetch_array($result); 
////////////////////////////////// 
) 
 
if ($rowAccount)( 
                  
echo "The record exists so you can enter "; 
 
)elseif($submitted)( 
 
echo "You dont exist in the system so your npt getting in!"; 
 
) 
 
?> 
 
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
</head> 
 
<body> 
<form id="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>"> 
  <table width="200" border="2" align="center"> 
    <tr> 
      <td>Username:</td> 
      <td><label> 
        <input name="uname" type="text" id="uname" maxlength="20" /> 
      </label></td> 
    </tr> 
    <tr> 
      <td>Password</td> 
      <td><label> 
        <input type="text" name="pword" id="pword" /> 
      </label></td> 
    </tr> 
    <tr> 
      <td colspan="2" align="center" valign="middle"><input name="submitted" type="hidden" id="submitted" value="1" /> 
        <label> 
          <input type="submit" name="login" id="login" value="Login" /> 
      </label></td> 
    </tr> 
  </table> 
</form> 
</body> 
</html>

Want something coded email me at sales@webnwaphost.com for a prices.

http://flagcounter.com/more/W80q

djdevil89 Senior · 287 posts #3

nd as far as i see you are using () insead of {}

foreach ($_SERVER as $server => $value)
{
echo "$server is $value<br />";
}
cobusbo Developer · 117 posts #4

I did they changes you guys told me but still the same error im not sure if I used the corect sign "|" in line nine but they say the T_Variable error is in line 12 anyway here is the edited script again:

  <?php 
require_once("dbConfig.php");  //database connection 
 
// Catch field data 
$username = $_POST['uname']; 
$password = $_POST['pword']; 
$submitted = $_POST['submitted']; 
 
if ($username | $password){ 
////////////////////////////////// 
$query = sprintf("SELECT * FROM users_cb where uname ='".$username."' and pword = '".$password."'") 
$result = @mysql_query($query); 
$rowAccount = @mysql_fetch_array($result); 
////////////////////////////////// 
} 
 
if ($rowAccount){ 
                  
echo "The record exists so you can enter "; 
 
)elseif($submitted)( 
 
echo "You dont exist in the system so your npt getting in!"; 
 
} 
 
?> 
 
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
</head> 
 
<body> 
<form id="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>"> 
  <table width="200" border="2" align="center"> 
    <tr> 
      <td>Username:</td> 
      <td><label> 
        <input name="uname" type="text" id="uname" maxlength="20" /> 
      </label></td> 
    </tr> 
    <tr> 
      <td>Password</td> 
      <td><label> 
        <input type="text" name="pword" id="pword" /> 
      </label></td> 
    </tr> 
    <tr> 
      <td colspan="2" align="center" valign="middle"><input name="submitted" type="hidden" id="submitted" value="1" /> 
        <label> 
          <input type="submit" name="login" id="login" value="Login" /> 
      </label></td> 
    </tr> 
  </table> 
</form> 
</body> 
</html>
ori Lead · 512 posts #5

on the query line u forgot to close with ;

cobusbo Developer · 117 posts #6

Thanks ori Solved my problems

cobusbo Developer · 117 posts #7

K I added some sessions now I get error again

Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\login.php on line 7

  <?php 
require_once("dbConfig.php");  //database connection 
 
session_start()

// Catch field data 
$username = $_POST['uname']; 
$password = $_POST['pword']; 
$submitted = $_POST['submitted']; 
 
if ($username | $password){ 
////////////////////////////////// 
$query = sprintf("SELECT * FROM users_cb where uname ='".$username."' and pword = '".$password."'"); 
$result = @mysql_query($query); 
$rowAccount = @mysql_fetch_array($result); 

////////////////////////////////// 
} 
 
if ($rowAccount){ 
                  
$_SESSION['id'] = $rowAccount['uname'];

header("location:index2.php");
exit;
 
}elseif($submitted){ 
 
echo "You dont exist in the system so your not getting in!"; 
 
} 
 
?> 
 
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
</head> 
 
<body> 
<form id="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>"> 
  <table width="200" border="2" align="center"> 
    <tr> 
      <td>Username:</td> 
      <td><label> 
        <input name="uname" type="text" id="uname" maxlength="20" /> 
      </label></td> 
    </tr> 
    <tr> 
      <td>Password</td> 
      <td><label> 
        <input type="text" name="pword" id="pword" /> 
      </label></td> 
    </tr> 
    <tr> 
      <td colspan="2" align="center" valign="middle"><input name="submitted" type="hidden" id="submitted" value="1" /> 
        <label> 
          <input type="submit" name="login" id="login" value="Login" /> 
      </label></td> 
    </tr> 
  </table> 
</form> 
</body> 
</html>
cobusbo Developer · 117 posts #9
<?php 
session_start();
require_once("dbConfig.php") // database connection

if (! isset($_SESSION['id'])){

header("location:login.php");
exit;

}

$id = $_SESSION['id'];

/////////////////////////////////////////////
$query = sprintf("SELECT * FROM users_cb where uname ='$id'");
$result = @mysql_query($query);
$rowAccount = @mysql_fetch_array($result);
/////////////////////////////////////////////

?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>Welcome <?php echo $rowAccount('uname'];?>
</body>
</html>

Parse error: syntax error, unexpected T_IF in C:\xampp\htdocs\index2.php on line 7

subzero Super moderator Fellow · 3,954 posts #10

}else{ if($submitted){

echo "You dont exist in the system so your not getting in!";

} }

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

cobusbo Developer · 117 posts #11

I had a space before <?php but its fixed im done with the script thanks to you guys and thnks for the patience

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close