go to personal gallery via di submit go to personal gallery via di submit
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

go to personal gallery via di submit

Started by hyacinth, May 29, 2006, 08:51:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

hyacinth

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???


hyacinth

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.

hyacinth

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>

Joachim Müller

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 toheader('Location: http://localhost/gallery/index.php?cat='.$_POST['id']);Reading the PHP docs is strongly recommended, start with the basics (find out what vars are and how they are used).

hyacinth

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...???

Joachim Müller

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.

hyacinth

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:)

Joachim Müller

That's JavaScript, not Java - to entirely different animals. Your code is far from being standards-compliant. Anyway, marking as solved.