FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

i need this,pls help

 


jossylala
i design a site for a school last year and now they are asking me to make the site result checking enabled.please i would like someone to help me with a script that could do something like.let say some thing l;ike www.waecdirect.org or www.myjambresult.com ,it most not use pin and exam number,it could be using username and password.please i would like this as soon as possible.
LukeakaDanish
Do you know php?

Do you have a database of all the info readily available? And on what DB engine?
jossylala
Quote:
Do you know php?

Do you have a database of all the info readily available? And on what DB engine?


i dont know php but i can do installation of php scripts.

i have it available on the schools computer and am waiting to transfer it online.DB engine?i dont get but whant i want is to place students result online so that they could use either a username/password or pin/exam number to check the result.thanks for your response and i am still expecting more reponse
LukeakaDanish
Basically, you wont be able to do this without a custom php script.

Show us an example of the results, and tell us what kind of file it is, and someone might write it for you Smile
jossylala
you dont get it,i want a script where by i manually tpye in a students result and when the student login with a pin/exam number or usernamne/password, they student would see his or her result with the ability to print it.do you get me now?
LukeakaDanish
Yep ok, now I get you. Do you know how to make mysql databases (coz that is what this kind of thing will use)
jossylala
i dont know how to do it but i could follow an instruction for it when u give me the script.
adri
If you cpanel? or PHPmyAdmin? or something where stands "MySQL"?

PS: You will not find it when you only have FTP-access....
jossylala
i have mysql in my sever.but i dont know how having it makes any differences,bcos i dont know want to do to get the students result online and for them to be able to check it .note that the result would be attached to the site.
LukeakaDanish
jossylala wrote:
i have mysql in my sever.but i dont know how having it makes any differences,bcos i dont know want to do to get the students result online and for them to be able to check it .note that the result would be attached to the site.


If you put the data into a database we can read it with a php script. Go into cpanel, create a database and add a user to it. Then go into the database my PhpMyAdmin and add a table and fill it with some data.

If you do that I'll write a script to allow the users to read it for you.
jossylala
ok i would create the msql of the datas.but can i get a guideline on how to execute the action you just mention
LukeakaDanish
Ok...so you've got your DB created right?

...find the PhpMyAdmin link in cpanel and select your database.

Then add a table (should be on the front page) name "students" with 4 collumns. It will give you input space for the 4 collums...add the following:

Code:
Name: ID        Type: INT          Attributes: Unsigned, auto_increment        PRIMARY KEY (check the box under the key)
Name: name      Type: VARCHAR   Length: 50
Name: password  Type: VARCHAR   Length: 32
Name: data      Type: TEXT


