Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse parameters invisible or add to session whilst clicking on link 1

Status
Not open for further replies.

JRBeltman

IS-IT--Management
Joined
Feb 5, 2004
Messages
290
Location
NL
Hi,
on my little site: I am trying to suppress or find a way of not showing parameters I pass on ie:

is something I rather see as
or even
How can I still pass this parameter to the index.php page?
Or how can I add the parameter to a session var when clicking on a link? This latter option would be preferred to keep information as well protected as possible.

Many thanks
JR
 
It depends on how your page works, if it's coded as a form change the method to post, and change your .php to use $_POST[]. Using post sends the varialbes as part ofthe page request rahter than as a querystring
Post some code so we can see what you doing

regards
 
well you wont be happy with my coding for it is bloody much :) so an example (and I am not working with a form, you are correct, that would have been very nice).
Anyway some example code and possible outcomes below that:

<?
$conn = db_connect();

// Get some details
$query = "select * from $object order by rowposition desc, posted desc limit 5";
$result = mysql_query($query);

for($count=0; $row = mysql_fetch_array($result); $count++)
{
?>
<tr>
<td class='menuitem'></td>
<td class='menuitem'><a href='index.php?object= <?=$row[$object.'id']?>'><br><?=$row['title']?></a>
</td>
</tr>
<?
}
?>

=============
Outcome:

About us (hyperlink to index.php?object=1)
contact (hyperlink to index.php?object=2)
news (hyperlink to index.php?object=3)

etc

Hope this helps!
Thanks for replying!
 
Just as an add-on to my own reply:
we have either FORMs, but I do not know if you can have a normal looking hyperlink or that you will always have a submit button.

Maybe it is possible to call a function when clicking a hyperlink and storing the variable in a session? (PhP or JAVA to call the function)?

Cheers
JR
 
If you are supplying parameters on a link you will always see them. What you could do is try one of the following:
Have a frameset, you will only see the original request, all the url passing should occir invisibly (I havn't tried this )
or
Code everything as a form, and this will answer your next point, because you can simulate the submit button with the Javascript submit method. In your case you might have a button respond to a click event, put the data you need into a hidden field in the form (again using JavaScript) and then call the submit method.
Hope this helps !!
 
Ingresman,
many thanks.

Could you show me the javascript? (I am not a Java programmer). And would it be possible to replace the standard submit button with one that looks like a normal hyperlink, say white background and blue underlined writing?

Many thanks
JR
 
I'll put something together for you
 
Ok,

I've had a play and I couldn't get the onclick event of an href to honour a submit() method.
I've have got this to work though:
<html>
<head><title>How to simulate a form</title>
<script>
function sendit(which) {
document.forms.secret.theparameter.value = which;
}
</script>
</head>
<body>
<form name="secret" method="post" action = "index.php">
<input type=hidden name=theparameter>
</form>
<a href="javascript:sendit(1);document.secret.submit()">About Us</a>
<br>
<a href="javascript:sendit(2);document.secret.submit()">Contact</a>
<br>
<a href="javascript:sendit(3);document.secret.submit()">News</a>
</body>
</html>

The php to check it is:

<?php
echo "it is " . $_POST["theparameter"];
?>

You will generate using your original php the html and javascript above, note the parameter value is given to the sendit function. The sendit function alters the hidden field "theparameter" in the form.
The whole thing gets invoked by clicking the standard <A> tag which has some javascript as the target, it calls sendit and then submits for form.
Hope this all makes sence and works for you !

 
Hi ingresman,
that looks like exactly it!!!
Many thanks for this fantastic solution, I will try it out once I get back home!

Cheers!
JR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top