Tuesday, July 28, 2009

How can I make a php form open the entered information in a new window?

I have a form on a website that when information is entered into it, I want the inputted information to be opened in a new window. How can I do this?

How can I make a php form open the entered information in a new window?
Why aren't you using the php support docs if you're a web programmer? It's all there.
Reply:Check out php.net to find out how to make the new window.





However, I know how to get the information to come up.





Your HTML:





%26lt;form action="action.php" method="post"%26gt;


%26lt;input type="text" name="test1" /%26gt;


%26lt;input type="submit" value="Submit" /%26gt;


%26lt;/form%26gt;





It doesn't have to look exactly like that, but make sure that:


1. "action.php" can be replaced with whatever (.php). You have to make sure to name your PHP file whatever you replace it with, though.


2. The method="post" is in the form tag.


3. Each input must have a name (unless it's "submit")





PHP code (action.php)





%26lt;?php





$test1 = $_POST['test1']





echo "%26lt;html%26gt;


%26lt;head%26gt;


%26lt;title%26gt;Show the Info%26lt;/title%26gt;


%26lt;/head%26gt;


%26lt;body%26gt;


%26lt;h1%26gt;Show the Info%26lt;/h1%26gt;


$test1


%26lt;/body%26gt;


%26lt;/html%26gt;";





?%26gt;





MAKE SURE:


1. You don't put double quotes anywhere in the HTML code that's being echoed (except at the end and at the beginning).


2. See the $_POST['test1']? That's from the POST array. You can put the name of any input in between the single quotes.


3. Set a variable for each input, like this:





$test1 = $_POST['test1'];


$test2 = $_POST['test2'];





4. If you don't put the variables ($test1, etc.) in the HTML that's echoed, they won't show up.





5. DON'T FORGET THE SEMICOLONS where they are.
Reply:With the target attribute on the form element (that PHP generates the markup is irrelevant, you're influencing the client, not the server here).





I'd advise against it though, http://diveintoaccessibility.org/day_16_...


No comments:

Post a Comment