problem with posting form data to new page


I am currently working through some tutorials on PHP, and am stuck. I am creating a from that allows users to input information, and then I want to use this information to "create " an HTML page. I have made a form with the variables so the user can enter the information and it is here I get stuck.
What is the code to capture these variables so I can use them , and open a new page with the result

this is my form…

// This is a form that asks the user to input some items to be used in generating a //web page.

Your Heading:
Type your BackGround Colour
Type Your Font Colour
Enter the text for your Web Page

This appears to work OK.
newPage.php is the page into which I would like to use the variables.
My efforts with this so far are…

<style type = "text/css">

background: $bgColour;
color: $fontColour;

global $heading;
print "$heading";



global $bodyText;
Print "$bodyText";



One must understand that this isn’t near finished. My problem is that I can’t seem to get the variables from the form to appear in the newPage.php. Any Ideas so I can finish this exercise???

Help much Appreciated,

First of all, the use of ‘global’ is not recommended. It would be best to leave it out. I’m not sure what the security implications are of using it, though.

What you’re looking for, is the following:

[php]$myVar = $_POST[‘myVar’];
echo $myVar;[/php]

The $_POST array is a superglobal (?) variable, and it grabs all POST values (ie. values sent through POST from a form).

It’s best practice (and security-wise higly recommended) to use the (super)global variables $_GET, $_POST, $_COOKIE, $_SERVER and $_SESSION over the ‘global’ keyword, or grabbing user input directly, by enabling register_globals.

On a sidenote: watch out for the various types of injection (SQL, CSS, etc.).

Thanks, that seems to clear up most od the problems. If I can’t get the others ironed out I will be back… :wink:

No problem, we’ll take’em on :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service