View previous topic :: View next topic |
Author |
Message |
PWD -
Joined: 04 Jan 2005 Posts: 34 Location: trying to conquer these fears I thought were GONE
|
Posted: Mon Jan 17, 2005 6:20 am Post subject: Can't locate "form action"..hmm |
|
|
I'm really not an idiot! Mebbe a little "special" at times, but not an idiot.
I've been coding in PHP for a few years now and programming HTML forms even longer, but when I try to run this, it says file not found...and I KNOW it's there!
"revieworder.php" :
Code: |
<?php
if ($total_price==0) {
?>
<H2><I>You Have No Products Selected</I></H2>
<FORM action="/backtoshopindex.php" method="POST">
<INPUT type="submit" name="return" value="Start Selection Again >>>">
</FORM>
<?php
}
?> |
Simply put, this is for my shopping cart, and if a customer doesn't have any items selected, it echos that and gives them a button to return to the "Shop Index" page.
I have something IDENTICLE to this on my "view accounts" page where when they press the "log out" button, it destroys their session and redirects them to my home page.
Here is the "backtoshopindex.php" I'm using:
Code: | <?php
session_id();
session_start();
session_destroy();
header("location:/shopindex.php");
?> |
Now when I press the "Start Selection Again" button, it says 404-page not found! It can't find the "backtoshopindew.php" script to redirect them???? I've tried every path route to the action script to no avail?
Are my eyes just tired or am I having a bug?
Thanks for helping me learn
PWD |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Mon Jan 17, 2005 7:20 am Post subject: |
|
|
I tried both scripts in the same folder which is htdocs and it works , it maybe
possible that your PHP file is really a text file , check to make sure the file
doesn't have a double extension but your script is working fine for me.
Note: Try and provide more details about the situation , where are these
PHP files stored and maybe I will be able to pin point the exact problem. |
|
Back to top |
|
 |
admin Site Admin
Joined: 03 Mar 2002 Posts: 1334
|
Posted: Mon Jan 17, 2005 2:34 pm Post subject: Re: Can't locate "form action"..hmm |
|
|
PWD,
We recommend having a look on your log file to know which URL has generated error 404. This will help you know which is the wrong path. |
|
Back to top |
|
 |
