Tharu KasthuriArachchi Tharu KasthuriArachchi - 1 year ago 57
MySQL Question

How to connect login page into mysql database


$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)


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

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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download