TinyPortal

Development => Support => Older SMF versions => Topic started by: marzi on November 02, 2007, 10:55:39 PM

Title: Get a php article form to submit back on itself
Post by: marzi on November 02, 2007, 10:55:39 PM
Using SMF 1.1 RC3  and TinyPortal v0.9.6beta

How can I get a php article to submit back on itself to display the return page. I have read through the thread at http://www.tinyportal.net/index.php?topic=19604.0  but it has not helped me.

I start the php article with a ?> and end it with a <?php and put everything else in between so I can use the old fashioned style of php/html coding and mixing.

The article URL is http://www.marscafe.com/index.php?page=60

When the form is submitted, if I code it like this in the html section:
<FORM  METHOD=POST ACTION="http://www.marscafe.com/index.php?page=60">
only the forum board index is displayed, not the page itself.


If you test the form now it is currently set up to display the submitted results outside of Tiny Portal but I would like to keep the user totally inside Tiny Portal. The submit code is
<FORM  METHOD=POST ACTION="http://www.marscafe.com/php/menueng/menueng.php"  NAME="action" onSubmit="return Validator(this);">
<input type="hidden" name="action" value="true">


and it takes you to http://www.marscafe.com/php/menueng/menueng.php


Is it possible considering the way I have modified the use of php in the article from the way you all do it? Hope I have been clear.
Title: Re: Get a php article form to submit back on itself
Post by: IchBin on November 03, 2007, 12:07:02 AM
try this as the action for the form.
action="', $_SERVER['QUERY_STRING'],'"
Title: Re: Get a php article form to submit back on itself
Post by: marzi on November 03, 2007, 12:45:05 PM
Thanks for the help.
I was not able to get any success. I tried a few different permutations. When I used http://www.marscafe.com/index.php?page=60 for the string I got
The requested URL /',%20$_SERVER%5B'http://www.marscafe.com/index.php?page=60'], does not exist.

and when I used
<FORM  METHOD=POST action="', $_SERVER['PHP_SELF'],"  NAME="action" onSubmit="return Validator(this);">
I got
404 Not Found
The requested URL /',%20$_SERVER%5B'PHP_SELF'%5D, does not exist.

Perhaps I am not using the code correctly and probably did something wrong. The action code is in the html section of the page and most likely needs to be moved into the php section to make use of the php global $_SERVER. I guess I am lost on this one.
Title: Re: Get a php article form to submit back on itself
Post by: JPDeni on November 03, 2007, 03:51:46 PM
I think it might be better if you just used php in the article and used echo statements to output the html, rather than

Quote
I start the php article with a

?>

and end it with a

<?php

and put everything else in between so I can use the old fashioned style of php/html coding and mixing.

It may work the way you're doing it, but it's not the way most of the rest of us doi things, and it's hard to adjust our code to fit yours.
Title: Re: Get a php article form to submit back on itself
Post by: IchBin on November 03, 2007, 05:35:19 PM
I fixed an apostrophe missing in my post above. Try it again and also listen to Deni. :)
Title: Re: Get a php article form to submit back on itself
Post by: marzi on November 04, 2007, 01:48:42 PM
IchBin,
Still no success but I believe I will be able to "ride this horse".

Thanks for the help and advice. I will take JPDeni's advice, my experience with it has been 100% satisfactory. For a historical note, the php code I am using is something I wrote a while ago and thought it would be great to have it inside of TP instead of just linking out of TP to it. Next time it will be coded to TP standards.

Title: Re: Get a php article form to submit back on itself
Post by: Ianedres on November 05, 2007, 04:34:13 AM
If I understand your request correctly, could you use the php article to refer back to itself, parsing the POST data once it is submitted (using a hidden value) as "menueng.php" would?
Title: Re: Get a php article form to submit back on itself
Post by: marzi on November 05, 2007, 09:36:28 AM
Yes.
Title: Re: Get a php article form to submit back on itself
Post by: JPDeni on November 05, 2007, 02:18:27 PM
I have a number of php articles which have forms which submit back to the same page. I use


echo '<form  action="index.php?page=',$page,'" method="post">';


where the $page variable is defined as the page number. There's never been a problem, so I don't understand what is going on with your article. The same thing with blocks.

I understand that the structure is different than you use, but I've never used your structure and I find it difficult to wrap my brain around it to be able to translate what I do to your format.
Title: Re: Get a php article form to submit back on itself
Post by: marzi on November 07, 2007, 07:18:32 PM
JP,
Would you be willing to share the code of one of the "php articles which have forms which submit back to the same page"?
Title: Re: Get a php article form to submit back on itself
Post by: JPDeni on November 07, 2007, 08:21:21 PM
They're pretty complicated. :-)