PWD -
Joined: 04 Jan 2005 Posts: 34 Location: trying to conquer these fears I thought were GONE
|
Posted: Tue Jan 18, 2005 1:26 am Post subject: |
|
|
Thanks so much for getting back to me...
To explain a little better...A visitor decides they want to purchase a product from my site. They click the "Shop" tab and it takes them to the "Shop Index" page where they select their items. If there are no items selected and they press "Submit", it echos a custom error message- "No Items Selected" and it gives them a button to return them to the shop index page.
Here is my code for this:
(I am only posting these scripts for reference to resolve this issue)
Code: | <?php
session_id();
header("Content-type: text/html; charset=utf-8");
header("Cache-control: private");
if (!isset($_SESSION['Review'])) {
$_SESSION['Review'] = "Page Hit";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Your Current Order</TITLE>
<LINK href="/css/shell.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="/js/drmc.js">
</script>
</HEAD>
<BODY>
<H1>Ordering Services...</H1>
Step 1: Select Services<br>
<B>STEP 2: REVIEW SELECTIONS</B><br>
Step 3: Checkout
<P></P>
<H1> Your Current Selections</H1>
<?php
$sess=session_id();
$connect = mysql_connect("localhost", "user", "pass") or
die ("Could not connect to Database. Please use the Contact Us link to let us know.");
mysql_select_db ("database");
$query="SELECT * from order where sess='$sess'";
$results=mysql_query($query)
or die ( mysql_error() );
while($row=mysql_fetch_assoc($results)) {
extract($row);
?>
<B>Product Name: </B> <?php echo $prodname; ?> <BR>
<B>Product Number: </B> <?php echo $prodnum; ?> <BR>
<B>Description: </B> <?php echo $proddesc; ?> <BR>
<B>Price: </B> <FONT color="red">$<?php echo $price; ?> </FONT>
<FORM action="orderupdate.php" method="POST">
<INPUT type="hidden" name="sess" value="<?php echo $sess; ?>" >
<INPUT type="hidden" name="prodnum" value="<?php echo $prodnum; ?>" >
<INPUT type="hidden" name="prodname" value="<?php echo $prodname; ?>" >
<INPUT type="hidden" name="proddesc" value="<?php echo $proddesc; ?>" >
<INPUT type="hidden" name="price" value="<?php echo $price; ?>" >
<INPUT type="submit" value="Delete">
</FORM>
<P></P>
<?php
}
$query2 = "SELECT sum(price) FROM order where sess='$sess'";
$res = mysql_query($query2);
$dat = mysql_fetch_row($res);
$total_price = $dat[0];
if ($total_price==0) {
?>
<H2><I>You Have No Products Selected<I></H2>
<FORM action="backtoshopindex.php" method="POST">
<INPUT type="submit" name="return" value="Start Selection Again >>>">
</FORM>
<?php
}
else {
?>
<TABLE border="1" cellpadding="5">
<TR>
<TD><B>TOTAL</B></TD>
<TD><FONT color="red"><B>$<?php echo $total_price; ?></B></FONT></TD>
</TR>
</TABLE>
<FORM action="billinginfo.php" method="POST">
<INPUT type="hidden" name="sess" value="<?php echo $sess; ?>" >
<INPUT type="hidden" name="prodnum" value="<?php echo $prodnum; ?>" >
<INPUT type="hidden" name="prodname" value="<?php echo $prodname; ?>" >
<INPUT type="hidden" name="price" value="<?php echo $price; ?>" >
<P align="center">
<INPUT type="submit" value="Begin Checkout >>>">
</P>
</FORM>
<?php
}
mysql_close();
?>
</BODY>
</HTML> |
Here is the script I use (I'll call it backtoshopindex.php for this forum) to redirect the visitor if they have NO products and they click the "Start Selection Over>>>" button:
Code: | <?php
session_id();
session_start();
session_destroy();
header("location:/shop_index.php");
?> |
Like I said, I use this EXACT thing to redirect a registered user to log out of their account and it works just fine.
trustpunk said:
Quote: | check to make sure the file
doesn't have a double extension |
I checked my file, and it is a PHP file (No double extension...though I've done that a few times in my life)
trustpunk said:
Quote: | Note: Try and provide more details about the situation , where are these
PHP files stored and maybe I will be able to pin point the exact problem. |
Both files are located in the same subfolder of htdocs
admin requested:
Quote: | We recommend having a look on your log file to know which URL has generated error 404. This will help you know which is the wrong path.
|
And here are the details of my log file: (NOTE: I've changed the real file locations with pseudo ones for the sake of security)
Code: | 127.0.0.1 - - [17/Jan/2005:17:55:24 -0600] "GET / HTTP/1.1" 200 5361 "" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
127.0.0.1 - - [17/Jan/2005:17:55:25 -0600] "GET /js/drmc.js HTTP/1.1" 200 376 "http://localhost/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
127.0.0.1 - - [17/Jan/2005:17:55:25 -0600] "GET /css/shell.css HTTP/1.1" 200 2513 "http://localhost/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
127.0.0.1 - - [17/Jan/2005:17:55:25 -0600] "GET /images/pwrabyss.png HTTP/1.1" 200 1170 "http://localhost/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
127.0.0.1 - - [17/Jan/2005:17:55:25 -0600] "GET /images/logo2.gif HTTP/1.1" 200 9061 "http://localhost/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
127.0.0.1 - - [17/Jan/2005:17:55:25 -0600] "GET /images/mysqllogo.png HTTP/1.1" 200 1461 "http://localhost/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
127.0.0.1 - - [17/Jan/2005:17:55:25 -0600] "GET /images/background.gif HTTP/1.1" 200 805 "http://localhost/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
127.0.0.1 - - [17/Jan/2005:17:55:25 -0600] "GET /shop/shopindex.php?PHPSESSID=613a6d769417034bf9b382315a494ddd HTTP/1.1" 200 3585 "http://localhost/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
127.0.0.1 - - [17/Jan/2005:17:55:25 -0600] "POST /shop/add.php HTTP/1.1" 200 1806 "http://localhost/shop/shopindex.php?PHPSESSID=613a6d769417034bf9b382315a494ddd" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
127.0.0.1 - - [17/Jan/2005:17:55:29 -0600] "POST /shop/backtoshopindex.php HTTP/1.1" 302 108 "http://localhost/shop/add.php" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
127.0.0.1 - - [17/Jan/2005:17:55:31 -0600] "GET /shopindex.php HTTP/1.1" 404 223 "http://localhost/shop/add.php" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)" |
Again, I'm just posting this to help resolve this issue...
Thanks again for helping me learn...
(Bows Gracefully)
PWD |
|
Back to top |
|
 |
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Tue Jan 18, 2005 11:50 am Post subject: |
|
|
Might just be me, but in your code you have
Quote: | header("location:/shop_index.php") |
Whilst in the sample log you posted I see
Quote: | 127.0.0.1 - - [17/Jan/2005:17:55:31 -0600] "GET /shopindex.php HTTP/1.1" 404 |
At a guess, you have a missing _ somewhere (in add.php?) unless I've completely misunderstood what filenames you've used... |
|
Back to top |
|
 |
admin Site Admin
Joined: 03 Mar 2002 Posts: 1334
|
Posted: Tue Jan 18, 2005 1:19 pm Post subject: |
|
|
PWD,
So it seems that the problem comes from this redirection and from /shopindex.php . Do you have a shopindex.php file inside the main web site directory (by default htdocs/). Our guess is that you have all the files inside the shop subdirectory so the use of an absolute virtual path here may be the cause of this error.
Try using a relative path only (not prepended by /):
Code: |
header("location: shopindex.php");
|
As Anonymoose said, check also the name of the file: does it have an underscore _ in it or not? |
|
Back to top |
|
 |
PWD -
Joined: 04 Jan 2005 Posts: 34 Location: trying to conquer these fears I thought were GONE
|
Posted: Tue Jan 18, 2005 5:21 pm Post subject: |
|
|
I am humbled. Amazing how it usually comes down to something basic.
The issue all boiled down to the file path in the redirect header("location: shopindex.php").
As Aprelium suggested, I rechecked the file path, removed the "/" and BAM! everything is working fine.
Thanks for all your help and trudging through my code....off to tighten it up!
From now on, I'll be sure to check my basics before posting.
Sincerely,
PWD |
|
Back to top |
|
 |
|