-2
    <?php
if(ISSET($_POST['submit']){

        $username =$_POST['uname'];
        $password =$_POST['lpass'];

        $mdpass = md5($password);
        $result = mysql_query("select * from member where RegNo ='$username' and Password ='$mdpass'")or die(mysql_error());

        $count =mysql_num_rows($result);
        $row = mysql_fetch_array($result)

        if($count>0){

            session_start();  //start a session
            $_session['id']=$row['id']; //create a session variable
            header('location:home.php');  //redirect to home.php


        }
        else{
            header('location:index.php'); //redirect to index.php

        }

    }
?>

I wanna connect my login page into sql data base. I used this code.but some unexpected error occurs (Parse error: syntax error, unexpected '{' in on line "if(ISSET($_POST['submit']){") after I removed {.. then also its not working. Im a beginer into programming.. so please someone help me.

Funk Forty Niner
  • 73,764
  • 15
  • 63
  • 131
  • 2
    Call it a blessing in disguise. Don't use that code for a few reasons. One of which being MD5; it can't be trusted to store passwords anymore. Use something more of this century like `password_hash()`. – Funk Forty Niner Sep 13 '16 at 21:49
  • thanx for your comment sir.. – Tharu KasthuriArachchi Sep 13 '16 at 21:52
  • You're welcome. However, you have a few more syntax errors. You also accepted an answer for another question you posted http://stackoverflow.com/q/39444664/ where they had `mysqli_` instead of what you posted here, being `mysql_`. Your HTML form is unknown also. You have answers below. – Funk Forty Niner Sep 13 '16 at 22:15
  • I dont understand how to define a query in mysqli.. whats the difference between them. where should I change in this code. – Tharu KasthuriArachchi Sep 13 '16 at 22:54

2 Answers2

-1

Well, to start, you're missing a ) on the line that's throwing an error (count your brackets).

Second, like other people have already (and always do) chime in with, take a look at proper practices regarding storing and using stored passwords.

Tyler Sebastian
  • 7,244
  • 5
  • 33
  • 56
-1
if(ISSET($_POST['submit']){

as you can see you say here if (ISSET( so you are opening twice. but you are only closing once. ['submit']){

can you try the following see if it works for you?

if(ISSET($_POST['submit']))
SunnBro
  • 315
  • 3
  • 16