Current location: Hot Scripts Forums » Programming Languages » PHP » [SOLVED] Posting Problem


[SOLVED] Posting Problem

Reply
  #1 (permalink)  
Old 04-24-08, 01:49 AM
Frznagn Frznagn is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] Posting Problem

Noob Alert. I'm following a tutorial on form processing and I'm having problems.

I have xampp installed locally and I run the code without any problems, but when I use the same files on my server, I get a 404 Error. The file is there. What gives?

Since I get it working locally, I take it nothing is wrong with the code so posting it here would be useless. I shouldn't have to do any sort of chmod on it, right?
Reply With Quote
  #2 (permalink)  
Old 04-24-08, 03:29 AM
blinn_shade's Avatar
blinn_shade blinn_shade is offline
Aspiring Coder
 
Join Date: Aug 2007
Posts: 540
Thanks: 0
Thanked 0 Times in 0 Posts
Lets see the code. Your host might need to change some php settings or soemthing.
__________________
Can you think outside the box but remain inside the box?
Reply With Quote
  #3 (permalink)  
Old 04-24-08, 08:09 PM
Frznagn Frznagn is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Zeee code....

This is from tizag.com

The order file:
HTML Code:
<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>
And the process.php file:
PHP Code:

<body>

<?php
$quantity 
$_POST['quantity'];
$item $_POST['item'];

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

?>
</body>
Just a basic copy/paste from their site. I tried other examples with the same results. I decided to give up and seek help. You can only bang your head against the keyboard for so long, ya'know what I mean?
Reply With Quote
  #4 (permalink)  
Old 04-24-08, 08:16 PM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
Have you tested static pages to make sure that your host is actually configured properly?
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Reply With Quote
  #5 (permalink)  
Old 04-24-08, 08:31 PM
Frznagn Frznagn is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Not sure what you mean by static pages. I do have other .php pages running without a problem.

Here , and here.

The only problem I've had so far is with the Post command. Odd?
Reply With Quote
  #6 (permalink)  
Old 04-24-08, 08:52 PM
Frznagn Frznagn is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
PHP settings on server:

Optimization: Alternate PHP Cache (APC)
Memory limit: 32 mb
Safe mode: Yes
Register Globals: No
Display Errors: Yes
Allow URL Fopen: No

Should I take it off Safe Mode?
Reply With Quote
  #7 (permalink)  
Old 04-24-08, 08:57 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Make sure any capitalization of file names matches what the action="..." parameter is.

Also, are you doing any URL rewriting? Alaska in one of your links is redirected back to Alaska when I entered alaska.

In fact, entering your_domain/process.php gets redirected to your_domain/Process.php with the resultant output -

Quote:
You ordered .
Thank you for ordering from Tizag Art Supplies!
Edit: Based on the above, I would say you have a .htaccess file that is playing some un-necessary games that is preventing the form from submitting to the form processing code.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???

Last edited by mab; 04-24-08 at 08:59 PM.
Reply With Quote
  #8 (permalink)  
Old 04-24-08, 08:57 PM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
I wouldnt have thought so no. save the following as test.php in your public_html folder on your server
PHP Code:

<?php
if(isset($_POST['txt']))
    
$txt 'You typed '.$_POST['txt'];
?><!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>Test page</title>
</head>

<body>
<div id='txt'>
<?php
if(isset($txt))
    echo 
$txt;
?>
</div>
<form id="form1" name="form1" method="post" action="">
  <p>
    <input type="text" name="txt" id="txt" />
</p>
  <p>
    <input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" />
</p>
</form>
</body>
</html>
tell me if that works

EDIT: Static page is a page without dynamic/changing content
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Reply With Quote
  #9 (permalink)  
Old 04-24-08, 09:12 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
In fact, upon further testing by putting a copy of your form on my server, using an upper case P in Process.php allows it to submit (lower case p in process.php gets the 404 page.)

Your .htaccess if probably doing something with 'HTTP_REFERER' and a rewrite rule to capitalize the first letter of the file name, but when 'HTTP_REFERER' either does not exist or does not match, it leaves the file name alone and it does not match the actual file present on the server.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
  #10 (permalink)  
Old 04-24-08, 09:47 PM
Frznagn Frznagn is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
mab: Success! I changed it to a capital letter and it works fine! I'm embarrassed that it was such a simple fix, but happy to comprehend the problem. I was afraid it'd be really technical!

Jay: Yes, that code works. And does this count as a static page?

Thanks for all the help and the fast response! Is it any wonder why I visit this site every day?

Now to figure out how to mark this as solved....
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pls help website problem! iangarrinud CSS 1 01-03-08 01:48 PM
suggest software to assist posting qts and seeing replies on this site. janicefernandes Script Requests 2 03-17-07 06:37 AM
login, roles problem dbrook007 ASP.NET 10 11-10-06 03:42 PM
Form Display Problem neevrap02 Visual Basic 1 09-05-06 05:18 AM
Asp and Microsoft Access 2002 problem gop373 ASP 2 10-06-04 09:13 AM


All times are GMT -5. The time now is 07:43 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.