FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Forms





Ndogg
How come this doesnt work?

order.html
Code:
<html><body>
<h4>Tizag Art Supply Order Form</h4>
<form action="process.php" method="post">
<select name="item">
<option>Paint</option>
<option>Brushes</option>
<option>Erasers</option>
</select>
Quantity: <input name="quantity" type="text" />
<input type="submit" />
</form>
</body></html>



process.php
Code:
<html><body>
<?php
$quantity = $_POST['quantity'];
$item = $_POST['item'];

echo "You ordered ". $quantity . " " . $item . ".<br />";
echo "Thank you for ordering from Tizag Art Supplies!";

?>
</body></html>



It should display the information typed in the form on t Process.php page.
sonam
Hmmm, your order.html and process.php are looking good, only what I see you don't need <body> and <html> tags in process.php. Maybe this cause problem. Did you try this script at real hosting or on your localhost?

Sonam
Ndogg
That didnt make a difference, also, Im using this on this host.
mathiaus
The code is all Ok.

What is it doing for you? Do you a blank page or just missing the quantity and type?
sonam
Try to put this lines on the top of your process.php and post here if you get some error.

Code:
error_reporting(E_ALL);
ini_set("display_errors", "1");


Sonam
rvec
try replacing <option> with <option value="Paint">.
Ndogg
mathiaus wrote:
The code is all Ok.

What is it doing for you? Do you a blank page or just missing the quantity and type?


Blank Page


sonam wrote:
Try to put this lines on the top of your process.php and post here if you get some error.

Code:
error_reporting(E_ALL);
ini_set("display_errors", "1");


Sonam


When I put that code above the <php script... w/e it is lol
All I see is the code(Error code, not the php stuff)

I also tried putting that in with the <php... but that didnt do anything, all I saw was a blank page again.



rvec wrote:
try replacing <option> with <option value="Paint">.


Like this:

Code:
<option value="Paint">Paint</option>
<option value="Brushes">Brushes</option>
<option value="Erasers">Erasers</option>


Didnt make a difference.
imagefree
Ndogg wrote:
How come this doesnt work?

order.html
Code:
<html><body>
<h4>Tizag Art Supply Order Form</h4>
<form action="process.php" method="post">
<select name="item">
<option>Paint</option>
<option>Brushes</option>
<option>Erasers</option>
</select>
Quantity: <input name="quantity" type="text" />
<input type="submit" />
</form>
</body></html>



process.php
Code:
<html><body>
<?php
$quantity = $_POST['quantity'];
$item = $_POST['item'];

echo "You ordered ". $quantity . " " . $item . ".<br />";
echo "Thank you for ordering from Tizag Art Supplies!";

?>
</body></html>



It should display the information typed in the form on t Process.php page.


after submitting the form, if it shows blank bage, look at the source of the page. Is it something like


Code:
<html><body></body></html>

???
Aredon
Firstly,
Code:
<option value="Paint">Paint</option>
<option value="Brushes">Brushes</option>
<option value="Erasers">Erasers</option>
Is the correct method, and you should use it anyway.

I copied your code onto two files on my site to play around with. The code works correctly for me. You might try adding a DOCTYPE and such...
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
Stuff
</body>
</html>
Ndogg
That didnt make a difference either Sad

When I click on the order.html file to look at the page and test it, before the changes are updated, I have to refresh the page. Could this be why when I click submit, the process.php page is update and when I click refresh all the form info is reset?

I dont know whats wrong!
Ndogg
wait, it cant be the coding at all, its something else because it doesnt even write the text

echo "Thank you for ordering from Tizag Art Supplies!";

which isnt hard to do at all.


My text isnt displaying wth php, or is it because the text is displayng white and the bg is white?
rvec
it has to be something with php, else you would've seen a different source.

Code:
error_reporting(E_ALL);
ini_set("display_errors", "1");


That part should be set between the <?php and ?> tags.
and after that try var_dump($_POST);
if that doesn't give any output there's something breaking the script somehow.
Ndogg
Code:
<?php
error_reporting(E_ALL);
ini_set("display_errors", "1");
var_dump($_POST);

$quantity = $_POST['quantity'];
$item = $_POST['item'];

echo "You ordered ". $quantity . " " . $item . ".<br />";
echo "Thank you for ordering from Tizag Art Supplies!"
?>


I dont get any error at all, so what could cause this?
sonam
Try to put ";" (without quotes) on the end of last line. Maybe this cause problem.

Code:
echo "Thank you for ordering from Tizag Art Supplies!" ;


Sonam
Ndogg
theres something wrong with using echo variable, because I asked this question somewhere else and got every possible way to type out that and they all didnt work but sometimes it shows just the bottom line, but not correctly(it shows everything after the first line).
rvec
If the var_dump didn't return anything there's nothing wrong with the echo part, but the mistake is already made in the form.
imagefree
Ndogg wrote:
Code:
<?php
error_reporting(E_ALL);
ini_set("display_errors", "1");
var_dump($_POST);

$quantity = $_POST['quantity'];
$item = $_POST['item'];

echo "You ordered ". $quantity . " " . $item . ".<br />";
echo "Thank you for ordering from Tizag Art Supplies!"
?>


I dont get any error at all, so what could cause this?


do a trick, add the following line before the error_reporting, so that you can see everything outputed on the screen.

Code:
header('Content-Type: text/css');


browser will take everything as css and will display it on the screen. It will make debugging easy.
Aredon
Perhaps you should link us the pages on your site so that we can test them to make sure it's not something simple like your browser cache.
Marcuzzo
you are not assigning values to your options....
this works
order.html
Code:
<html><body>
<h4>Tizag Art Supply Order Form</h4>
<form action="process.php" method="post">
<select name="item">
<option value="Paint">Paint</option>
<option value="Brushes">Brushes</option>
<option value="Erasers">Erasers</option>
</select>
Quantity: <input name="quantity" type="text" />
<input type="submit" />
</form>
</body></html>


when I select brushes and enter 16 I get:
Quote:
You ordered 16 Brushes.
Thank you for ordering from Tizag Art Supplies!
Ndogg
I think you guys should just test my form, nothing ever happens:

http://www.wowguides.frihost.org:2222/CMD_FILE_MANAGER/domains/wowguides.frihost.org/public_html/order1.html
mathiaus
The preview link in Direct Admin does not parse PHP. Use the correct link and you'll find it works.

http://www.wowguides.frihost.org/order1.html
Ndogg
With that it opens it in notepad and shows the coding, how do I change that?
mathiaus
Right click -> Save As (just save to desktop)
Right Click icon on Desktop -> Open With, select IE or Firefox (or whatever browser you use) and select the Always use this option box
rockacola
umm... it works for me =_=

Quote:

You ordered 5 Paint.
Thank you for ordering from Tizag Art Supplies!


Did it just got fixed or is it just me?
Ndogg
Its fixed, thanks guys.
Aredon
There wasn't anything to fix, php just wasn't being processed from where he was viewing it.
Ndogg
Well, ya, but you guys helped.
Related topics
basic tutorials on most forms of web programming
"Forms To Go" create scripts in PHP, ASP and Perl
Easily create forms and many other stuff without much knowle
Multiple Forms
I have a question regarding forms and such.
Anyone that can give me help/suggestions for forms?
Flash Tutorials
Building Web Forms In Flash
a question about forms. [SOLVED]
Question about forms on websites?
I am having alot of trouble with forms! Urgent help please!
PHP Forms security
Forms
Did earth's life forms come from Mars?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.