I guess the simplest one is my own image gallery. Here's the whole thing:


global  $scripturl, $cat_name, $cat_parent, $child_cats, $cat_order, $nbsp;


$category_list = '';

$number_of_cols = 4;
$number_of_rows = 4;

$max_on_page = $number_of_cols * $number_of_rows;

$directory = '/home/.salinger/morethan/morethanspike.com/album';
$nbsp = '&nb' . 'sp;' . '&nb' . 'sp;';

$perm= $GLOBALS['user_info']['groups'][0];
if ($perm == 1 || $perm ==2)
  $can_edit=1;
else
  $can_edit = 0;
isset($_GET['cat']) ? $cat = $_GET['cat'] : $cat=0;
isset($_GET['p']) ? $p = $_GET['p'] : $p=1;
isset($_GET['pic']) ? $pic = $_GET['pic'] : $pic=0;


if (isset($_POST['op']))
  $operation = $_POST['op'];
elseif (isset($_GET['op']))
  $operation = $_GET['op'];
else
  $operation = '';
  $query = db_query(
    "SELECT *
     FROM gallery_cats
     ORDER BY sort_order", __FILE__, __LINE__);
  while ($row = mysql_fetch_assoc($query))
  {
    $id = $row['gallery_cat_id'];
    $cat_name[$id] = $row['gallery_cat'];
    $cat_parent[$id] = $row['father'];
    $cat_order[$id] = $row['sort_order'];
  }

if ($can_edit==1)
{
  if ($operation=='Upload file')
  {
    $file =  $_FILES['FILE_UPLOAD']['tmp_name'];
    $file_name =  $_FILES['FILE_UPLOAD']['name'];

    $gallery_cat_id = $_POST['gallery_cat_id'];
    $title = $_POST['title'];
    $description = $_POST['description'];

    $file_ext = 'jpg';
    $ext = strtolower($file_ext);
    $query = db_query(
      "SELECT gallery_id
       FROM gallery
       ORDER BY gallery_id DESC LIMIT 1", __FILE__, __LINE__);
    $row = mysql_fetch_assoc($query);
    $totr = $row['gallery_id'];
    ++$totr;
    $image = "a_"."$totr".".$ext";
    move_uploaded_file("$file", "$directory" . '/' . "$image");

    $cdata = time();

    $thumb = "t_$image";
    $source = "$directory" . '/' . "$image";
    $dest = "$directory" . '/' . "$thumb";
    CreateImage(120,$source,$dest);

    db_query(
          "INSERT INTO gallery(gallery_cat_id, title, description, file, date)
           VALUES('$gallery_cat_id', '$title', '$description', '$image', '$cdata')", __FILE__, __LINE__);

    echo 'file uploaded';
  }

  elseif ($operation=='Add Category')
  {
    $gallery_cat = $_POST['gallery_cat'];
    $father = $_POST['father'];
    db_query(
          "INSERT INTO gallery_cats(gallery_cat_id, gallery_cat, sort_order, father)
           VALUES('', '$gallery_cat', '0', '$father')", __FILE__, __LINE__);    
    echo 'category added';
  }

  elseif ($operation=='Change Category Name')
  {
    $gallery_cat = $_POST['gallery_cat'];
    $gallery_cat_id = $_POST['gallery_cat_id'];
    db_query("UPDATE gallery_cats
            SET gallery_cat='$gallery_cat'
            WHERE gallery_cat_id='$gallery_cat_id' LIMIT 1", __FILE__, __LINE__);
    echo 'category name changed';
  }

  elseif ($operation=='Delete Category')
  {
    $gallery_cat_id = $_POST['gallery_cat_id'];
    $error = '';
    $query = db_query(
          "SELECT gallery_id
           FROM gallery
           WHERE  gallery_cat_id = $gallery_cat_id", __FILE__, __LINE__);
    if (mysql_num_rows($query))
      $error = 'You must first move all of the images from the category.<br />';
    $query = db_query(
          "SELECT gallery_cat_id
           FROM gallery_cats
           WHERE  father = $gallery_cat_id", __FILE__, __LINE__);
    if (mysql_num_rows($query))
      $error = 'You must first delete any child categories of this category.<br />';
    if ($error > '')
      echo $error . 'Category not deleted';
    else {
        db_query("DELETE FROM gallery_cats
            WHERE gallery_cat_id='$gallery_cat_id' LIMIT 1", __FILE__, __LINE__);
      echo 'category deleted';
    }
  }
  elseif ($operation=='Re-order Categories')
  {
    $query2 = db_query("
      SELECT gallery_cat_id
      FROM gallery_cats", __FILE__, __LINE__);
   $row2 = '';
    while ( $row2 = mysql_fetch_assoc($query2))
    {
    $test = 'sort_order_cat' . $row2['gallery_cat_id'];
    $sort_order=$_POST[$test];
    $gallery_cat_id = $row2['gallery_cat_id'];
     db_query("UPDATE gallery_cats
            SET sort_order='$sort_order'
            WHERE gallery_cat_id='$gallery_cat_id' LIMIT 1", __FILE__, __LINE__);
    }
    echo 'categories re-ordered';
  }
}

if ($can_edit==1 && $operation=='admin')
{
  $ta_end = '<' . '/textarea' . '>';

  echo '<table border="1"><tr valign="top">';

// Upload file form
  echo '<td><form action="index.php?page=7" name="UPLOAD" method="post" enctype="multipart/form-data">
    <table border="0">
    <tr><td colspan=2> <p style="text-align:center"> Upload a new file.</p>Please be sure to fill out all of the fields and only upload .jpg files.</td></tr>';

  echo '<tr><td>Category:</td><td><select name="gallery_cat_id">';

  display_child_cats('0', '0', 'select', '0');

  echo '
    </select></td></tr>

   <td width="10%">Title</td>
   <td width="90%"><textarea cols="50" rows="10" name="title" />' . $ta_end . '</td>
   </tr>
   <tr>
   <td width="10%" valign="top">Description</td>
   <td width="90%"><textarea cols="50" rows="10" name="description" />' . $ta_end . '</td>
   </tr>
   <tr>
   <td width="10%">File</td>
   <td width="90%"><input type="file" name="FILE_UPLOAD" size="50" /></td>
   </tr>
   <tr>
   <td colspan="2" style="text-align:center"> <input type="submit" name="op" value="Upload file" /></td>
   </tr>
   </table>
   </form></td></tr>';

// Add category
  echo '<tr><td>
    <table border="0">
    <tr><td> <form action="index.php?page=7" method="post">';
    echo '<tr><td align="right">Parent category:</td><td><select name="father">';
    echo '<option value="0">Main category -- no parent</option>';
  display_child_cats('0', '0', 'select', '0');
  echo '
    </select></td></tr>';
  echo '
   <tr><td align="right">Category name:</td>
   <td><input type="text" name="gallery_cat" size="52" /></td></tr>';

  echo '<tr><td colspan="2" style="text-align:center"><input type="submit" name="op" value="Add Category" /></form>';
  echo '</td></tr><hr />';

// Change category name
  echo '<form action="index.php?page=7" method="post">';
    echo '<tr><td align="right">Change this category:</td><td><select name="gallery_cat_id">';
  display_child_cats('0', '0', 'select', '0');
  echo '
    </select></td></tr>';
  echo '
   <tr><td align="right">To this:</td>
   <td><input type="text" name="gallery_cat" size="52" /></td></tr>';

  echo '<tr> <td colspan="2" style="text-align:center"> <input type="submit" name="op" value="Change Category Name" /></form>';
  echo '</td></tr><hr />';

// Delete category

  echo '<tr><td colspan=2>Note that you can only delete a category if there are no images in that category and if the category has no child categories.</td></tr>';
  echo '<form action="index.php?page=7" method="post">';

    echo '<tr><td align="right">Delete this category:</td><td><select name="gallery_cat_id">';
  display_child_cats('0', '0', 'select', '0');
  echo '
    </select></td></tr>';

  echo '<tr><td colspan="2" style="text-align:center"><input type="submit" name="op" value="Delete Category" /></form>';


  echo '</td></tr>';
  echo '</table>';
  echo '</td></tr>';

// Order categories

  echo '<tr><td>Order categories<br />';


  echo '<form action="index.php?page=7" method="post">';

      display_child_cats('0', '0', 'form', '0');

  echo '<p style="text-align:center"><input type="submit" name="op" value="Re-order Categories" /></p></form>';
 
  echo '</td></tr>';
  echo '</table>';
}
else
{


if (isset($_POST['edit_pic']) && $can_edit )
{
  $cat = $_POST['oldcat'];
  $gallery_id = $_POST['gallery_id'];
  $gallery_cat_id = $_POST['gallery_cat_id'];
  $description = $_POST['description'];
  $title = $_POST['title'];
  if ($cat == $gallery_cat_id)
    $pic = $_POST['gallery_id'];
  else
    $pic = 0;

  db_query("UPDATE gallery
            SET gallery_cat_id='$gallery_cat_id', title='$title', description='$description'
            WHERE gallery_id='$gallery_id' LIMIT 1", __FILE__, __LINE__);
  echo 'edited';
}

if (isset($_POST['del_pic']) && $can_edit)
{
  $gallery_id = $_POST['gallery_id'];
  $file = $_POST['file'];
  $thumb = "t_$file";
  db_query("DELETE FROM gallery
            WHERE gallery_id='$gallery_id' LIMIT 1", __FILE__, __LINE__);
  unlink($directory . '/' . $file);
  unlink($directory . '/' . $thumb);
  echo 'deleted';
}

// One picture
if ($pic > 0) {
  $query = db_query(
   "SELECT *
    FROM gallery
    WHERE  gallery_id = $pic
    LIMIT 1", __FILE__, __LINE__);
    $row = mysql_fetch_assoc($query);
  $gallery_cat_id = $row['gallery_cat_id'];
  $query2 = db_query(
   "SELECT gallery_id, file
    FROM gallery
    WHERE gallery_cat_id = $gallery_cat_id
    ORDER BY gallery_id DESC", __FILE__, __LINE__);
  while ($row2 = mysql_fetch_assoc($query2))
  {
    $pics_in_cat[] = $row2['gallery_id'];
    $pic_file[] = $row2['file'];
  }
  $current = array_search($row['gallery_id'],$pics_in_cat);
  $numpix = mysql_num_rows($query2) - 1;
  if ($current > 0)
  {
    $prev = $pics_in_cat[$current-1];
    $prevthumb = 't_' . $pic_file[$current-1];
  }
  else
    $prev = -1;
  if ($current < $numpix)
  {
    $next = $pics_in_cat[$current+1];
    $nextthumb = 't_' . $pic_file[$current+1];
  }
  else
    $next = -1;
  $cat= $row['gallery_cat_id'];

  echo '<center><table>';
  echo '<tr valign=top><td width="120" align="right">';
  if ($prev >-1)
    echo '<a href="' . $scripturl . '?page=7&pic=' . $prev . '"> <img src="/album/' . $prevthumb . '" border="0" alt="Previous" /> </a><br /> Previous image<br /><hr />';
  if ($next > -1)
    echo '<a href="' . $scripturl . '?page=7&pic=' . $next . '"><img src="/album/' . $nextthumb . '" border="0" alt="Next" /></a><br /> Next image<br /><hr /><br />';
  echo '<table><tr><td>' . breadcrumbs($gallery_cat_id,$pic) . '<br /><br /></td>';
  echo '</tr></table>';
  echo '</td><td width="15"> </td>';
  echo '<td><center><table border="3"><tr><td>';
  $picture = '/album/' . $row['file'];
  $picturedir = $directory . '/' . $row['file'];
  list($width, $height, $type, $attr) = getimagesize($picturedir);
  if ($width > 500) {
    $small_width = 500;
    $small_height = ceil(500 * $height / $width);
    $smattr = 'width=' . $small_width . ' height=' . $small_height;
    $windowattr = 'width=' . $width . ',height=' . $height;
    echo '<a href="' . $picture. '" onclick="window.open(' . "'" . $picture . "','popup','" . $windowattr . ',scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0' . "'" . '); return false"><img src="' . $picture . '" ' . $smattr . ' border="0" alt="Click for bigger picture" /></a>';
  }
  else
    echo ' <img src="' . $picture . '" ' . $attr . ' border="0" alt="" /> '; 
  echo '</td></tr></table></center></td>';
  echo '</tr>';
  $text = str_replace("\\n","<br />",$row['title']);

  echo '<tr><td colspan="3"><center>' . $text . '</center></td></tr>';
  $text = str_replace("\\n","<br />",$row['description']);
  echo '<tr><td colspan="3"><center>' . $text . '</center></td></tr>';
  echo '</table>';




  if ($can_edit)
  {
    echo '<hr /><table><tr valign=top><td width="50%">';
    echo '<form action="index.php?page=7" method=post><table>';
    echo '<input type="hidden" name="oldcat" value="' . $cat . '">';
    echo '<input type="hidden" name="gallery_id" value="' . $row['gallery_id'] . '">';
    echo '<tr><td>Category:</td><td><select name="gallery_cat_id">';
    display_child_cats('0', '0', 'select', $cat);
    echo '</select></td></tr>';
    echo '<tr><td>Title:</td><td><textarea cols="50" rows="10" name="title" />' . $row['title'] .  '</' . 'textarea' . '/></td></tr>';
    echo '<tr><td>Description:</td><td><textarea name="description" rows=10 cols=30>';
    echo $row['description'] . '</' . 'textarea' . '/></td></tr>';
    echo '<tr><td colspan=2><input type="submit" name=edit_pic value="Edit this picture"></td></tr>';
    echo '</table></form></td>';

    echo '<form action="index.php?page=7" method=post>';
    echo '<input type="hidden" name="gallery_id" value="' . $row['gallery_id'] . '">';
    echo '<input type="hidden" name="file" value="' . $row['file'] . '">';
    echo '<td>This will delete the main picture, the thumbnail and the record from the database.
              There will be no "Are you sure?" button.
              You might want to save the main file to your hard drive in case you change your mind and want to add it back again.';
    echo '<p style="text-align:center"><input type="submit" name=del_pic value="Delete this picture"></p></td>';
    echo '</tr></table>';
  }
  echo page_numbers($cat,$max_on_page,$p,$pic);
  if ($can_edit)
    echo '<br /><a href="' . $scripturl . '?page=7&op=admin">Image Admin</a>';
}

// Category index page
elseif ($cat > 0) {

  $start = ($p-1) * $max_on_page;

  $query = db_query(
    "SELECT gallery_id, file
     FROM gallery
     WHERE  gallery_cat_id = $cat
     ORDER BY gallery_id DESC
     LIMIT $start, $max_on_page", __FILE__, __LINE__);

  echo '<table width=100%><tr>';
  $k=0;
  while ($row = mysql_fetch_assoc($query))
  {
    $file = $row['file'];
    $thumb = "t_$file";
    $pic_number = $row['gallery_id'];
    echo  '<td height="180"><center> <a href="' . $scripturl . '?page=7&pic=' . $pic_number . '">
           <img src="/album/' . $thumb . '" border="0" alt="" /></a> </center></td>';
    if (($k%$number_of_cols == ($number_of_cols-1)) && ($k < $max_on_page))
      echo '</tr><tr>';
    ++$k;
  } 
  echo '</tr></table>';
  echo '<table><tr><td>' . breadcrumbs($cat,$pic) . '</td></tr></table>';


  echo page_numbers($cat,$max_on_page,$p,$pic);
  if ($can_edit)
    echo '<br /> <a href="' . $scripturl . '?page=7&op=admin">Image Admin</a>';

}

else {

// Image index page
  $category = array();
  echo '<table width="100%"><tr>';

  $query = db_query(
    "SELECT gallery_cat_id, gallery_cat
     FROM gallery_cats
     WHERE  father = 0
     ORDER BY sort_order", __FILE__, __LINE__);
 
  while ($row = mysql_fetch_assoc($query))
  {
    $child_cats = array();
    $category[] = '<a href="' . $scripturl . '?page=7&cat=' . $row['gallery_cat_id'] . '">' . $row['gallery_cat'] . '</a>';
    $child_cats = display_child_cats($row['gallery_cat_id'], '0', 'random','0');
    $child_cats[] = $row['gallery_cat_id'];
    $randomimagequery = "SELECT file, gallery_id FROM gallery WHERE gallery_cat_id=";
    $randomimagequery .= implode(" || gallery_cat_id=",$child_cats);
    $randomimagequery .= " ORDER BY rand() LIMIT 1";
    $randomrecord = mysql_fetch_row(mysql_query($randomimagequery));
    $rfile = $randomrecord[0];
    $pic = $randomrecord[1];
    $thumb = "t_$rfile";
    $rand_image_thumb[] = '<a href="' . $scripturl . '?page=7&pic=' . $pic . '">
           <img src="/album/' . $thumb . '" border="0" alt="" /></a>';
  }
  $last_cat =  count($category);
  $k = 0;
  while ($k < count($category))
  {
    echo '<td width=25% align=center height="180">' . $rand_image_thumb[$k] . '</td>';
    echo '<td width=25%>' . $category[$k] . '</td>';
    if ($k%2)
      echo '</tr><tr>';
    ++$k;
  }
  if ($k%2)
    echo '<td>' . $nbsp . '</td><td> </td>';
  echo '</tr></table>';
  if ($can_edit)
    echo '<br /><a href="' . $scripturl . '?page=7&op=admin">Image Admin</a>';
}

}


//****************
// FUNCTIONS
//****************

function breadcrumbs($cat,$pic)
{
  global  $scripturl, $nbsp,$cat_name;
  echo '<a href="' . $scripturl . '?page=7">Image index</a><br />';
  $level = 1;
  $path = parents_path($cat);
  foreach ($path as $value)
  {
    echo str_repeat($nbsp,$level) . '<a href="' . $scripturl . '?page=7&cat=' . $value . '">' . $cat_name[$value]. '</a><br />'; 
    ++$level;
  }
  if ($pic > 0)
    echo str_repeat($nbsp,$level) . '<a href="' . $scripturl . '?page=7&cat=' . $cat . '">' . $cat_name[$cat]. '</a><br />'; 
  else
    echo str_repeat($nbsp,$level) . $cat_name[$cat]. '<br />';     
  ++$level;
  display_child_cats($cat, $level, 'echo','0');
}

function CreateImage($size,$source,$dest,$border=0) {

  $imgsize = GetImageSize($source);
  $width = $imgsize[0];
  $height = $imgsize[1];
  $new_width = $size;
  $new_height = ceil($size * $height / $width);
  $im = @ImageCreateFromJPEG($source);

  $new_im=@ImageCreateTrueColor($new_width,$new_height);
   if ($new_im) {
    ImageCopyResized($new_im,$im,0,0,0,0,$new_width,$new_height,ImageSX($im),ImageSY($im));
    ImageJPEG($new_im,$dest,90);
    ImageDestroy($new_im);
  }
}

function display_child_cats($parent, $level, $output, $cat) {
  global $cat_name, $cat_parent, $scripturl, $child_cats, $cat_order ;
  $nbsp = '&nb' . 'sp;' . '&nb' . 'sp;';
  // retrieve all children of $parent
  $children = array_keys($cat_parent,$parent);
  // display each child
  foreach ($children as $value)
  {
    // indent and display the title of this child
    if ($output == 'form')
      echo str_repeat($nbsp,$level+1) . '<input type="text" name="sort_order_cat' . $value . '" value="' . $cat_order[$value] . '" size="3" /> ' . $cat_name[$value] . '<br />';
    elseif ($output == 'echo')
      echo str_repeat($nbsp,$level+1) . '<a href="' . $scripturl . '?page=7&cat=' . $value . '">' . $cat_name[$value]. '</a><br />'; 
    elseif ($output == 'select')
     {
      echo '<option value="' . $value . '"';
      if ($value == $cat) { echo ' SELECTED '; }
      echo '>' . str_repeat('--',$level+1). $cat_name[$value] . '</option>';
     }
     $child_cats[] = $value;
    // call this function again to display this child's children
    display_child_cats($value, $level+1, $output, $cat);
  }
  if ($output == 'random')
    return $child_cats;

}

function parents_path($cat)
{
  global $cat_name, $cat_parent, $scripturl;
  $path = array();
  if ($cat_parent[$cat] > 0)
  {
    $path[] = $cat_parent[$cat];
    $path = array_merge(parents_path($cat_parent[$cat]), $path);
  }
  return $path;
}

function page_numbers($cat,$max_on_page,$p)
{

global  $scripturl;
// Print out page numbers
  $pix_in_cat_query = db_query(
    "SELECT *
     FROM gallery
     WHERE  gallery_cat_id = $cat", __FILE__, __LINE__);

  $pix_in_cat = mysql_num_rows($pix_in_cat_query);
  $number_of_pages = intval($pix_in_cat/$max_on_page) + ($pix_in_cat%$max_on_page > 1);
  $return = '<div align=center>';
 
  for ($i=1; $i<=$number_of_pages;++$i)
  {
    if ($i == $p)
      $return .= '- ' . $i . ' -';
    else
     $return .= '- <a href="' . $scripturl . '?page=7&cat=' . $cat . '&p=' . $i . '">' . $i. '</a> -';
  }
  $return .= '</div>';

  return $return;
}


I hope you can find it helpful.
Title: Re: Get a php article form to submit back on itself
Post by: IchBin on November 07, 2007, 08:24:52 PM
try $_SERVER['REQUEST_URI'] for the action instead.
Title: Re: Get a php article form to submit back on itself
Post by: marzi on November 09, 2007, 02:01:09 PM
JP,
Many thanks for your generosity and willingness to help others.

Ichbin,
I will let you know the results and my thanks to you also for your patient outreach.