Welcome! Log In Create A New Profile

Advanced

Project related

Posted by Slinger 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Re: Project related
October 19, 2009 07:47PM
Thanks Mac that does make sense will try that.
I seem to be a bit confused about registering students link. This is the structure I have based my assignment on I have index page with the following links:
1. A student registration link where the student registers with student and course details
2. Mnage students link allowing administrator to delete, edit student details. I also have a link to register student exactly as 1 above is that correct.
3. Manage Couurse link to add, delete and edit course.
4. View registration link to view students registeration details.
Should I create another page to manage student course dtails that is to edit and delete student course details.
Re: Project related
October 20, 2009 09:25AM
I'm Glad Saadia asked this question.
I was about to ask the same thing.

I don't quite understand the "Trick" I have been googleing (if there is such a word) for it, but all I find is people asking the same question, but no real answers.

Does anyone maybe have a link as to where I can read up on this.?

Thanx Mac and Thanx Saadia.
This forum is really really help full.

PS. How much is the course registration fee again?... Just for in case?
avatar
Mac
Re: Project related
October 20, 2009 10:26AM
The tut letter gives the minimu pages required. You can add as many pages as you want - as long as you work within the provided table structure.

Sorry - I should have posted the code in code format. Have a look again. The trick is MAX in your sql statement.
avatar Re: Project related
October 20, 2009 02:04PM
Some problem I have with the code that especially Stanimal provided.... since U are Joining two or 3 tables why don't U then use mysql_fetch_assoc($result) as opposed to mysql_fetch_array($result) that U used..... does it in fact not make a difference?
avatar Re: Project related
October 20, 2009 02:40PM
The Screen dump that came with the Tutorial Letter for Database Creation...... I figure it has to be in a page of it's own... so should one link this also to the required Switchboard... so that the admin can run it once....
avatar Re: Project related
October 20, 2009 04:42PM
Hey Mac...

As an alternative to your max(id) select statement,

I inserted the student info.

I then inserted into course_student using the sno which generated on the insert student:

$sno=mysql_query("select sno from student where idno = '$idnumber'"

Understanding the fact that the idno is not a primary key in this database, i realised this could cause a problem when trying to register a student with an idno already in the database. So before i could even do my insert statement into the student table, i had to do an error check, whereby if that student is already registered for a course it would not let them register again, which i think for the purpose of this course is a fair assumption.
Re: Project related
October 20, 2009 09:18PM
Hello got this error with sessions Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\prac\login.php:3) in C:\xampp\htdocs\prac\login.php on line 3
session_start();


let me see heres the code i am batling my ass off here for days now :

=================================================================
login.php


