![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Jul 2004
Location: Location
Posts: 138
Rep Power: 5
![]() |
Form Code problem
Hi everyone,
I've written up the basic code for my get.php script, but it doesn't seem to be working. I keep getting error: undefined index in all the lines that $_POST is on. What could be wrong? HTML code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Coyote Product Submit Form</TITLE>
</HEAD>
<BODY>
<H3 ALIGN="center">Coyote website product submit form</H3>
<FORM ACTION="get.php" METHOD="post" ENCTYPE="text/plain">
<TABLE>
<TR>
<TD> <B>Location of product:</B> <INPUT NAME="Productl" TYPE="text" SIZE="20">
<BR>
<BR>
<B>Description:</B> <INPUT NAME="Description" TYPE="text" SIZE="20">
<BR>
<BR>
<B>Make:</B> <INPUT NAME="Make" TYPE="text" SIZE="20">
<BR>
<BR>
<B>Model:</B> <INPUT NAME="Model" TYPE="text" SIZE="20">
<BR>
<BR>
<B>Year:</B> <INPUT NAME="Year" TYPE="text" SIZE="20">
<BR>
<BR>
<B>Color:</B> <INPUT NAME="Color" TYPE="text" SIZE="20">
<BR>
<BR>
<B>Suggested list price:</B> <INPUT NAME="Suggested list price" TYPE="text" VALUE="$0.00" SIZE="15">
<BR>
<BR>
<B>Inventory Type:</B> <INPUT NAME="Inventory Type" TYPE="text" VALUE="Container, Truck, Reefer etc." SIZE="24">
<BR>
<BR>
<B>Serial #:</B> <INPUT NAME="Serial #" TYPE="text" VALUE="#" SIZE="30">
<BR>
<BR>
<B>Name of submitter:</B> <INPUT NAME="Full name" TYPE="text" SIZE="20"></TD>
</TR>
<TR>
<TD ALIGN="center"><INPUT TYPE="submit" VALUE="Submit" STYLE="color: #ffffff; background-color: #000000"></TD>
</TR>
</TABLE>
</FORM><A HREF="index.htm">Click Here</A> to submit another product to the site.
<BR>
<BR>
<BR>
<H3 ALIGN="center">Instructions</H3>
<BR>
<BR>
<H5>1: Enter all required information into the text box. Avoid leaving blank spaces.
<BR>
<BR>
2: Once you are completed, press the 'Submit' button. This will then open your e-mail client. Now you should see some text already already in the email.
<BR>
<BR>
3: Now, add an attachment to the email. The attachment should be picture of the object that you want to sell.
<BR>
<BR>
4: Send The email. (It will automatically be sent to the appropriate address)
<BR>
<BR>
5: If you need assistance understanding the text boxes, please visit <A HREF="submit_help.htm">This Page</A>
<BR>
<BR>
6: The information will soon be added to the site.</H5>
<BR>
</BODY>
</HTML>get.php <?php //Start of the PHP script $ProductL = $_POST["Productl"]; //Gets all the variables $Desc = $_POST['Description']; $Make $_POST['Make']; $Model = $_POST['Model']; $Year = $_POST['Year']; //Echo to the user echo "<BR /><b>Product Location:</b>$ProdductL"; echo "<BR /><b>Description:</b>$Desc"; ?> |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
$Make $_POST['Make']; // missing an = sign
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand." - B. Russell http://web.bryant.edu/~srk2 |
|
|
|
|
|
#3 |
|
Programming Guru
![]() |
get.php
<?php
if(count($_POST) > 0) {
//Start of the PHP script
$ProductL = $_POST["Productl"]; //Gets all the variables
$Desc = $_POST['Description'];
$Make $_POST['Make'];
$Model = $_POST['Model'];
$Year = $_POST['Year'];
//Echo to the user
echo "<BR /><b>Product Location:</b>$ProdductL";
echo "<BR /><b>Description:</b>$Desc";
} else {
echo "Failure or something";
}
?>
__________________
|
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Jul 2004
Location: Location
Posts: 138
Rep Power: 5
![]() |
Tempest, I tried your code and it constantly outputs the failure message. Any idea why?
|
|
|
|
|
|
#5 |
|
Programming Guru
![]() |
Because the page isn't being posted any POST data via a form.
__________________
|
|
|
|
|
|
#6 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
try switching to GET and see if that makes the problem clear
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand." - B. Russell http://web.bryant.edu/~srk2 |
|
|
|
|
|
#7 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
@tempest: Your code is also still missing an assignment operator. It might also be more useful to a confused or neophyte OP if you included some commentary in your response. Just a suggestion.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|