need help creating an update & confirm page

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
mikewooten
Forum Contributor
Posts: 169
Joined: Wed Feb 11, 2004 12:13 pm
Location: Duluth, Georgia
Contact:

need help creating an update & confirm page

Post by mikewooten »

i am working on an administration section. i need help creating an edit/update page where i click the update link on a showproducts page, and that link goes to another page where i can fill out a form from the showproducts page that i can update the info. from the information that is in the show products page.
with the confirm page, i need a confirm link on the show products page that takes me to another page where that page shows me that one row of information on that other page. then from that page i have the option to delete that one row or go back to the show products page.
does anyone know how to do that or can anyone help me out with this
any help would be much appreciated.
thanks
here is the code that i am using

Code: Select all

<?php

require_once('book_sc_fns.php'); 

$redo = $_GET[doredo]; 

session_start();

do_html_header('Administration');

$dbname = "rmgiusa"; 
$tblname = "items"; 
$linkid = mysql_connect("localhost", "username", "password") or die("Couldn't connect.");  
$db = mysql_select_db($dbname, $linkid) or die("Couldn't select database."); 
mysql_query ("SELECT * FROM $tblname"); 
echo "$select<br>";			
	$host    ="localhost";
	$dbuser="username";
	$dbpass="password";
	$database="rmgiusa";				
mysql_connect($host,$dbuser,$dbpass);
mysql_select_db($database) or die ("Unable to select database");    
$query="SELECT * FROM $tblname ORDER BY itemId ASC";  
$result=mysql_query($query);
$num=mysql_num_rows($result);  
$result = mysql_query($query, $linkid);   
include("include_code5.php");  
$result = mysql_query($query);



echo "<table border='1' bordercolor='#000000' cellpadding='0' cellspacing='0' width='100%'>";  
echo "<tr>";
echo "<td width='5%'><strong><center>cat id</center></strong></td>";
echo "<td width='6%'><strong><center>item id</center></strong></td>";
echo "<td width='10%'><strong><center>product item</center></strong></td>"; 
echo "<td width='10%'><strong><center>item name</center></strong></td>"; 
echo "<td width='20%'><strong><center>item image</center></strong></td>";
echo "<td width='30%'><strong><center>item desc</center></strong></td>";
echo "<td width='14%'><strong><center>item price</center></strong></td>";
echo "<td width='5%'><strong><center>Delete</td>";
echo "<td width='5%'><strong><center>Update</td>";
echo "</tr>";
while($query_data = mysql_fetch_row($result)) {
echo "<tr>";
echo "<td>$query_data[0]</td>";
echo "<td>$query_data[1]</td>";
echo "<td>$query_data[2]</td>"; 
echo "<td>$query_data[3]</td>";
echo "<td><img src='../p_imgs/$query_data[4]'></td>";
echo "<td>$query_data[5]</td>";
echo "<td>$query_data[6]</td>";
echo "<td>";
?>
<br>
<a href="showprod4.php?action=delete_proditem_row&id=<?php echo $query_data[1];  ?>">delete</a>
<br>
<a href="prod_confirm2.php">confirm</a>
<?
if(!$redo){
print "<a href='showprod4.php?doredo=true'>confirmdelete</a>";}
else if($redo){
?>
<br><a href='showprod4.php?action=delete_proditem_row&id=<? $query_data[1] ?>'>
<font color='red' size='1'>ARE YOU SURE YOU WANT TO DELETE THIS INFORMTION?</font></a>
<?
}
?>
<?
echo "</td>";
echo "<td>";
?>
<a href="prod_update.php">update</a>
<?
echo "</td>";
echo "</tr>";
}     
echo "</table>";  
do_html_footer();
?>




?>
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

header('Location: page.php?productid=".$pid);

then pull the information needed from the database using the product id
mikewooten
Forum Contributor
Posts: 169
Joined: Wed Feb 11, 2004 12:13 pm
Location: Duluth, Georgia
Contact:

Post by mikewooten »

would that header go on the confirm page? or what page would that header go on?
thanks
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

it will go on the the page you want to have redirect to another
mikewooten
Forum Contributor
Posts: 169
Joined: Wed Feb 11, 2004 12:13 pm
Location: Duluth, Georgia
Contact:

Post by mikewooten »

for the link that goes on the show products page to take me to a confirm page and/or edit/update page, i wouln't need a header to redirect, would I? would i need a link that you would click to go to the confirm page and/or the edit/update page? if i needed a link, how would i get the information from that row and pass it through to the next page using the link to get the information onto the confirm and update/edit page? how would the confirm link look like? would it be something like the delete link that i have in my code and what would the update link be? would it just be a link that goes to the update page or would i have to pass information through that link, if i had to pass information through the link, what information would i have to put into the link, how would i do that?
thanks
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

u might want to look at sessions
mikewooten
Forum Contributor
Posts: 169
Joined: Wed Feb 11, 2004 12:13 pm
Location: Duluth, Georgia
Contact:

Post by mikewooten »

i have looked at sessions. how would i use them to do what i need to do?
i think that i would have to use session_id, and session_start, and maybe session_name. what sessions would i use and how would i use them?
thanks
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

well it seems your passing variables from page to page

which is okay to do thru the URL and use the $_GET superglobal, but its not secure.

sessions would be your best bet, start a session and assign the variables to the $_SESSION array, any page u wish to access the variables u stored in the session array needs a session_start(); and you can simply compare n contrast or do whatever u need to do with the session vars.

I'm not going to write this out for you, theres a billion and 1 session tutorials that would explain it in detail. Come back if you encounter a problem
Post Reply