<center>
<form action="admin.php" method="post">
<?php
include_once("config.php"winking smiley;
include_once("functions.php"winking smiley;
include_once("header.php"winking smiley;
if($_SESSION['loggedin'])
{
header("Location:admin.php"winking smiley; // redirect if already logged in
exit;
}
// Validate the username:
if (!empty($_POST['username'])) {
$e ="admin";
echo $e;
} else {
$e = FALSE;
echo '<p class="error">You forgot to enter your username!</p>';
}

// Validate the password:
if (!empty($_POST['pass'])) {
$p = "admin";
echo $p;
$_SESSION['loggedin'] = 1;
header("Location:admin.php"winking smiley;
exit;

} else {
$p = FALSE;
echo '<p class="error">You forgot to enter your password!</p>';
}

?>


<table>

Username: <input type="text" name="username" size="20" maxlength="40" />
<br>
Password:</b> <input type="password" name="pass" size="20" maxlength="20" />
<br>
<div align="center"><input type="submit" name="submit" value="Login" /></div>
<input type="hidden" name="submitted" value="TRUE" />
</form>
</center>


<br>
<br>
<br>


<?php
include("footer.php"winking smiley;
?>

=================================================================
logoff.php

same here , damm
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\prac\about.php:2) in C:\xampp\htdocs\prac\logoff.php on line 2

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\prac\about.php:2) in C:\xampp\htdocs\prac\logoff.php on line 7
about the windows



<?php
session_start();
session_unset();
session_destroy();
$_SESSION['loggedin'] = 0;

header("Location:login.php"winking smiley;
exit;
?>

smoking smiley When all else fails , read instructions grinning smiley
smiling smiley Reading is a course on it's own ! smiling smiley
Re: Project related
October 20, 2009 10:04PM
Slinger I tried this approach to the problem of getting new student number that is automatically generated to insert into course student table. It did work when I did it read it in the text book. Hope this helps you.
$query = "INSERT INTO student VALUES (' ' ,'$Surname', '$Initials', '$Name', '$Title', '$Maiden', '$DOB', '$Gender', '$Language', '$ID', '$Home_Tel', '$Work_Tel', '$Cell','$Fax_Tel', '$Email', '$Postal')";
$result = mysql_query($query);
if($result) $newsno = mysql_insert_id();
$rows = mysql_affected_rows();

if ($rows < 1) echo "Error. The record has not been added to the database.";

else echo "$rows record has been added to the database.";






$query = "INSERT INTO course_student VALUES('$newsno','$Course','1997')";
$result = mysql_query($query);
$rows = mysql_affected_rows();

if ($rows < 1) echo "Error. The record has not been added to the database.";

else echo "$rows record has been added to the database.";
Re: Project related
October 20, 2009 10:08PM
Am busy tring to edit course information, have got form producing the record record I want to edit, the problem is when updating it does not seem to pick up the correct course id I think can someone help me. This is my code:
<?php

$title = "Managing Course";
include ("header.php"winking smiley;
require_once 'config.php';
mysql_select_db("project"winking smiley;
// $cid = $_POST['cid'];
$CourseName = $_POST['CourseName'];
//$query = "INSERT INTO course VALUES ('CourseName',' ')";
$query = "UPDATE course SET cname = '".$_POST['CourseName']."' where cid = '".$_GET['cid']."'";
$result = mysql_query($query);
$cid = $row["cid"];


if ($rows < 1) echo "Error. The record has not been updated to the database.";

else echo "$rows record has been added to the database.";




?>
</BODY>
</HTML>
avatar Re: Project related
October 21, 2009 07:45AM
Hi Saadia...

Put in some echo scripts so as to check what values of your you are getting for $_POST['CourseName'] and $_GET['cid'].

When i battled, i always try echo the values before the SQL so i can see what info is coming through.

Give it a try...

Regards
Stanton
avatar Re: Project related
October 21, 2009 07:49AM
Hi Chili...

I also had this problem before.

According to google:

The problem does not lie in the code, just where its been placed. Session functions like session_name, session_start etc are special functions that can only be called BEFORE information has been sent to the browser.

So check in which file your session_start occurs, and make sure it starts first before any info has been sent to the browser...

Regards
Stanton
avatar
Mac
Re: Project related
October 21, 2009 08:25AM
ssmkhize Wrote:
-------------------------------------------------------
> The Screen dump that came with the Tutorial Letter
> for Database Creation...... I figure it has to be
> in a page of it's own... so should one link this
> also to the required Switchboard... so that the
> admin can run it once....


Admin has no need to run this - you create the tables with that dump and it is there.... you are not creating an install function.
avatar
Mac
Re: Project related
October 21, 2009 08:27AM
stanimal Wrote:
-------------------------------------------------------
> Hey Mac...
>
> As an alternative to your max(id) select
> statement,
>
> I inserted the student info.
>
> I then inserted into course_student using the sno
> which generated on the insert student:
>
> $sno=mysql_query("select sno from student where
> idno = '$idnumber'"
>
> Understanding the fact that the idno is not a
> primary key in this database, i realised this
> could cause a problem when trying to register a
> student with an idno already in the database. So
> before i could even do my insert statement into
> the student table, i had to do an error check,
> whereby if that student is already registered for
> a course it would not let them register again,
> which i think for the purpose of this course is a
> fair assumption.


Many ways to skin a cat and I'll accept them all smiling smiley As long as you remember for the future that there probably is a shorter route - many times in the inbuild PHP functions
avatar
Mac
Re: Project related
October 21, 2009 08:30AM
headers already sent error:
There must be no empty white space (or lines) in your code at the top of the file, and session must be first! PHP interprets white space as "code".
Anonymous User
Re: Project related
October 21, 2009 10:52AM
Hi guys

I'm stuck with the validation of the student registration form. I'm able to do a simple validation where a message is displayed indicating which fields were left out, etc. but I would like to highlight the problem on the form itself. It's been driving me nuts for the past few days. Any suggestions?

Other than that, things are starting to look up smile
Re: Project related
October 22, 2009 10:25PM
I'm really hitting a brick wall to get mysql_real_escape_string to work.

It kinda works, but If say I post Mc'Donnald it takes care enough of the database, as before it all went up in smoke.
But now it outputs in the List as Mc\'Donnald.

Are there any thoughts on correcting this? Perhaps just a little shove in the right direction.
Or can I leave it like that for this project?

I also have a

header ("Location: content.php"winking smiley;
exit;

problem that I just can't seem to get right. I have a bit of a cop out
solution that tells the user the input was successful with an href to take him back.
I hate these type of solutions, but time is catching up on me.

Feels like I lost that fight, and I hate losing a fight.

It looks like I might finish this project on time. I really really want to and I hope I can.
Re: Project related
October 22, 2009 11:06PM
My redirect is 100% correct, but I get a blank screen.
I need this to work, Can someone explain it to me.

header ("Location: content.php"winking smiley;
exit;

At this point this is key to making it or failing it.

Please help me Mac.?
Re: Project related
October 23, 2009 06:21AM
back on schedule well i hope so, playing the one hand band , playing longer though ,but at leats you will hear the song smiling smiley
got the login to work and redirects me to the correct page - rewrite is always good ,the trick is design, write ,re-think on paper then code in designer , but hey HUMAN NATURE ,we dont do that ,we jump in head first and takes us longer.

smoking smiley When all else fails , read instructions grinning smiley
smiling smiley Reading is a course on it's own ! smiling smiley
avatar
Mac
Re: Project related
October 23, 2009 07:07AM
Validation on the page is done through Javascript - lots of examples out there on the web.

You need to escape slashes (\) - see here http://php.net/manual/en/function.addslashes.php
' is here http://php.net/manual/en/function.htmlspecialchars.php

Redirect to blank screen - not sure what to say since I have no idea what your code looks like on the other page?
Re: Project related
October 23, 2009 08:17AM
I'm going to look up escape slashes now.
here is my redirect that won't work
Thanx Mac I really appreciate your input.

<?php require_once("includes/connection.php"winking smiley; ?>
<?php require_once("includes/functions.php"winking smiley; ?>
<?php
$errors = array();

//Form Validation
if (!isset($_POST['cname']) || empty(!isset($_POST['cname'])) {
$errors[] = 'cname';
}
// This does'nt work
if (!empty($errors)) {
header("location:new_course.php"winking smiley;
}
?>

<?php
$year = mysql_real_escape_string( $_POST['year'] );
$cname= mysql_real_escape_string( $_POST[''] );
?>

<?php
$query1 = "INSERT INTO `registration`.`course` (
`cname` , `cid`)
VALUES ('{$cname}', NULL)";
if (!mysql_query($query1 , $connection))
{
die('Error: ' . mysql_error());
}
//cool little solution from:
//http://www.daniweb.com/forums/thread178612.html
$last_insert_client_id = mysql_insert_id();
$query2 = "INSERT INTO `registration`.`course_student` (
`cid` , `year`)
VALUES ( '{$last_insert_client_id}', '{$year}')";
if (mysql_query($query2, $connection)) {
//success!
//THIS IS A COP OUT
echo "<p>Entry successfull !! <P>";
echo "</br>";
echo "<a href = \"content.php\">Add another</a>";
exit;
} else {
echo "<p>Course creation failed</p>";
echo "<p>" . mysql_error() . "</p>";
}
?>
<?php mysql_close($connection); ?>
avatar
Mac
Re: Project related
October 23, 2009 10:24AM
Language: PHP
//Form Validation if (!isset($_POST['cname']) || empty(!isset($_POST['cname'])) { $errors[] = 'cname'; } // This does'nt work if (!empty($errors)) { header("location:new_course.php"; } ?>

Why don't you just combine these two into one? E.g. if $_POST['cname'] is not set, then simply redirect immediately? Also - read what you have - if the cname is not set OR if the cname is not set and is empty - that is the same thing??? Then you also want to put cname into an array - why? It is just a single variable?

So

if (!isset($_POST['cname']) )
{
header("location:new_course.php";
}

Keep in mind if you do validation like this - it is better to add a <a href link as opposed to a redirect. WHen you take me back with a redirect, I have to complete the form all over again! So to the <a href I'll append what DID come through. eg. register.php?cname=$cname...the rest... >Go back</a>
When I get back to the form, the information that I have already filled in - and is correct - can be echoed back into the form, leaving met to only fill in the empty elements.

if (!isset($_POST['cname'] || !isset($_POST[....... add them all here - you just need to catch one that is empty) )
{
echo "You have not completed all the fields!<br>";
echo "< a href=.......php?append what you have here>Click here to go back</a>";
}

And on my form I will have <input type=text value=<?php echo $_GET['cname']....>
The first time I fill in the form it is empty, but if I get sent back to this form because of errors, it is filled in with my 1st effort information.
Re: Project related
October 23, 2009 11:57AM
Can I use dreamweaver to set form validation scripts for me?
Re: Project related
October 23, 2009 01:00PM
Scratch that, I found a PHP way to validate my forms. with a bit of your advice and a bit of my backward logic.
Its probably the most long winded code you will ever come across, but it seems like it might just work.

We are studying php after all and not Dreamweavers automated functions.
Anonymous User
Re: Project related
October 24, 2009 12:29PM
Hi guys

Here's a link to a website I found regarding form validation - I found it to be pretty useful.
Click here
avatar Re: Project related
October 24, 2009 11:39PM
Ok, silly question time from me:

Is it necessary to be able to edit the student information? change phone numbers or address or something like that?

It won't really affect the amount of time I've spent on the project whether its required or not. I just had that thought and kept thinking its what we need to do.

The only places I can't have the information filled in on the form is on my dropdown of course names or the radio buttons I have for the gender.

But if we don't have to do this, then I'll smile happily.

Chris
~~~~
"Cleverly disguised as a responsible adult."
avatar
Mac
Re: Project related
October 25, 2009 10:59AM
Yes, student information can change.... that is important! It does not take much to code it though. When I click on a student's name, his information is displayed in a form - ready to change. See my post here above.
Re: Project related
October 26, 2009 09:28AM
Just saw something seriously nerve wrecking.

In the database dump that came with the tutorial letter there is no field under course_student called fmark,
Yet its listed in the tutorial letter.

I did not include it in my project anywhere and now I'm a bit stressed.

Please Advise
avatar Re: Project related
October 26, 2009 03:15PM
Yeah i saw that a while ago too... Must be something Mac adds in at the end?

Hey Mac weren't you going to help us with some kind of php object orientated info as well?
avatar
Mac
Re: Project related
October 27, 2009 10:42AM
The fmark field, if not used (which you don't have to) can be left out.

OO - yip - except I have mislaid it..... sad smiley I'll keep on searching...
avatar Re: Project related
October 27, 2009 02:34PM
Thanks Mac!
Sorry, only registered users may post in this forum.

Click here to login