Jump to content



Recommended Posts

I've just started learning php today, but after installing XAMPP i wrote my first code but it came out only as text in the browser, i have tried all i know to resolve it no solution. Please i need help, kindly guide me.


<!DOCTYPE html> <html> <head> <title>Gathering Information</title> </head> <body> <?php $studentName = $_POST['studentName']; $grade = $_POST['grade']; $section = $_POST['section']; $classTeacher = $_POST['ClassTeacher']; echo '<p>Student Informtation</p>'; echo 'Student Name is ' . $studentName; echo 'He/She is in this grade: ' . $grade; echo 'he is also in this section: ' . $studentName; echo 'Is being taught by: ' . $classTeacher; ?> </body> </html>

Link to comment
Share on other sites

1) Don't post your problems on the Introductions page

2) Use <> button in toolbar when posting code

3) Format your code.

Before you process POST data, you need to check that data has been posted to the page and only process if it has. To check...

    // process data

Does the filename that contains that code end with .html or .php ?

Link to comment
Share on other sites

And learn to write your code in separate lines - makes it far, far easier to read, interpret and to maintain.

Another good plan would be to execute your php code FIRST and then to output the html code with the dynamic parts coming in the form of php vars that you build from that php logic you executed earlier in the script.



do php stuff like grabbing the posted data.

format some results into php vars

Now start echo-ing html code and inserting those php vars where you want the generated php results to show up.

then exit php.


Read up on using the heredocs construct.  Makes outputting html and php vars much much easier IMHO

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.