I'm working with a function. When we type an id in a textfield and press submit, we can go to the gallery with that id.
I lack PHP knowledge please help me. Here is mine code:
<?php
if(isset($_POST[Submit])){
header('Location: http://localhost/gallery/index.php?cat=[b]id[/b]');
exit;
}
?>
<form name="form1" method="post" action="">
<table width="600" border="1" align="center" cellpadding="5" cellspacing="0"
bordercolor="#9999FF">
<tr>
<td width="23%"><div align="right">ID</div></td>
<td width="77%"><input name="[b]id[/b]" type="text" id="[b]id[/b]"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="submit">
</div></td>
</tr>
</table>
</form>
------------------------
how to make it works?
or Should I totally change this code" header('Location: http://localhost/gallery/index.php?cat=id'); " to other?
or are there any other methods???
QuoteGauGau
Administrator
Coppermine wizard
Karma: 55
Gender:
Posts: 24052
Re: show the link
« Reply #17 on: Today at 09:41:21 PM »
--------------------------------------------------------------------------------
The most useless mod I've ever seen - I've never met an end user who would find it usefull to see a URL printed on the screen next to a link that can be clicked on and does the same.
This is why I want to show the ID. I want users to remember their ID and when they logoff, they don't need to login and click on" MY GALLERY". They are conveniently to type their ID and go to their gallery.
anyway, how to make it works?????
<?php
if(isset($_POST[Submit])){
header('Location: http://localhost/gallery/index.php?cat=id');
exit;
}
?>
<form name="form1" method="post" action="">
<table width="600" border="1" align="center" cellpadding="5" cellspacing="0"
bordercolor="#9999FF">
<tr>
<td width="23%"><div align="right">ID</div></td>
<td width="77%"><input name="id" type="text" id="id"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="submit">
</div></td>
</tr>
</table>
</form>
Quote from: hyacinth on May 29, 2006, 09:53:50 PM
They are conveniently to type their ID and go to their gallery.
Convenience would mean to me that a dynamic link to "my gallery" shows on the other page, not that users have to memorize their id and type it in. Only make your users type in stuff the server can not know. The ID is geek data to the users, not something that comes naturally.
However,
header('Location: http://localhost/gallery/index.php?cat=id');can't work, as the ID is just text in this case. Change it to
header('Location: http://localhost/gallery/index.php?cat='.$_POST['id']);
Reading the PHP docs (http://www.php.net/manual/en/index.php) is strongly recommended, start with the basics (find out what vars (http://www.php.net/manual/en/language.variables.php) are and how they are used).
it doesn't work....
when I type e.g. 10002 and press enter, I doesn't work. However, when I type 10002 and click submit using my mouse, it works...???
Make sure to sanitize the posted data by performing a trim and maybe a typecast. Your html markup isn't valid either, the input field doesn't have the required attributes. I'm not going to look into this deeper, as this is not a coppermine issue, but an issue with your custom code, so it doesn't belong here on this support board anyway.
Why do you insist on using this method? As suggested, it's silly to do what you're up to in the first place.
Ok,
this time I use java:
<HTML>
<HEAD>
<Script>
function transfer()
{window.location.href="<?php echo "http://localhost/gallery/index.php?cat=$_POST[ID]"
?>"}
</Script>
</HEAD>
<BODY onLoad="setTimeout('transfer()',1)">
</HTML>
works perfectly:)
That's JavaScript, not Java - to entirely different animals. Your code is far from being standards-compliant. Anyway, marking as solved.