Welcome! Log In Create A New Profile

Advanced

Prac available

Posted by Mac 
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: Prac available
May 08, 2008 04:07PM
Hi. You welcome..

See at the bottom, Its a little more coding but it works. smile

I will try your method and see if it works as well but this method works on my machine.

<?php
$option = $_POST['option'];

if ($option == 'adm1yes'winking smiley{
$URL="course_admin.php";
header ("Location: $URL"winking smiley;
}
elseif ($option == 'adm2yes'winking smiley{
$URL="student_admin.php";
header ("Location: $URL"winking smiley;
}
elseif ($option == 'rep1yes'winking smiley{
$URL="report.php";
header ("Location: $URL"winking smiley;
}
else {
echo"Error";
}
?>

Let me know wat happens smile
Re: Prac available
May 09, 2008 08:07AM
Hi JwV

I tried your code, it works fine here. It redirects on all 3. The only difference i added and im not sure if you have it also is $option = $_POST['option']; on line 2.

Hope that help or try the code i posted yesterday,

<?php
$option = $_POST['option'];

switch ($option)
{
case "adm1yes":
header("Location: course_admin.php"winking smiley;
break;
case "adm2yes":
header("Location: student_admin.php"winking smiley;
break;
case "rep1yes":
header("Location: report.php"winking smiley;
break;
}

?>
Re: Prac available
May 09, 2008 08:35AM
Hi guys,
im not sure i understand this part in the prac.pdf:
"Please provide a single configuration page with your database and user information which you can include in pages that require so."

I'm not sure if i understand this correctly... are we suppose to write our own
basic config.inc.php containing the logon details and mac will just copy our file into the phpMyAdmin on his server and then run our prac or am i on a total wrong track here...

I am really starting to enjoy this course now..
Re: Prac available
May 09, 2008 08:46AM
Hi.

How you?

I think it refers to the database and table details for connecting to the database. The database is already there only the user details will have to be changed so that macs machine will be able to connect to them.

example :

<?php

$host = "localhost";
$user = "yourusername";
$pass = "yourpassword";
$db = "yourdb";
// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"winking smiley;
// select database
mysql_select_db($db) or die ("Unable to select database!"winking smiley;

?>

That section should be part of your config file so 1 change will change all your tables and database configuration settings.

Hope that helps.

smile
JwV
Re: Prac available
May 09, 2008 12:50PM
Hi MuhammadA

Thanks for the help. smile I have been reading stax of web page on the header command. eye popping smiley So from what I understand from all the reading is that you cannot output any data before you issue the header command. It seems that as soon as you output something to the screen a header is sent and when the header command is issued it complains since a header is already sent to the client. If I remember correctly, th page said that the header command should be as high up in your page as possible.

I remove a echo statement (for debugging) I had before the header statement, removed any spaces and ran my code again. It is now working. Thank goodness.hot smiley

Here is another question I hope anyone can help with. The dob field in the student table. What is the format of the field. it could be ddmmyyyy or dd/mm/yy or mm/dd/yy or even start with the year. Does anyone know how to create a display mask for data. ie:in the dob field dta is store as ddmmyyyy and I would like to dissplay it as dd/mm/yyyy or even dd-mm/yyyy. Hope anyone can help.

So far, so good with the prac. It just seems if it has a life of its own. Growing with each new thing I discover on the net and want to try out. Hope the rest of you are also having fun.

Mac =>> Is it possible that we could get copies of the other pracs at the end of the course, so we could see how others tackled certain tasks. It could be posted as a single or multiple download(s) on the PHP unisa site and downloaded by us, the same as the prac and tut letters.thumbs up smiley

Good luck you all with the prac. smileys with beer

Thanks.
Re: Prac available
May 09, 2008 02:40PM
Hi..

Glad to be of help. Yeah the header is very fragile as it needs to be sent out early in the processing of your code.

I think,the dob field should be in what ever format you choose for your users to use. The best way to do this for me is use 3 selection boxes.Date, Month and Year. You can name them dd, mm, yyyy respectively. The only thing you need to do is when writing it to your database table is to format it into one variable so it can be written as one.

Before writing to the database i added the follwowing,

<?php


$dd = $_POST['dd'];
$mm = $_POST['mm'];
$yyyy = $_POST['yyyy'];

//combine

$dob = $dd . "/" . $mm . "/" . $yyyy;

Those are seperated by '/'.

You may change it to:

$dob = $yyyy . "-" . $mm . "-" . $dd;

Oh and one more thing, the prac shows the structure of the table with the date of birth being:

`dob` varchar(8) NOT NULL default '',

so try to keep it to to 8 characters.

Hope that helps.

smile
JwV
Re: Prac available
May 09, 2008 09:57PM
Hi MuhammadA

I agree with you that the 3 selection boxes are the best approach. I had started coding in that direction and just needed to clear up some things before the codimg became to involved. Doing a rewrite afterwards would be a real pain in the butt.

I am going to store the date as ddmmyyyy. This will keep it in the 8 char limit. I just need to figure out if php has a substring function so that i can cut it up at display time to make it readable.

Thanks for all the help sofar.

Have qa great weekend, and don't let php keep you up to late.
Re: Prac available
May 09, 2008 10:23PM
Hi its a pleasure. But can i ask what you meant by using a substring function to make it readable at display time?

Thanks and yeah you too.. Php needs a break also lol..

Enjoy your weekend.

smile
JwV
Re: Prac available
May 11, 2008 06:53PM
MuhammadA

With ref to the substring. I am storing the date as ddmmyyyy (ie 01032008). Thus when I am ready to display it I want to cut it up into 01 (for dd) 03 (for mm) and 2008 (for year) and store each in its own vartiable. I have discovered a php function called substr which will do it for me.

eg:

<?php
$date = "01032008";
$dd = substr ($date,0,2); //returns 01
$mm = substr ($date,2,2); //erturns 03
$yy = substr ($date,4,4); //returns 2008
echo "date is : $dd-$mm-$yy"; //displays date as 01-03-2008
echo "date is : $yy/$mm/$dd"; //displays date as 2008/03/01

?>

I now just need to go and test it in my setup. So instead of displaying $date I can now display the date in the way I want it.

Hope it is of use to you as well.

"What is this I hear calling my name...... It must be the voice of PHP calling me to work" <grin>

Let me get back to work.
Re: Prac available
May 11, 2008 09:03PM
Hi..

Hope you having a good weekend.

Hey thanx. It looks nice and i think it will be of use to me. Thank you.

I was busy the whole weekend. Back to php for me from tomoro.lol

Good luck with yours.

smile
JwV
Re: Prac available
May 12, 2008 11:22AM
Greeting....

It is Monday morning, and its back to the labour camps again. <grin> Had a great weekend, just wish it was longer.

Glad I could help with the substr function. Am having "fun" eye rolling smiley with the data validation rules for the student data. Am trying to make it break proof. Maybe I should think of just keeping it simple. Oh well, I am half way through the form, I can just as well complete it. Am now busy with the id number. Have decided to make it a standard that it must be 13 char long and all must be numeric.

This week its me and PHP every evening.
Re: Prac available
May 12, 2008 11:37AM
Hi..

Me too wish it was longer. smile

Yeah i try and keep everything simple. You can achieve at times the same outcome and still keep it simple.

Have you done your tables yet. I was testing it and im having a problem with the incrementing. Am I right in saying that it should increment, lets say the student table as follows.

You add record 1 it will be 9
Record 2 will be 18
etc

It increments each time by 9 as in the case of the student table.

Not too sure
Re: Prac available
May 12, 2008 01:19PM
Hi,

Maybe you are calling your header file 2 times thats why the error is coming.

try using include_once() in place of include().

Have a great day.
avatar
Mac
Re: Prac available
May 13, 2008 06:41AM
ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 means the auto increment should start at 9, then increase by one.

This is simply because we have populated the datatbase with 9 records, and then created a dump. You can remove that line from the dump. Its really irrelevent where it starts - 1, 9 or 1254 makes no difference.
Re: Prac available
May 13, 2008 08:19AM
Thanks smile It was starting at 9 but i was confused if it had to increase each time by 9 or just start at 9. Thanks.
JwV
Re: Prac available
May 13, 2008 10:34AM
Also thought in the beginning that it should increment in steps of 9, but just left it for later to investigate.

Have done the course table and the add, delete and update course pages. Now busy with the student registration page, and next is the delete student and update student pages. Will do the reporting last.
Re: Prac available
May 13, 2008 10:37AM
Cool. You a little infront of me smile

Enjoy
Re: Prac available
May 13, 2008 11:08AM
Hi guys,

I decided to do the student registration and managing first.
I picked up a 'possible error' in the Table structure for table `student`
No course field exists when a student registers for the 1st time...
Is this wrong or am i looking at it from the wrong angle?

<<Mac>>
When we register a student, should we also include the course he wants to register
for on the data entry form?
OR
Do we add the student 1st to the student table and then later on after selecting a course from the course table, add both the student and course to the course_student table...?


If we have to include the course, then it means you'll have to retrieve it from the course table and present the available courses to the student...

Am i just confusing the whole requirement here? im not too sure anymore...


FROM THE PRAC:
3. You should have a function to add course information and student information to the course_student table, as well as a function to edit and delete associations between a student and the course he/she registered for.
Re: Prac available
May 13, 2008 11:45AM
Hi.

I am not too sure what problem you experiencing, but from what i understand is that you are trying to write the course the user is registering for into the student table. the course field doesn't exist in the student table, the course field must be written to course_student together with the student no. so in this way the admin can still pick up what course a specific student is registered for.

So in the registeration you need to write to 2 places. The tables have the same 'sno' so it should link in that way.

Hope that is of help to you smile
avatar
Mac
Re: Prac available
May 13, 2008 12:39PM
When a student registers, he registers for a course so yes, the course info should be pulled from the course information into the student registration page
Re: Prac available
May 13, 2008 01:38PM
Hi Mac,

I think i get it now...
Thanx for clarifying...
Re: Prac available
May 14, 2008 10:42AM
Hi All (Mac)

When creating your input form(s) can we use pure html to create the input fields or should we difne withing PHP

E.g.
PURE HTML
<form method=POST>

OR

HTML EMBEDDED IN PHP
echo "<form method=POST>";

It is much quicker to create forms using pure html and using the include ("myform.html"winking smiley; statement from PHP to pull the form into your script...
avatar
Mac
Re: Prac available
May 14, 2008 11:10AM
as you wish....
Re: Prac available
May 14, 2008 10:24PM
You need to clear the output buffer before the header statement.

$output = null;

switch ($option)
{
case "adm1yes":
header("Location: course_admin.php"winking smiley;
break;
case "adm2yes":
header("Location: student_admin.php"winking smiley;
break;
case "rep1yes":
header("Location: report.php"winking smiley;
break;
}
JwV
Re: Prac available
May 19, 2008 11:24AM
Hi all

RichardSanders >>> Thanks, I will remember that titbit of info. Am sure it will become handy very soon.

Mac >>> Have heard people mention asp. Is it like php.


MuhammadA >>> Hope you are well. Am busy with the student update/delete section. It is taking longer than I had hoped for. Plan to finish this part by the end of the week. Then its the reoprt section and I should be finished. smiling bouncing smiley

Good luck to all of you.
Re: Prac available
May 19, 2008 11:42AM
Hi. Im well thanx and yourself.

Thats good, you still have some time so take your time and perfect it. I have completed all the sections of the site but still going to test and test and test and modify lol.

ASP.. Lol.

I started as a web designer here at this company but had to learn a little of asp because this company loves asp smile. What i know from php really helped me with learning the basics of asp. They are very similar but what sets them apart is the syntax and commands. Personally I find Php 100 times better and easier to use. The language syntax isn't as strict as asp. Here is an example.

ASP:<%Response.Write "This is a test!" %>
PHp:<?php echo "This is a test";?>

Asp uses either javascript or vbscript.

What can be done in asp can be done is php as well and i love php. The difference is peoples preferences.

Hope you having a great time with the prac. Enjoy.
avatar
Mac
Re: Prac available
May 20, 2008 06:59AM
Ditto on PHP versus ASP. Started with ASP - will never go back.
Re: Prac available
May 20, 2008 07:35AM
Hi Mac,

How will you go about in marking the prac?
Will you look at the functionality of the site as a whole
as well as our code?
Re: Prac available
May 20, 2008 04:30PM
Hi Mac,

I have completed my project but when i try and mail it, it is returned. Is there another email address i can send it to.

Thanks
avatar
Mac
Re: Prac available
May 21, 2008 07:10AM
See new thread for posting your prac.

Just check previous forums for how I mark - eg
http://osprey.unisa.ac.za/phorum/read.php?205,59188
Sorry, only registered users may post in this forum.

Click here to login