Welcome! Log In Create A New Profile

Advanced

course_man.php

Posted by 77928490 
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
course_man.php
April 22, 2013 04:01PM
Hi All,

I emailed a query to Mac about the interface. The tutorial stipulated all code for the course_man.php file should be within the file so I had the notion in my mind no additional php files are allowed. Mac sent me a response which is further below. Essentially I thought of adding submit buttons for each 'Delete', 'Edit' and 'Add' option per course (See image link below). The problem I encountered was how to retrieve the cid for each course. I worked around it by adding the cid to each submit button name, thus individualizing it. It worked by using a function called preg_match (way overkill). Yay at least it worked I guess!!! In hindsight it deviates from what our project is trying to see if we understand...i.e. what we learnt in the online tutorials.



So below is the response from Mac.



It is easier to just use an
Language: HTML
<A href…..>Delete</a>
link as opposed to a form e.g.
Language: HTML
<A href=delete.php?cid=$cid&Delete=yes>Delete</a>
. Then you have the cid available to run the delete query. The use of preg functions is a bit overboard here.



I trust this helps some.

Hope your portfolio projects are progressing well. Finding it really interesting. Found myself staying up till 4am a few times just to get the code right. Exhausted.

Cheers
Ian
Re: course_man.php
May 09, 2013 07:48AM
Hi Mac,

Following on from above, I have now created a student_man.php where I pass a variable to delete.php.

Language: PHP
<a href=';delete.php?sno=db_field[';sno';]';>Delete</a>

One query is why do I need to use $_GET to retrieve the variable in delete.php when the form method is 'POST' in student_man.php?

Another query is why you use Delete=yes in your suggestion above?

However my main query has to do with delete.php.

In delete.php I read the value passed from student_man.php using $_GET.

I then create a form in delete.php with method POST and action 'delete.php'. The student to be deleted is printed in a table in this form.

I then create a 2nd form in delete.php with method POST and action 'student_man.php'.

In this 2nd form I create a submit button to 'delete' and the SQL query to delete the student. I found I had to create a hidden type to store the $_GET value passed from student_man.php, otherwise it gets lost when the submit button is pressed.

The problem is when submit button is pressed, the SQL query is not executed and the page jumps from delete.php to student_man.php.

If I change the action value to 'delete.php' then the SQL query is executed but does not jump to student_man.php

Please could you assist.

Thanks Ian
avatar
Mac
Re: course_man.php
May 09, 2013 05:43PM
> One query is why do I need to use $_GET to retrieve the variable in delete.php when the form method is 'POST' in student_man.php?

Just an example - I used a <a href link which is always GET. You wanna use a form, then do so but it it easier to use GET in this instance

> Another query is why you use Delete=yes in your suggestion above?

Because I will test for the presence of a variablewith name Delete and with value yes. You can use whatever you want Dog=woof, cat=Maaui, as long as you keep with the case. You also do not have to assign a value, but better to do so.

However my main query has to do with delete.php.

> In delete.php I read the value passed from student_man.php using $_GET.
Yes

> I then create a form in delete.php with method POST and action 'delete.php'. The student to be deleted is printed in a table in this form.

Why?

Language: PHP
//<A href=delete.php?cid=$cid&Delete=yes>Delete</a>   //on delete page you simply have   $Delete=$_GET[';Delete';]; $cid=$_GET[';cid';]; if($Delete==';yes';) {   //query e.g. DELETE FROM... WHERE cid=';$cid';

Why the extra form? You do not want to edit, you simply want to send the cid an delete.

P.S. I'm rushing here - nearly 17h45 and I have to take my kind somewhere.... Hope I read it correctly...
Re: course_man.php
May 09, 2013 07:38PM
Thanks Mac,

Yes you read it correctly. Thanks for the assistance.
Re: course_man.php
May 09, 2013 08:15PM
Hey Mac

One last query on this.

I execute the above perfectly as you showed above. Thanks.

But how do I return from the delete.php file back to student_man.php. I hope this is not too stupid a question but starting to panic a bit here so not thinking too clearly.
Re: course_man.php
May 09, 2013 09:04PM
Not too worry, got it working.

Thanks for your help.
Re: course_man.php
May 10, 2013 11:06PM
Hi Mac

Still busy with the student_man.php file.

I managed to get the delete.php file working for deleting students. Thanks. Now working on the edit.php file.

I can see why the delete.php file did not need to be in a form with a submit button as you mentioned above.

However surely the edit.php file would need a submit button to upload edited student information.

When in student_man.php, I pass the student id to the edit.php file in a href link and using $_GET.

But when the submit button in edit.php is clicked, the array for $_GET is cleared so can't update student table.

Surely information can be stored from $_GET without an error when a submit button is pressed. I used a hidden type input as well. Did not work.

Is there a better strategy to edit student information?

Thanks in advance for your assistance.

Regards
Ian
Re: course_man.php
May 11, 2013 12:38AM
found solution!!

Language: PHP
http://www.c-sharpcorner.com/UploadFile/satyapriyanayak/how-to-insert-edit-and-delete-in-php/
Re: course_man.php
May 14, 2013 02:30PM
Are we allowed to have more than the 4 main pages ?? Like a Edit.php, Delete.php ? I have code everything into 4x pages so far....

Student Number: 78042879 (Part Time Courses)
avatar Re: course_man.php
May 14, 2013 03:07PM
Same with mine. I also used only the 4 pages asked for by the tutorial letter.


35316462_Antondev Wrote:
-------------------------------------------------------
> Are we allowed to have more than the 4 main pages
> ?? Like a Edit.php, Delete.php ? I have code
> everything into 4x pages so far....
Re: course_man.php
May 14, 2013 10:30PM
Hi guys,

Yes, there are 4 main pages (4 main links) but their more associated pages to this 4 links.

78026962 afojonny
Re: course_man.php
May 15, 2013 08:21AM
the 4 pages are set standard pages. but you will definitely have more. I've worked with different people coding in PHP, you will be surprised by different approach they take to solve 1 same problem.
sometimes a user wont even see a difference, but if you look at the code, it is totally different.
Sorry, only registered users may post in this forum.

Click here to login