Welcome! Log In Create A New Profile


PHP and HTML on one document

Posted by 07813619-Henk 
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
PHP and HTML on one document
August 24, 2012 03:53PM
Hi everyone

I am busy with Assignment 1.
I am trying to combine all my HTML and PHP on one document, and saving it as a PHP extension.
Am I correct in my assumption that this is more professional or preferable than doing separate HTML and Phip docs?

example: for strings section of the assignment where we need to use 10 string functions, I would have the form part where I ask the user for his input (HTML and JAVASCRIPT) as well as the PHP on the same doc, and distinguish between the 2 parts by seeing if the PHP variables are empty or not (they mos get populated by the POST part of the HTML form).

Why I'm asking, is I'm having difficulties with trying to do it so neatly.

If I use a input button to submit (instead of a "submit" button), (so I can to javascript validation of the text before I call the PHP part) I need to do "form,submit()" in order to get it to submit. But then my PHP variables are actually empty?
how to solve, that is the question.......

If I've not confused everybody now, can someone maybe point me in a direction?

H Maritz
Re: PHP and HTML on one document
August 27, 2012 07:32AM
Having HTML and PHP on the same page is much easier accomplished. Why use JavaScript for form submission? It is a simple form submit, PHP test if the form has been submitted, and catch the information send by the form. USe if/elses
Re: PHP and HTML on one document
August 27, 2012 11:00AM
Hi Mac

The reason I'm using Javascript too, is to validate the text the user typed in. I ask him to enter a word with an "a" in it, then the php will convert the "a" to an "e".
I'm not sure if (and how) PHP can check the user's input, and how to return him back to the html part if it wasn't correct,
so it's just easier to check with javascript.
problem is you can't use a submit button and onclick call a javascript function to validate.
you have to use a normal button.
which then doesn't populate the php variables.

But don't worry, I'll just change my design to work differently and try to validate it with PHP itself, or otherwise not validate text input at all, and just submit it. thanks for the reply.
Re: PHP and HTML on one document
August 30, 2012 02:19PM
Which assignment or where to find it bra help me???????????????????????
Re: PHP and HTML on one document
August 30, 2012 02:23PM
Masixole, I suggest you read your tutorial letter.......
Sorry, only registered users may post in this forum.

Click here to login