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
Section 4 - Working with HTML Forms
July 07, 2013 02:50PM
I've finished this section. I'm lucky in that I have a lot of HTML experience, but it's really nice to learn how to actually "submit" info without the limitations of basic email functionality posed with HTML.
Re: Section 4 - Working with HTML Forms
July 07, 2013 07:51PM
Hi ,

I'm still working through this section and noticed in the text book, page 153. The "Search" and the "Add" Submit buttons have the same name. Is this a normal practice?
Are there any other input types available? A list box would be useful.
avatar
Mac
Re: Section 4 - Working with HTML Forms
July 08, 2013 09:34AM
It can - it depends on the value.
Re: Section 4 - Working with HTML Forms
July 08, 2013 11:55AM
Hi,

Okay, it should sort itself out as we go on. I'll get onto the next part before I get behind.

Thanks!
Re: Section 4 - Working with HTML Forms
July 11, 2013 08:56PM
Worked threw this section. Struggled with a couple parts but will work threw this section again.
avatar Re: Section 4 - Working with HTML Forms
July 12, 2013 11:43AM
I am yet to get there..
eye rolling smiley
Re: Section 4 - Working with HTML Forms
July 12, 2013 05:02PM
I've completed this Section 4 , was tricky/ confusing but after practicing it , have a decent understanding.