Once you've managed to do that, I'll write a quick script for you. It wont be amazing, but it'll do the job.
jossylala
thanks very much for the help.i would contact you a soon as am through
jossylala
i have done what you said i should do,now am waiting for your script.here is the output of what i did,is it ok?
Code:
SQL query:
CREATE TABLE `sureqed_result`.`students` (
`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 50 ) NOT NULL ,
`password` VARCHAR( 32 ) NOT NULL ,
`data` TEXT NOT NULL
) ENGINE = MYISAM


please note that the student are about finishing thier exams and the result would soon be ready for uploading.
LukeakaDanish
Cool! Well done!

I'll fix something up for you one of the following days Smile
jossylala
thanks luke,i would be expecting it Very Happy
LukeakaDanish
Ok...here we go.

I'm posting all the code, so it can be community-reviewed for mistakes/errors/insecurities.

All the following files should be created inside a "/grades/" directory

File 1: config.php - database config

Code:

<?php
/**************************
/ Config
/*************************/

$dbhost = 'localhost';
$dbuser = '###';
$dbpass = '###';
$dbname = '###';

/**************************
/ End of config
/*************************/
?>


In this file, replace the ###'s with your actual database login values

File 2: index.php - the file students see - include it on your page with <?php include('grades/index.php'); ?>

Code:

<?php

include('config.php');

if (isset($_POST['name'])) {
   $db = mysql_connect($dbhost,$dbuser,$dbpass) or die(mysql_error());
   mysql_select_db($dbname,$db);
   
   if (!isset($_POST['name']) || !isset($_POST['password'])) die('Please remember to type both name and password!');
   
   $name = mysql_real_escape_string($_POST['name']);
   $password = mysql_real_escape_string($_POST['password']);
   $encrypt = md5($password.$name.'salt');
   
   $query = "SELECT * FROM `students` WHERE `name`='$name' AND `password`='$encrypt' LIMIT 1";
   $result = mysql_query($query) or die('Database error: '.mysql_error().'<br />Query: '.$query);
   
   if (mysql_num_rows($result) == 0) die ('There was no student with that name/password combination. Please go back and try again.');
   
   $row = mysql_fetch_assoc($result);
   
   echo '<table><tr><td>Name:</td><td>'.$row['name'].'</td></tr><tr><td>Grades:</td><td>'.$row['data'].'</td></tr></table>';
   
}
else {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
   <table>
      <tr>
         <td>Name</td><td><input name="name" /></td>
      </tr>
      <tr>
         <td>Password</td><td><input type="password" name="password" /></td>
      </tr>
      <tr>
         <td colspan="2"><input type="submit" value="Check grades..." /></td>
      </tr>
   </table>
</form>
<?php
}
?>


Nothing should be changed in this file!

File 3: p_encrypt.php - use this file to get encrypted passwords for the database! DO NOT insert unencrypted passwords into the database! Usernames are case sensitive in both files!
Code:

<?php
if (isset($_POST['name']) && isset($_POST['password'])) {
   //connect to database to get mysql_real_escape_string function.
   include('config.php');
   $db = mysql_connect($dbhost,$dbuser,$dbpass) or die(mysql_error());
   $name = mysql_real_escape_string($_POST['name']);
   $password = mysql_real_escape_string($_POST['password']);
   $encrypt = md5($password.$name.'salt');
   echo 'Name: '.$name.'<br />Encrypt: '.$encrypt;
}
else {
?>
<html>
<head></head>
<body>
<form action="p_encrypt.php" method="POST">
   <table>
      <tr>
         <td>Name</td><td><input name="name" /></td>
      </tr>
      <tr>
         <td>Password</td><td><input type="password" name="password" /></td>
      </tr>
      <tr>
         <td colspan="2"><input type="submit" value="Get encrypted password" /></td>
      </tr>
   </table>
</form>
</body>
</html>
<? } ?>


I hope everything works for you.

Insert new grades with phpmyadmin, by selecting your database and pressing "insert" - leave ID blank.
jossylala
thanks very much, the url is sureq.org/grades/index.php.but i would like to make some suggestions if its possible
is it possible to make the result that would be displayed to like the one in the attachment?secondly i would like something like an admin interface that has a form that inserts the grades into the database.note that the grades are not just scores,there are scores and rating in 11 subjects(english,maths,agric,physic,etc).and i would also like the school logo display in the result.

note:

i asked for the admin interface intimes of uploading result bcos i dont want that stress of uploading alot of result to be on me.so i would give the school cafe operator the admin interface username and password to do the result uploading.
thanks very much once more
LukeakaDanish
Sorry, doing an admin interface and a more advanced grade displaying method would take me WAY to much time. If you would like to hire me, I would be glad to work for you, but for free - the script before is all you get.

Sorry.
jossylala
sorry for over asking you.am grateful for what you did for me.thanks very much... Laughing
LukeakaDanish
Ok, no problem mate Smile.

Remember you can add all the branding you want yourself, by just making another HTML document the way you normally do, and then saving as .php and using <?php include(PATH_TO_SCRIPT); ?> to include the grading stuff Razz
jossylala
thanks once more but i have not yet tested if it show the datas.i would tell you the result after the test.
jossylala
i have typed what you said i should(i inserted datas to the database) but after encryting the password and using it on the site,i got there is not student with the name and password combination.what should i do?
LukeakaDanish
Can you explain more precisely what you did please. What did you insert?
jossylala
i inserted a sample username(john) and a sample password(ade) and then in the place where data is writen,i inserted a sample text (u scored 280) and the i encrypted the password ade to produce the encrypted password.i inserted the stated password/username/data by opening the students table and clicking the insert icon in other to insert those.and i left the id blank.
jossylala
hello fellow forumites,is there no one that can debug the php code bcos it has a bug.I mean apart from lukakadanish bcos he has tried his best.
LukeakaDanish
I dont think its bugged...if you insert the data correctly into the database i think it should work.

Try exporting your current database and posting it here...I might be able to tell you where you've gone wrong
jossylala
Laughing i know you would be willing to post but i expected other forum members to respond.presently,i think i would just save you code in my computer for future use since the school that needed it now have something else in mind.thanks and please,am i allowed to bother you in the future about this code you created for me?
LukeakaDanish
of course mate Smile
jossylala
thanks man i would get to you when the time comes. Rolling Eyes Cheers!!!
Reply to topic    Frihost Forum Index -> Scripting -> Website Software

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.