Jump to content

MerlinJR

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

MerlinJR's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm working on my login system but my code doesn't work. it is always skip the "true" part, so basically dosen't matter if the user and pass I entered is right or wrong it's always said it's wrong. Please help.... <?php session_start(); extract($_POST); $host = 'localhost'; $user_name = ''; $password = ''; $data_base = ''; $connect = @mysqli_connect ($host, $user_name, $password, $data_base)or die('Error connecting to mysql'); $username=$_POST['user']; $password=$_POST['pass']; $query="SELECT * FROM user WHERE username='$username' and pass='$password'"; $result=mysqli_query($query); $count=mysqli_num_rows($result); if($count==1){ $_SESSION['login'] = true; header('location: location: ../main.php'); exit; } $_SESSION['error'] = 'Wrong name or password. Try again.'; header('location: login.php'); ?>
  2. So I'm trying to update grade in grade table, at the same time if there was NO grade INSERT it into the table. basically, before this file, I have a form with drop down box so a user can pick student ID and courses then update or insert grade. I didn't get any error message but it didn't update or insert grade to my table. anybody have any idea what is wrong with my code? Thanks 4 your help. <?php $host = 'localhost'; $user_name = 'xxx'; $password = 'xxx'; $data_base = 'xxx'; $student = 'student'; $course = 'course'; $grade = 'grade'; $connect = @mysqli_connect ($host, $user_name, $password, $data_base) or die('Error connecting to mysql'); $query = "SELECT grade FROM grade WHERE stu_id = '$_POST[stu_id]' AND cours_num ='$_POST[cours_num]' "; $result = mysqli_query($connect, $query); if (mysqli_num_rows($result) > 0) { $result = mysqli_query($connect, "UPDATE grade SET grade = '$_POST[cours_num]' WHERE stu_id = '$_POST[stu_id]' AND cours_num = '$_POST[cours_num]'"); echo "<h1 align=\"center\">Grade Completed</h1>"; } else { $result = mysqli_query($connect, "INSERT INTO grade (grade) VALUES '$_POST[grade]'"); echo "<h1 align=\"center\">Grade Completed</h1>"; } ?> <html> <head> <style type="text/css"> .center {text-align:center} </style> </head> <body> <p class="center"><br/><br/><a href="grade.php">Edit/Add Another Record?</a></p> <p class="center"><a href="..">Go back to the main form</a></p> </body> </html>
×
×
  • 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.