"It's it and that's that" - Not sure who said it ( I might have thought if it, but could've heard it on tv or something)
avatar Re: Section 4 - Working with HTML Forms
July 14, 2013 05:52PM
Hi everyone
Question on:- Checking if the Submit Button of a HTML Form was Clicked.

Everything is working fine until I add the if (isset($_POST['Submit'])) { } code.

The code below this line does not get executed and I cannot see why. The code is below:

<html>
<head>
<title>A BASIC HTML FORM</title>

<?PHP
if(isset($_POST['Submit'])){
$username=$_POST['username'];

if($username=="letmein"winking smiley{
print("Welcome back friend!"winking smiley;
}
else{
print("You're not a member of this site"winking smiley;
}
}
?>
</head>
<body>

<FORM NAME ="form1" METHOD ="POST" ACTION = "basicForm.php">

<INPUT TYPE = "TEXT" VALUE ="username" NAME="username">
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login">

</FORM>
</body>
</html>


Does anybody else have this problem, or can anyone see the mistake that I just cannot see?
Help will be much appreciated.
Regards
Susan
Re: Section 4 - Working with HTML Forms
July 14, 2013 07:16PM
Hi Susan;

I think you forgot the closing bracket here, and this may be the reason your code is breaking

if($username=="letmein"{
Re: Section 4 - Working with HTML Forms
July 14, 2013 07:51PM
still busy with this section. Currently working on the 3 exercises.
avatar
Mac
Re: Section 4 - Working with HTML Forms
July 15, 2013 08:18AM
Use the formatted code button to post code else smiley's are shown making it difficult to pick up errors
avatar Re: Section 4 - Working with HTML Forms
July 15, 2013 09:44AM
Thank you Mac I will do in future.

Thank you Suzan, Yes it was the curly bracket. I had put it at the end of the php code instead of at the end of the line of code.

Have a great day all.
Regards
Susan
Re: Section 4 - Working with HTML Forms
July 15, 2013 01:10PM
Hi Guys

I am bit confused, the headings that you are using they don't really correspond to the manual I downloaded from http://php.net/download-docs.php.

I still have not received my study material till this day. Let me know if you are referring to "Dealing with Forms". Also can you let me know if maybe you are using the text book prescribed.

Thanks
M
avatar Re: Section 4 - Working with HTML Forms
July 15, 2013 02:05PM
Studying PHP is the best decision I made, I am loving ever moment of it.. Can
t wait to reach the OOP part because that what I am still trying to clarify..
LOL now using a HTML form makes sence......thumbs up smiley

@GOUWEM I too have not received any study material but I find this website extremely useful homeandlearn.. All you need is the internet bud, also have a look at w3schools..spinning smiley sticking its tongue out

I use about 3 differnet sources home and learn being my primary and an PHP ebook, plus I did PHP with codecademy before starting this course..
Re: Section 4 - Working with HTML Forms
July 15, 2013 02:28PM
Hi Gouwem, The topic subject, eg "Section 4 - Working with HTML forms"
Is reference to the courseware/ study material ( CD received from Unisa)


Until you receive it, Go to Homeandlearn.co.uk
As this is exactly the course we are all using.( It comes on the UNISA CD)
Re: Section 4 - Working with HTML Forms
July 16, 2013 09:34AM
Hi Sipho and Yusuf

Thanks for the feedback, after the reading through the forum yesterday I landed at homeandlearn.co.uk and i'm glad a now on the same page with you guys.

Currently on section 1 and I must say I will catch up slowly but surely. smile
Re: Section 4 - Working with HTML Forms
July 16, 2013 06:47PM
It was fun doing this section and I would love to go back to this section again in future. quite challenging codes...
Re: Section 4 - Working with HTML Forms
July 17, 2013 03:39PM
I have finally completed this section 4: Working with HTML Forms.

I must say it can get quite code intensive when it comes to radio buttons and check-boxes when you want to display the result to the user.

I particular found printing into text-boxes much easier than i initially thought.

On to the next section.

S
Re: Section 4 - Working with HTML Forms
July 18, 2013 04:10PM
Completed section 4! All good! grinning smiley
So much hassle to get a radio button / checkbox to stay checked!
Re: Section 4 - Working with HTML Forms
July 18, 2013 04:14PM
Hi all. SK, with radio buttons and check boxes. Code it as Boolean ! If checked = True. Unchecked= False . Helps a lot when it come to validation of the form.

Also what I found what's pretty nice in forms are Placeholders. Will give a different look to a form.
avatar Re: Section 4 - Working with HTML Forms
July 18, 2013 09:29PM
I have finished this section. I found it rather difficult and needed to refer to the text book and some other online tutorials.

One site I can highly recommend is :- http://thenewboston.org/list.php?cat=11
They have 200 php tutorial videos, all very well presented.
Re: Section 4 - Working with HTML Forms
July 18, 2013 11:03PM
@Susan
Thanks for recommending thenewboston.org
Realized I subscribed to their YouTube channel last year sometime.Totally Forgot about it.
Didn't know their was a website.Going to check it out
Re: Section 4 - Working with HTML Forms
July 18, 2013 11:17PM
I thought this was a pretty cool and well explained section.
Re: Section 4 - Working with HTML Forms
July 21, 2013 10:44AM
Section very well explained, Correct me if I am wrong but when it comes to form validations the most practical code to use Will be JavaScript. But knowing how to validate it with PHP make me sleep better at night cause you won't know if the users will have Java disabled on there Pc. HTML5 has is own built in validations but I won't trust it!!
avatar Re: Section 4 - Working with HTML Forms
July 21, 2013 03:47PM
The most practical ("best"winking smiley solution is to have both client-side (JavaScript) and server-side (PHP) validation.

As you have mentioned, it is possible to disable JavaScript. Bear in mind that there are also non-HTML5 compliant browser (IE) users out there, which will just ignore any HTML5 validation.
Re: Section 4 - Working with HTML Forms
July 21, 2013 03:50PM
Hey,

I have done this exercise. Then tried again, and tried again. But it seems everytime I get to the if(isset($_POST['Submit])) step, it just stops working.

I did see Susan's post, but couldn't find my solution there. Can anyone else see my mistake?

Here is my code;


Language: PHP
<html> <head> <title> A BASIC HTML FORM </title>   <?PHP   if(isset($_POST['Submit'])){   $username = $_POST['username'];   if($username=="letmein"){ print("Welcome back, friend!"); } else{ print("You're not a member of this site"); } }   ?>   </head> <body>   <FORM NAME="form1" METHOD="POST" ACTION="basicForm.php">   <INPUT TYPE="TEXT" NAME="username" VALUE="username"> <INPUT TYPE="Submit" NAME="Submit1" VALUE="Login">   </FORM>   </body> </html>
avatar Re: Section 4 - Working with HTML Forms
July 21, 2013 05:19PM
Hi Elizabeth

Yep, that is exactly the same mistake I made. It is the very first closing curly bracket. It needs to be closed after the first line of code and not at the end of the code.
eg:
Language: PHP
if(isset($_POST['Submit'])){ }


Then remove one of your closing curly brackets from the end of your code.

Regards
Susan
avatar Re: Section 4 - Working with HTML Forms
July 21, 2013 05:44PM
I have just gone back to look at this code in the tutorial. The chapter "Checking if the Submit Button of a HTML Form was Clicked" gives the following example:

Language: PHP
if (isset($_POST['Submit'])) {   $username = $_POST['username'];   if ($username = = "letmein") { print ("Welcome back, friend!"); } else { print ("You're not a member of this site"); } }

This is why we are getting confused with this section. Perhaps an error in the tutorial?
Re: Section 4 - Working with HTML Forms
July 21, 2013 06:08PM
Hi Susan,

Thank you. Will definitely have a look at it again, though I think I did try that.

Agree that there might be a error in the tutorial. Copy and pasted the code from the tutorial and had the same problem.

Hopefully once I get the prescribed book things will go better. =)
Re: Section 4 - Working with HTML Forms
July 21, 2013 06:20PM
Hi Elizabeth,

You have named your <INPUT TYPE="Submit" NAME="Submit1" VALUE="Login">
try using Submit1 instead of just 'Submit' in if(isset($_POST['Submit'])){}.

Regards Charles
Re: Section 4 - Working with HTML Forms
July 21, 2013 08:22PM
Hi Susan. In that code you posted your == has a space in-between the equals sign. Take take the space out.

If($username =='letmein'){}

It will work smiling smiley

Let me knowsmiling smiley

Willem
avatar Re: Section 4 - Working with HTML Forms
July 21, 2013 10:39PM
All you need to check if a form has been submitted is that the POST array is not empty.

So if ( $_POST ) works just fine.


It is not really necessary to check isset, or a specific input.
Re: Section 4 - Working with HTML Forms
July 21, 2013 11:06PM
@Elizabeth - 78124018

Ja, 78044545CharlesU is spot on.
Only error I can see is on line 9 where you have
Language: PHP
if(isset($_POST['Submit'])){

should be
Language: PHP
if(isset($_POST['Submit1'])){

to correspond with name you have given to your submit button on line 29
avatar Re: Section 4 - Working with HTML Forms
July 22, 2013 09:30AM
Your php script is misinformed, its searching for a button named "submit" mean while on your html form you named the button "submit1".

Sorry for the late reply, I do not have internet (as yet) at home, I see everything on my blackberry and I unfortunately cant reply from there, the forum doesn't allow me. I finally received my study material and was glad to find there is an offline version of the Home and Learn website in the companion CD..thumbs up smiley
Re: Section 4 - Working with HTML Forms
July 22, 2013 11:57AM
Re: Section 4 - Working with HTML Forms
July 22, 2013 01:18PM
Susan 70254443 Wrote:
-------------------------------------------------------
> Hi Elizabeth
>
> Yep, that is exactly the same mistake I made. It
> is the very first closing curly bracket. It needs
> to be closed after the first line of code and not
> at the end of the code.
> eg:
>
Language: PHP
> > if(isset($_POST['Submit'])){ > } >
>
>
> Then remove one of your closing curly brackets
> from the end of your code.
>
> Regards
> Susan


Hi Susan,
If you close the curly bracket right after the first line like in your example you're closing the IF statement.

So instead of having :
Language: PHP
if(condition) { execute this code }

You'll have :
Language: PHP
if(condition) { } execute this code

So your solution might get the code to work but it is not actually checking now if the submit button has been clicked.
The problem was, as others have already said, that it should have been isset($_POST['Submit1']) as the name of the submit button is "Submit1"

Hope this helps!! smile
Re: Section 4 - Working with HTML Forms
July 22, 2013 08:07PM
almost done with section
Re: Section 4 - Working with HTML Forms
July 23, 2013 05:26PM
had no problems completing this section:
there is nothing more exciting than creating a web page that interact with the user...
avatar
Mac
Re: Section 4 - Working with HTML Forms
July 23, 2013 05:34PM
glen78134323 Wrote:
-------------------------------------------------------
> had no problems completing this section(Tu)
> there is nothing more exiting that creating a web
> page that interact with the user...

I have to agree. The first time I managed to insert data captured by a form into a db and extract it was the day I said to my wife - I am changing career (I was in sport back then). BTW, I have worked in industry, so do not fool yourself why am I not in industry... just choices. Suffice to say that.... no. I'll keep it at that. What I will say though is this - if you have the guts, work for yourself. But it will take time to get to that point. It is a journey. My hope is that this course excites you enough to believe it.
Re: Section 4 - Working with HTML Forms
July 23, 2013 07:14PM
Mac

Wise words

M
avatar Re: Section 4 - Working with HTML Forms
July 23, 2013 07:34PM
Hi Everyone

Thanks so much for all the input. I really thought it was the curly bracket in the wrong place, however, when I started on section 5 and saw the same curly bracket in the same place, I was stumped.
Problem solved it is the name of the submit button.
Re: Section 4 - Working with HTML Forms
July 24, 2013 09:57AM
Hi Guys

Could some one please post the correct scripts for the 3 exercises on Data Retention.

Here's what I got so far and I'm not sure if it's right or wrong because the script's seem to be working.

Exercise 1

Language: HTML
<html> <head> <title>Data Retention Exercise One</title>


Language: PHP
<?PHP   $username = $_POST['username'];   if ($username == "James") {   print ("James");   }     if ($username == "Howlett") {   print ("James Howlett");   } else{   print("");   }   ?>



Language: HTML
</head> <body>   <FORM NAME ="form1" Method ="POST" ACTION ="DataRetentionExerciseOne.php">   <INPUT TYPE = "TEXT" VALUE ="First name" Name = "username"> <INPUT TYPE = "TEXT" VALUE ="Surname" Name = "username"> <INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login">   </FORM>     </body> </html>


Exercise 2

Language: HTML
<html> <head> <title>Data Retention Exercise Two</title>


Language: PHP
<?PHP     $username = $_POST['username'];     if ($username =="James") {   print ("");   }   if ($username == "Howlett") {   print ("");   } else{   $username ="";   }     ?>



Language: HTML
</head> <body>   <FORM NAME ="form1" Method ="POST" ACTION ="DataRetentionExerciseTwo.php">   <INPUT TYPE = "TEXT" VALUE="James" Name = "username"> <INPUT TYPE = "TEXT" VALUE="Howlett" Name = "username"> <INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login">   </FORM>     </body> </html>

Exercise 3

Language: HTML
<html> <head> <title>Data Retention Exercise Three</title>



Language: PHP
<?PHP   if (isset($_POST['Submit1'])){   $username = $_POST['username'];     if ($username =="James Howlett"){   print ("Welcome back, friend!");   } else{   print ("You're not a member of this site");   }   } else{     $username="";   }         ?>



Language: HTML
</head> <body>   <FORM NAME ="form1" Method ="POST" ACTION ="DataRetentionExerciseThree.php">   <INPUT TYPE = 'TEXT' Name ='username' VALUE="<?PHP print $username ; ?>"> <INPUT TYPE = 'TEXT' Name ='username' VALUE="<?PHP print $username ; ?>"> <INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login">   </FORM>     </body> </html>
Re: Section 4 - Working with HTML Forms
July 24, 2013 10:38AM
Finished this section.
I found it also a bit difficult, but got some direction from the textbook. Now onto Loopsthumbs up
avatar Re: Section 4 - Working with HTML Forms
July 24, 2013 10:53AM
@78183294

If your script is running well, yes you probably are doing it right.

You know you're doing the right thing if the script gives you the correct results not undesired ones i.e if you try to log in and get no feedback then you know you need some coffee, patience and elbow grease to debug.grinning smiley

To properly grasp the concept I suggest coming up with your own scenarios and using what you've learned to generate solutions........thumbs up
avatar Re: Section 4 - Working with HTML Forms
July 24, 2013 10:58AM
@Zelda-78024447

Keep up the good work and double up the elbow grease..thumbs up smiley

Remember if it gets sticky!! wear you hat inside out and take a short nap and get back to it.. If you still stuck, you're welcome to drag us into your pit ..lol smiling bouncing smiley
Re: Section 4 - Working with HTML Forms
July 24, 2013 01:24PM
Still busy with this section and its quiet tricky.

Will have to revise it again. Thanks Sipho for your encouragement some of the task I did not get a errors and everything was up to the point but i'm nervous about being able to read the code myself and remember, on the site they will write the code for me and explain it also give the meanings, it get easier but I will have to remember myself so I guess it will come with practice.

eye popping smiley
Re: Section 4 - Working with HTML Forms
July 24, 2013 01:31PM
@72903694 Sipho,

Thanks for the heads up! Will definitely take you up on that onegrinning smiley

My office view is the sea, so I just drift off staring, and then start back up when I have time at work for PHPsmileys with beer
Re: Section 4 - Working with HTML Forms
July 25, 2013 10:18AM
Question about validating HTML Form posted data..

When data is posted by a user via a textbox, How does one deal with garbage that the user might post / send into your database.
e.g When a textbox requires a username and the user post something like this: gahsdxehfdg

How do you protect your DB from storing such garbage..?
avatar
Mac
Re: Section 4 - Working with HTML Forms
July 25, 2013 10:41AM
Write a really complex regex expression... but nearly impossible

http://stackoverflow.com/questions/1759746/php-regular-expression-to-filter-out-junk
Re: Section 4 - Working with HTML Forms
July 27, 2013 03:57PM
Completed this section today and did the exercises. I now have 21 scripts in total that I have worked on. I copy the examples and change them to make sure I understand what they are doing, or add something extra .
Had a lot of fun with this section!
I found this section more challenging as I am unfamiliar with html. Did not experience any problems, just sometimes struggling to keep track of the _ / -, brackets and ;
Looking very much forward to loops (have worked with them before)
Sorry, only registered users may post in this forum.

Click here to login