?
Solved

Forwarding a link...

Posted on 2003-03-20
7
Medium Priority
?
195 Views
Last Modified: 2006-11-17
Hi,

I'm writing a page in PHP that does a search in a DB and displays 10 results by page.

I'm using the POST method to pass through the URL the number of the page to display.

My only problem is that I want to have access to the number of page in the URL, so I create a page
that takes the number of page and forwards to the results.

To forward the page, I'm using a basic Javascript like this one :

?>
<script language="JavaScript"><!--
setTimeout("top.location.href = 'Result.php'",2000);
//--></script>
<?php

The thing is that I'd like to pass parameters to the page that is forwarding.

?>
<script language="JavaScript"><!--
setTimeout("top.location.href = 'Result.php?sql=$SQL'",2000);
//--></script>
<?php

This syntax isn't working only because it Javascript.

Anyone knows how it could be done ??

Thanks

JohnnyQ

(BTW, sorry for my bad english !! :D)
0
Comment
Question by:JohnnyQ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 15

Expert Comment

by:VGR
ID: 8175234
say it again JohnnyB (good?) :D

didn't understand anything.

first of all it's GET method that puts anything in the URL

then I also have a lot of FORMs searching a DB and displaying N results/page, and I don't catch your problem 8-)
0
 

Accepted Solution

by:
tirdun earned 40 total points
ID: 8175723
I ... think I'm getting this. You want to include a PHP variable in a bit of Javascript (?)

If so, you need to have the php code WRITE the javascript code instead of passing it directly:

so:
?>
<script language="JavaScript"><!--
setTimeout("top.location.href = 'Result.php?sql=$SQL'",2000);
//--></script>
<?php

becomes:

<?
print "<script language=\"JavaScript\"><!--\n';
print "setTimeout(\"top.location.href = 'Result.php?sql=$SQL'\",2000);\n";
print "//--></script>";



0
 
LVL 15

Expert Comment

by:VGR
ID: 8175778
yes
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:kimcheng
ID: 8182574
you could just use

<script language="JavaScript"><!--
setTimeout("top.location.href = 'Result.php?sql=<?=$SQL;?>'",2000);
//--></script>

so php will print the value of $SQL instead of the letter.
0
 
LVL 5

Expert Comment

by:cirtap
ID: 8192808
Hi JohnnyQ,

kim's example may already do it, but just in case:
don't get confused with POST and GET commands.
As VGR wrote: it's GET method that puts anything in the URL

You may certainly *POST* a <FORM> but you'll always *GET* a page when using "location.href", so the forwarding-thing you talk about will have your SQL variable in the $_GET array.

CirTap
0
 
LVL 15

Expert Comment

by:VGR
ID: 8194623
listening... how far building the script have you, JohnnyQ...
0
 

Author Comment

by:JohnnyQ
ID: 8197755
Thanks for all your answers !!!

It help me very much !!

Thanks again !!

JohnnyQ
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question