Jump to content

Need help with link.


Lucuis

Recommended Posts

Hi again everyone :)

 

I need some help getting this link to work.  This is line two of my category_list.php file.

<a href="<?php echo $ME?>?mode=add">[+C] Add Category</a>

$ME = $_SERVER['PHP_SELF'];  *Defined globally on my application.php file*

 

What it's supposed to do is go to my category_form.php page so that i can add a category.  However it does nothing, it looks as if the page refreshes.  There is no error, and i do have error reporting on all the way.

 

In fact all the links don't work in category_list.php.  I figure it's all the same problem, i'm hoping if this get's working i can fix the rest.

 

category_list.php  so you all can see it.

<p class=normal>

<a href="<?php echo $ME?>?mode=add">[+C] Add Category</a>

</p>



<table border=1 cellpadding=3>

<tr>

<th>Action</th>

<th>Category</th>

<th>Parent</th>

<th>Description</th>

</tr>



<?php while ($r = db_fetch_object($qid)) { ?>

<tr>

<td class=normal>

	[ <a title="Add a subcategory under <?php pv($r->name) ?>" href="<?php echo $ME?>?mode=add&id=<?php pv($r->id) ?>">+C</a>

	| <a title="Add a product under <?php pv($r->name) ?>" href="products.php?mode=add&category_id=<?php pv($r->id) ?>">+P</a>

	| <a title="Delete <?php pv($r->name) ?>" href="<?php echo $ME?>?mode=del&id=<?php pv($r->id) ?>">X</a>

	]

</td>

<td class=normal><a title="Edit this category" href="<?php echo $ME?>?mode=edit&id=<?php pv($r->id) ?>"><?php pv($r->name) ?></a></td>

<td class=normal><?php pv($r->parent) ?></td>

<td class=normal><?php pv($r->description) ?></td>

</tr>

<?php } ?>



</table>

 

And category_form.php which category_list.php is supposed to link to using some of the links.  The other are supposed to go to category_deleted.php, etc.

<form name="entryform" method="post" action="<?php echo $ME?>">

<input type="hidden" name="mode" value="<?php echo $frm["newmode"]?>">

<input type="hidden" name="id" value="<?php echo pv($id)?>">

<table>

<tr>

<td class=label>Parent:</td>

<td class=normal><?php echo $frm["parent"]?></td>

</tr>

<tr>

<td class=label>Name:</td>

<td><input type="text" name="name" size=25 value="<?php pv($frm["name"]) ?>"></td>

</tr>

<tr valign=top>

<td class=label>Description:</td>

<td><textarea name="description" cols=50 rows=5><?php pv($frm["description"]) ?></textarea></td>

</tr>

<tr>

<td></td>

<td><input type="submit" value="<?php echo $frm["submit_caption"] ?>"></td>

</table>

</form>

 

I have a feeling it's a "logic" error of mine.  Seeing as there's no error given to me.

Link to comment
https://forums.phpfreaks.com/topic/129524-need-help-with-link/
Share on other sites

declare

$ME = $_SERVER['PHP_SELF'];

again at the top of category_list.php

 

and change all

<?php echo $ME?>

to

<?php echo $ME; ?>

 

So far doing that didn't change anything.  Did you mean to change the code in all files, not just category_list.php ?

 

If you looked at your source code, you would realize that:

 

$me = http://www.whatever.com/category_list.php

 

Since $_SERVER['PHP_SELF'] is equal to the current page. So your link will link to whatever page it is placed on.

 

I'm not sure i follow.  How would i get it to do what i need it to?

Link to comment
https://forums.phpfreaks.com/topic/129524-need-help-with-link/#findComment-672425
Share on other sites

You say you want the link to go to category_form.php, but $_SERVER['PHP_SELF'] is equal to whatever page you are looking at. So the link will always be to the page you are looking at, not to any other page.

 

So to get it to do what you want, change your link to this:

<a href="category_form.php?mode=add">[+C] Add Category</a>

Link to comment
https://forums.phpfreaks.com/topic/129524-need-help-with-link/#findComment-672537
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.