Making all actions work with in one index.php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Lucnet
Forum Commoner
Posts: 61
Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:

Making all actions work with in one index.php

Post by Lucnet »

I am very new at php and I am developing a testimonials page. I am tring to get the admin site to work with just one show.php. As of now I have been able to get a three funtions to work with in the show.php. With the help of this forum. The final two actions are totally different in the way they will be called.

Here is the code, I have mark where my menu starts:

Code: Select all

<?
$status = (!empty($_GET['status']) ? $_GET['status'] : '%');
include "../inc/config.php";
switch($action) {
	case "approve":
		db();
		mysql_query("UPDATE ls_testimonials SET approved='y' WHERE id=$id");
		$pagecontent.="Item {$id} Approved<br><br>";
		db_close();
	break;
	case "hold":
		db();
		mysql_query("UPDATE ls_testimonials SET approved='h' WHERE id=$id");
		$pagecontent.="Item {$id} On Hold<br><br>";
		db_close();
	break;
	case "delete":
		db();
		mysql_query("DELETE FROM ls_testimonials WHERE id=$id");
		$pagecontent.="Item {$id} Deleted<br><br>";
		db_close();
	break;
	default:
	break;
}
db();
$query = "SELECT * FROM ls_testimonials WHERE approved LIKE '$status'"; 
$formdata_res=mysql_query($query) or die("query failed: " . mysql_error()); 
$pagecontent.="<table width=760 border=0 cellspacing=2 cellpadding=0>";
  $pagecontent.="<tr>";
/*HERE IS WHERE MY MENU STARTS*/    $pagecontent.="<td width=150  valign=top><table width=150 background=../inc/skins/default/images/menu_bg.gif>
<tr><td><font size=2><b>Menu</b></font></td></tr>
<tr><td><font size=2><a href=show.php?status=add.php>Add Testimonials</a></font></td></tr>
<tr><td><font size=2><a href=show.php?status=n>New Testimonials</a></font></td></tr>
<tr><td><font size=2><a href=show.php?status=h>On Hold Testimonials</a></font></td></tr>
<tr><td><font size=2><a href=show.php?status=y>Active Testimonials</a></font></td></tr>
</table></td>";
   $pagecontent.="<td width=610 valign=top><table width=100% border=0 cellpadding=0 cellspacing=1 ";
while ($formdata=mysql_fetch_object($formdata_res)) {
	$link_display=htmlentities($formdata->link_display);
	$email=htmlentities($formdata->email);
	$company=htmlentities($formdata->company);
	$testimonials=htmlentities($formdata->testimonials);
 $pagecontent.="<tr>
  <td width=203 bgcolor=#F1F1F1><font size=2><b>Display:</b></font></td>
  <td width=203 bgcolor=#F1F1F1><font size=2><b>Email:</b></font></td>
  <td width=203 bgcolor=#F1F1F1><font size=2><b>Website:</b></font></td></tr>
  <td width=203 bgcolor=#E9EDF0><font size=2>{$link_display}</font></td>
  <td width=203 bgcolor=#E9EDF0><font size=2><a href='mailto:{$email}'>{$email}</a></font></td>
  <td width=203 bgcolor=#E9EDF0><font size=2><a href='{$company}' target=new>{$company}</a></font></td></tr>
  <tr><td colspan=2><font size=2><b>Testimonial:</b></font><textarea style=width=300; border: 1; rows=1>{$testimonials}</textarea></td>
  <td><center><a href='?id={$formdata->id}&action=approve'><img src=../inc/skins/default/images/approve.gif width=17 height=17 border=0 ALT=Approve></a> 
  <a href='?id={$formdata->id}&action=hold'><img src=../inc/skins/default/images/hold.gif width=17 height=17 border=0 ALT=Hold></a> 
  <a href='?id={$formdata->id}&action=delete'><img src=../inc/skins/default/images/delete.gif width=17 height=17 border=0 ALT=Delete></a> </center></td>
  </tr>";
}
$pagecontent.="</table></td>";
$pagecontent.="</tr>";
$pagecontent.="</table>";
db_close();
?>
I am wanting the show.php to display some kind of welcome on the first visit to the show.php page. Kind of like what I have here http://www.lsscripts.com/projects/testi ... /index.php

Then the add.php is also what I would like to have work with in the admi site. You can see it here http://www.lsscripts.com/projects/testi ... in/add.php

Now this add.php is defferent from the clients side. This will only be used my the admin.

Hope you understand what I am getting at. Thanks in advance on any advice.
Last edited by Lucnet on Wed Jul 07, 2004 4:51 pm, edited 1 time in total.
User avatar
xisle
Forum Contributor
Posts: 249
Joined: Wed Jun 25, 2003 1:53 pm

Post by xisle »

sounds good. :lol:
User avatar
Lucnet
Forum Commoner
Posts: 61
Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:

Post by Lucnet »

:? Sounds good. :? Yeah it does, but I would like to get it to work.
User avatar
Lucnet
Forum Commoner
Posts: 61
Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:

Post by Lucnet »

Nobody has any idea on how to do this. :cry:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

although it needs some sanitizing of the control values/variables, it looks like you are on the right track.
User avatar
Lucnet
Forum Commoner
Posts: 61
Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:

Post by Lucnet »

Yeah but I am unable to get the add.php to work. Is there like a place I could add a varible for it to call the add testimonials form layout. http://www.lsscripts.com/projects/testi ... n/show.php if you look here. Click on the add link in the menu and you will notice in the url it goes totally to a new page. The information on that page is what I want displayed in the show.php once the add testimonials is clicked.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

looks like you need to do some specialized processing on the $status variable to get it to work.. pretty simple.. use a switch statement.
User avatar
Lucnet
Forum Commoner
Posts: 61
Joined: Sat Jun 26, 2004 5:28 pm
Location: Alabama
Contact:

Post by Lucnet »

I added this above the case "approve"

Code: Select all

case "add":
          $pagecontent.="<form method=post>
  <p>Displayed Link<br>
  <input name=link_display>
  <br>
  <br>
  Website<br>
  <input name=company value=http://>
  <br>
  <br>
  Email<br>
  <input name=email>
  <br>
  <br>
  <br>
  <br>
  Testimonial<br>
  <textarea name=testimonials rows=7 cols=40></textarea>
  <br>
  <br>
  <input type=hidden name=action value=store>
  <input type=submit value='Submit'>";
    break;
But it will load this right a start no matter what link I click.
Post Reply