order for return link??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
southeastweb
Forum Newbie
Posts: 14
Joined: Sun Mar 21, 2004 3:28 am
Location: Florida

order for return link??

Post by southeastweb »

I have searched far and low, but cannot seem to find a function return href function to create a link back to the order enter page. see the 3rd echo, I just can't figure this out, ive tried more than 20 variations of href and code code formats, thanks in advance for any advice. J :)

//Order error checking
if(totaqty == 0)
{
echo "<font color=red>";
echo "<p><strong>You did not order anything on the previous
echo "<a href=http://localhost, Return</a>";
}
Pozor
Forum Commoner
Posts: 74
Joined: Tue Mar 30, 2004 11:11 pm
Location: Switzerland

Link back

Post by Pozor »

Hello,

You want to go back on the page you was before?

try $_SERVER['REQUEST_URI']; //back reference to the last page

//Order error checking now with minor changes
if(totaqty == 0)
{
echo '<font color=red>';
echo '<p><b>You did not order anything on the previous</b></p>';
echo '>/font>';
//echo '<a href="http://localhost">Return</a>';
echo '<a href="'.$_SERVER['REQUEST_URI'].'">Return</a>';
}

use ' instead of " if you dont use variables within the strings -> its faster

When you want the same effect like the browser support (back button) use javascript.
Usually is this not a good solution -> not well controllable how the browser handle this...


Or try this ->

<?php
// print the hole $_SERVER array -> there you can find useful infos for creating backlinks...

print_r($_SERVER);
?>
greez Pozor
southeastweb
Forum Newbie
Posts: 14
Joined: Sun Mar 21, 2004 3:28 am
Location: Florida

Thanks for the info

Post by southeastweb »

The "return" link was now viewable, and hot, but only returned to the existing page, I viewed and tried several print_r($_SERVER); functions as you mentioned, but all I could acheive was returning to my index page. the page i am returning to is just a single seperate file on my server.

Maybe I am missing something here, and maybe java is the real answer.

It's a bit late here, so my full function is low, thanks for your help and advice, I learned something new! If you have any other suggestions, please let me know.

Thanks! :D
Pozor
Forum Commoner
Posts: 74
Joined: Tue Mar 30, 2004 11:11 pm
Location: Switzerland

Post by Pozor »

Hello,

Page now (who should have a linl back) = PN
that what i suggested before, was a solution to get to the previous page (that page you clicked on a link or on a submit button to get to the PN).

If you call this script by themself the link is a link that points on themself...

Maybe i missed what you wanted?? When yes can you point it out maybee with a link to the site who cause the problem?

greez Pozor

PS: Sorry my english isn't very well i'm still leraning :oops:
southeastweb
Forum Newbie
Posts: 14
Joined: Sun Mar 21, 2004 3:28 am
Location: Florida

I am going to keep hacking at it

Post by southeastweb »

Maybe my question does not make sense?? Sorry for using so much english puctuation.

All I am trying to do is create a link to the previous page.

PageA PageB

I am trying to go back to PageB. PageA is the current page that will display the return link.

I hope this makes sense. What language do you speak? I have a translator that might make it easier to speak, your english seems pretty good to me! Thanks :D
Pozor
Forum Commoner
Posts: 74
Joined: Tue Mar 30, 2004 11:11 pm
Location: Switzerland

Post by Pozor »

Hello,

my mother tongue is swiss german, but i speack german, and english too.
please dont try to translate english in german, this doesn't work well...

I think it is what i posted before...

file1: test_REFEREER.php

Code: Select all

<?php
echo '<a href="test_SERVER_var.php">Link zu file: test_SERVER_var.php</a>';
?>
file2: test_SERVER_var.php

Code: Select all

<?php
echo '<a href="'.$_SERVER['HTTP_REFERER'].'">Back Link</a>';
echo '<br><br>';
echo '<pre>';
print_r($_SERVER);
echo '</pre>';
?>
ok put this files on your local- or normal webserver (must be the same directory!), then start file1 and click on the link...

so i tested it.. it works fine. i think it is that what you wanted or not?

greez Pozor

//Edit sorry made a little mistake in file2 should be HTTP_REFERER instead of REQUEST_URI.... it's not my day, im ill -> got the flu :(
southeastweb
Forum Newbie
Posts: 14
Joined: Sun Mar 21, 2004 3:28 am
Location: Florida

That works

Post by southeastweb »

Well, it worked. Below is my full snipet:

Thanks for your help, I wish I could return a code favor, but I think you know quite a bit more than me. If you don't currently use a PHP editing software I recommend Davor's PHP Editor (other languages too). Here is a link to download it, it's FREE: http://download.com.com/3000-7957-10154 ... ag=lst-0-1

I have been using it, and my files are clean and organized.

//Order error checking
if($totalqty == 0)
{
echo "<font color=red>";
echo "<p><strong>You did not order anything on the previous page</strong></p>";
echo '<a href="bobs_home.php">Go Back</a>';
}
?>
Pozor
Forum Commoner
Posts: 74
Joined: Tue Mar 30, 2004 11:11 pm
Location: Switzerland

Post by Pozor »

Hallo,

i use Source edit, a nice Text, C++, C, PHP and and... editor
with useful function like tab -> 2 spaces (or how many you want)
http://download.com.com/3000-2352-10213 ... ag=lst-0-2

and lately i tried a very useful tool! TortoiseCVS a nice Version management for all kind of skripts and other stuff...


greez Pozor
Post Reply