i was working on this website, where teachers can publish students’ marks…my plan is to let the teacher open the mysql table and update the column “marks” for each “username” of id “id”… and anytime the marks are updated, each student gets an email… is my logic right? and is there any other way i can go about this??
regarding the emailing part, i have just conjured the idea, but i dont have much idea on how to implement it… could you please give me some hints or tell me of some code?
i know i’ve disturbed you for almost a week now, but this is kind of the last issues i am on, and then i ll be taking a very long break… my sincerest gratitude to you…
Do you have any table schemas (structures) you can share?
This may be terminology issue, but do you really plan on letting the teachers open/update the MySQL table directly or do you plan to put a form in front of it?
As for the e-mailing part, that should be simply enough, just use [fphp]mail/fphp
# Name Type Collation Attributes Null Default Extra Action
1 id int(10) UNSIGNED No None AUTO_INCREMENT Change Drop Browse distinct values Primary Unique Index Spatial Fulltext More
2 username varchar(255) latin1_swedish_ci No None Change Drop Browse distinct values Primary Unique Index Spatial Fulltext More
3 email varchar(255) latin1_swedish_ci No None Change Drop Browse distinct values Primary Unique Index Spatial Fulltext More
4 security varchar(255) latin1_swedish_ci No None Change Drop Browse distinct values Primary Unique Index Spatial Fulltext More
5 marks int(255) No None Change Drop Browse distinct values Primary Unique Index Spatial
this is my table in phpmyadmin, and actually the ideal thing would have been to present teachers with a form to insert marks, but i m not sure on how to do that, so the raw plan i had was to make the teachers edit the mysql table…sounds pretty crude and primitive though…
2.and regarding the mail(), could you please explain more on how to use that function. for instance like
send mail"“” if ‘’’ table is updated"‘’’ to all members in the table…
Agreed, a form would be simple enough (if that interests you). You will simply query the table for all records, loop through them generating your form entries, one thing you need to be sure you do is treat them as an array of form items with names like “marks[<?php echo $row[‘id’]; ?>]” so you know which id the marks applies to.
You can;t easily send an email from MySQL, there are options, but using a form for the updates would make it more seamless (in my opinion).
If you decide to go with a form for updating marks, I can help you through the entire process. If you want to the trigger approach as outlined in the link above, then you will need to develop a script that runs on a cronjob to send emails accordingly (I can help with that too).
Let me know which way you want to take this project.
thank you very much… i really needed someone to guide me through this…regarding the form, the issue i had in mind was if we made such a form, will it be accessible to students too?? because if that happens then students will be able to change their marks, right?
and about the email thingy, actually i was planning to do it through php, same way as my previous website (remember the portfolio and the password reset stuff)…so basically,
i ll have a php controller, and a template… much like reset.php (controller), and reset_form( template) from above… in fact i’m building this new website same way as the old, so i still have my old files config.php, login.php. logout.php, etc…just like the previous one… and in this new website, i m using the same reset method as the prev one from reset.php (remember??) to enable students to reset their passwords…
… and right now i have three folders … html (which contains 3 folders called
css,
img
and js respectively, and 6 files namely
index.php,
login.php,
logout.php,
pass.php (just like above)
register.php and
reset.php
2nd folder is “includes” which contains constants.php, functions.php and config.php
3rd folder called templates (contains
header.php,
footer.php
login_form.php,
pass_form.php,
portfolio.php ((I AM GOING TO CHANGE THIS TO STH LIKE A PAGE WHERE STUDENTS WILL SEE THEIR MARKS AND OTHER STUDENT RESOURCES LIKE NOTICES, ANNOUNCEMENTS, ETC),
register_form.php aand
reset_form.php
Do you have a way to tell if the logged in user is a student or a teacher? If you do, you just simply have to validate they are a teacher, then show the page, otherwise, show an Access Denied message/page.
That would work, so long as your initial view is showing a form for the teacher to fill out, and after it processes the entry, it kicks off an email to the student. Thus making it so the teacher can update the marks within the page.
Presumably, your db will differentiate between students and teachers. If so, you could add a login page which checks the db on submit. If the login is for a teacher, display the form, if not display a rejection.
one sec, so if this is my code for login.php how can i modify it to cater for teachers?? and the new database i create for teachers, called “teachers”, do i keep the same columns as those for students, i mean identical to them?? like “id”, username, security, email, hash??
<?php
// configuration
require("../includes/config.php");
// if form was submitted
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
// validate submission
if (empty($_POST["username"]))
{
apologize("You must provide your username.");
}
else if (empty($_POST["password"]))
{
apologize("You must provide your password.");
}
// query database for user
$rows = query("SELECT * FROM users WHERE username = ?", $_POST["username"]);
// if we found user, check password
if (count($rows) == 1)
{
// first (and only) row
$row = $rows[0];
// compare hash of user's input against hash that's in database
if (crypt($_POST["password"], $row["hash"]) == $row["hash"])
{
// remember that user's now logged in by storing user's ID in session
$_SESSION["id"] = $row["id"];
// redirect to portfolio
redirect("/");
}
}
// else apologize
apologize("Invalid username and/or password.");
}
else
{
// else render form
render("login_form.php", ["title" => "Log In"]);
}
Okay, first thing to do when defining a new column is to consider what types of values you want it to hold. So right now you definitely know you need to know the difference between a Student username and a Teacher username, what about an Administrator or Principal? Would those designations be helpful later on?
If so, I’d make the column varchar(20) and store one of the following per record, ‘Student’, ‘Teacher’, ‘Principal’, ‘Administrator’
sounds good, so now there is an issue with registartion too i guess? because the user will have to specify whether he is a teacher or a student, right?
wouldnt it be better if we like just added some specific teachers to the table, so that only they can see the form when they register, instead of making it open for teachers to register? what do you suggest?