PHP - How to remove a user from the database MySQL - php

I created a table where users are discharged from the database. Each user has a row and next to it is a button for deleting a user from the database. The problem is that I do not know how to do to really removed the particular user from the database when I click on a specific button. I have no idea how to do it.
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"pl-PL\">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Rezultat zapytania</title>
<style>
#container {
max-width: 1000px;
}
</style>
</head>
<body>
<div id="container">
<table width="1000" align="center" border="1" bordercolor="#d5d5d5" cellpadding="0" cellspacing="0">
<tr>
<?php
require_once "connect.php";
$baza = #new mysqli($host, $db_user, $db_password, $db_name); //Połączenie z bazą danych
$sql = "SELECT id, user, pass, email FROM users";
$result = $baza->query($sql);
$ile = mysqli_num_rows($result);
echo "znaleziono: ".$ile."<br /><br />";
if ($ile>=1)
{
echo<<<END
<td width="50" align="center" bgcolor="e5e5e5"></td>
<td width="50" align="center" bgcolor="e5e5e5">IDUsera</td>
<td width="20" align="center" bgcolor="e5e5e5">NazwaUsera</td>
<td width="20" align="center" bgcolor="e5e5e5">HasloUsera</td>
<td width="20" align="center" bgcolor="e5e5e5">EmailUsera</td>
</tr><tr>
END;
}
for ($i = 1; $i <= $ile; $i++)
{
$row = mysqli_fetch_assoc($result);
$a1 = $row['id'];
$a2 = $row['user'];
$a3 = $row['pass'];
$a4 = $row['email'];
echo<<<END
<td width="50" align="center"><a class="button_red" href="delete_user.php">Delete</a></td>
<td width="50" align="center">$a1</td>
<td width="100" align="center">$a2</td>
<td width="100" align="center">$a3</td>
<td width="100" align="center">$a4</td>
</tr><tr>
END;
}
?>
</tr></table>
</div>
</body>
</html>

// create a <td> tag in <tr>
<td>DEL USER</td>
/* del.php */
$user_id = $_GET['user_id'];
// you can add a sql injection filter
$sql = 'DELETE FROM table WHERE user_id = {$user_id}';
$result = $baza->query($sql);

Related

Paginating With Mysqli And Prepared Statements

I am learning PHP. I tried building a script that shows records from MySQL by pagination.
I set the code to show 1 record per page. There are 4 records or matches on the MySQL table for the recipient 'admin123'. I have logged-into this account.
And so, this pagination script should pull 4 records to show me. 1 record per page. Total 4 pages. It gives echo 2 results found (it should show 4). And then only shows 1 record on the page as expected. But, I do not see the pagination section. No links to the other pages are getting shown like this:
Page 1234.
I am confused now. Please take a look and let me know where I am going wrong.
<?php
declare(strict_types=1);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
include 'configurations.php';
if (!$conn)
{
$error = mysqli_connect_error();
$errno = mysqli_connect_errno();
print "$errno: $error\n";
exit();
}
else
{
//Get Page Number. Default is 1 (First Page).
$page_number = $_GET["page_number"];
if ($page_number == "")
{
$page_number = 1;
}
$sender_username = $mod; //$mod defined in configurations.php
$recipient_username = $user;
$links_per_page = 1;
$max_result = 30;
$offset = ($page_number*$links_per_page)-$links_per_page;
$query_1 = "SELECT COUNT(*) FROM messages WHERE recipient_username = ?
AND sender_username = ? ORDER BY id LIMIT ? OFFSET ?";
$stmt_1 = mysqli_prepare($conn,$query_1);
mysqli_stmt_bind_param($stmt_1,'ssii',$recipient_username,$sender_username,$ links_per_page,$offset);
mysqli_stmt_execute($stmt_1);
$result_1 = mysqli_stmt_bind_result($stmt_1,$matching_rows_count);
mysqli_stmt_fetch($stmt_1);
mysqli_stmt_free_result($stmt_1);
$total_pages = ceil($matching_rows_count/$links_per_page);
$query_2 = "SELECT id,date_and_time,recipient_username,sender_username,warning_messages FROM
messages WHERE recipient_username = ? AND sender_username = ? ORDER BY id
LIMIT ? OFFSET ?";
$stmt_2 = mysqli_prepare($conn,$query_2);
mysqli_stmt_bind_param($stmt_2,'ssii',$recipient_username,$sender_username,$links_per_page,$offset);
mysqli_stmt_execute($stmt_2);
$result_2 = mysqli_stmt_bind_result($stmt_2,$id,$date_and_time,$recipient_username,$sender_username,$warning);
mysqli_stmt_fetch($stmt_2);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional/EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv=" content-type">
<title><?php echo "$site_name User $user Warnings in $server_time time."; ?>
</title>
</head>
<body>
<br>
<p align="center"><span style="font-weight:bold;"><?php echo "$site_name
User $user Warnings in $server_time time."; ?></span></align>
<br>
<br>
<table width="1500" border="0" cellpadding="5" cellspacing="2"
bgcolor="#666666">
<?php if(!$stmt_2)
{
?>
<tr>
<td bgcolor="#FFFFFF">No record found! Try another time.</td>
</tr>
<?php
}
else
{
if(($offset+1)<=$max_result)
{
printf("<b> %d Result Found ...</b>\n",$matching_rows_count); ?><br>
<br>
<tr name="headings">
<td bgcolor="#FFFFFF" name="heading_submission-
number">Submission Number</td>
<td bgcolor="#FFFFFF" name="heading_date-and-
time">Date & Time in <?php echo "$server_time" ?></td>
<td bgcolor="#FFFFFF" name="heading_recipient-
username">To</td>
<td bgcolor="#FFFFFF" name="heading_sender-
username">From</td>
<td bgcolor="#FFFFFF" name="heading_warning">Warning</td>
</tr>
<tr name="user-details">
<td bgcolor="#FFFFFF" name="submission-number"><?php
printf("%s",$id); ?></td>
<td bgcolor="#FFFFFF" name="date-and-time"><?php
printf("%s",$date_and_time); ?></td>
<td bgcolor="FFFFFF" name="recipient-username"><?php
printf("%s",$recipient_username); ?></td>
<td bgcolor="#FFFFFF" name="sender-username"><?php
printf("%s",$sender_username); ?></td>
<td bgcolor="#FFFFFF" name="warning"><?php printf("%s",$warning); ?>
</td>
</tr>
<?php
while(mysqli_stmt_fetch($stmt_2))
{
?>
<tr name="user-details">
<td bgcolor="#FFFFFF" name="submission-number"><?php
printf("%s",$id); ?></td>
<td bgcolor="#FFFFFF" name="date-and-time"><?php
printf("%s",$date_and_time); ?></td>
<td bgcolor="#FFFFFF" name="recipient-username"><?php
printf("%s",$recipient_username); ?></td>
<td bgcolor="#FFFFFF" name="sender-username"><?php
printf("%s",$sender_username); ?></td>
<td bgcolor="#FFFFFF" name="warning"><?php
printf("%s",$warning);
?></td>
</tr>
<?php
?>
<tr name="pagination">
<td colspan="10" bgcolor="#FFFFFF"> Result Pages:
<?php
if($page_number < $total_pages)
{
for($i=1;$i<=$total_pages;$i++) //Show Page Numbers in
Serial.
echo "<a href=\"{$_SERVER['PHP_SELF']}?
user=$user&page_number={$i}\">{$i}</a> ";
}
else
{
for($i=$total_pages;$i>=1;$i--) //Show Page Numbers in
Reverse.
echo "<a href=\"{$_SERVER['PHP_SELF']}?
user=$user&page_number={$i}\">{$i}</a> ";
}
?>
</td>
</tr>
<?php
}
}
}
?>
</table>
<br>
<br>
<p align="center"><span style="font-weight:bold;"><?php echo "$site_name
User $user Warnings in $server_time time."; ?></span></align>
<br>
</div>
<br>
</body>
</html>
<?php
mysqli_stmt_free_result($stmt_2);
mysqli_stmt_close($stmt_2);
mysqli_close($conn);
}
?>

Pagination is only changing the page number, not the content

I have a table with a list of users and I want to create pagination for this table.
However, when I click page number 2 the page changes but not the contents of the list of users.
<?php
session_start();
require_once "connect.php";
//Database connect
$database = #new mysqli($host, $db_user, $db_password, $db_name);
//Limit users
$start = 0;
$limit = 3;
//Question to -> Database
$sql = ("SELECT * FROM users LIMIT $start, $limit");
$adds = $database->query($sql);
//Return records
$rows = mysqli_num_rows($adds);
echo "Rows found in database.. ".$rows."<br /><br />";
if(isset($_GET['id']))
{
$id=$_GET['id'];
$start=($id-1)*$limit;
}
else{
$id=1;
}
if ($rows >= 1)
{
//the beginning of the table
echo<<<END
<table width="1000" align="center" border="1" bordercolor="#d5d5d5" cellpadding="0" cellspacing="0">
<tr>
<td width="50" align="center" bgcolor="e5e5e5"></td>
<td width="50" align="center" bgcolor="e5e5e5">IDUsera</td>
<td width="20" align="center" bgcolor="e5e5e5">NazwaUsera</td>
<td width="20" align="center" bgcolor="e5e5e5">EmailUsera</td>
<td width="20" align="center" bgcolor="e5e5e5">DataRejestracji</td>
<td width="20" align="center" bgcolor="e5e5e5">Indetyfikator grupy</td>
</tr>
<tr>
END;
}
while($score = mysqli_fetch_assoc($adds)) {
$row_score_id = $score['id'];
$row_score_user = $score['user']." ";
$row_score_register = $score['dataRes']. " ";
//continued table
echo<<<END
<td width="50" align="center"><a class="button_red" href="delete_user.php?id=''">Delete</a></td>
<td width="50" align="center">$row_score_id</td>
<td width="100" align="center">$row_score_user</td>
<td width="100" align="center"></td>
<td width="100" align="center">$row_score_register</td>
<td width="100" align="center"></td>
</tr>
END;
}
$pagnSql = ("SELECT * FROM users");
$pagnBase = $database->query($pagnSql);
$pagnRows = mysqli_num_rows($pagnBase);
$total=ceil($pagnRows/$limit);
if($id>1)
{
//Go to previous page to show previous 10 items. If its in page 1 then it is inactive
echo "<a href='?id=".($id-1)."' class='button'>PREVIOUS</a>";
}
if($id!=$total)
{
////Go to previous page to show next 10 items.
echo "<a href='?id=".($id+1)."' class='button'>NEXT</a>";
}
for($i=1;$i<=$total;$i++)
{
if($i==$id) { echo "<li class='current'>".$i."</li>"; }
else { echo "<li><a href='?id=".$i."'>".$i."</a></li>"; }
}
?>
You have to put the $start from GET
Change this
$start = 0;
To:
$start = $_GET[id];

PHP not passing SOME session variables to another script

I'm going nuts to try to understand why the script below (let's call it script1 is passing session variable $_SESSION['emptystcode'] to bulkstOLD.php but not the other two: $_SESSION['dlstrest'] and $_SESSION['dllist']. I have session_start(); on the first command line of the called script.
All this script1 does is to $_GET the Restaurant and List names and display a form where the user can fill in a CODE field and submit it.
To makes things worse, I've created another script (a simplified version of this caller script) which just set the session variables and calls the same bulkstOLD.php and it works ok. I wonder if this has something to do with the $_GET. Any help would be much appreciated.. Thanks!!
Here is the code:
<?php
session_start();
include ('logged.php');
require_once ('functions.php');
$acisversion = $_SESSION['acisversion'];
reset_all();
$cyear = date(Y);
$cmonth = date(M);
$cday = date(d);
$configs = include('config.php');
$_SESSION["module"] = 'st';
$_SESSION['favstlists_ref'] = 0;
$strest = $dlstrest = $_GET['dlstrest'];
$favstlist = $dllist = $_GET['dllist'];
$restname = 'restname_'.$strest;
$stlistrest = $configs[$restname];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>ACIS - Edit Lists</title>
<script type="text/javascript" src="jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="stmenu.js"></script>
<style type="text/css">
#import url(acis.css);
</style>
<script type="text/javascript" src="js.js"></script>
</head>
<body>
<div id="content">
<?php
$_SESSION['stcodesub'] = $stcodesub = $stcode = ($_POST["stcodein"]);
dbfile_init() ;
$_SESSION['stcode'] = $stcode;
if(isset($_POST["editSave"]))
{
connect_db ();
if (!empty($stcode))
{
check_code_for_st_list();
$emptystcode = 0;
}
else
{
$emptystcode = 1;
}
$_SESSION['dlstrest'] = $dlstrest;
$_SESSION['dllist'] = $dllist;
$_SESSION['emptystcode'] = $emptystcode;
if ((!$emptystcode and $codestok) or $emptystcode)
{
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=bulkstOLD.php">';
exit;
}
}
?>
<table width="100%" border="0" align="center">
<tr>
<td width="223" align="left"></td>
<td width="111" align="right"></td>
</tr>
</table>
</style>
<form method="post" id="editLists" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<table width="739" border="0" align="center" cellspacing="0" bgcolor="#171717">
<tr>
<td colspan="3"
style="color:#00CC00;
text-align: left;
padding: 0;
background: #2e2e2e url(images/nav_bar.jpg) repeat-x;
font-size: 0.9em;
color: white;
height:16px;"><script type="text/javascript" src="mainmenu.js"></script></td>
</tr>
<tr>
<td width="502"><h2 style="color:red;"> Atualizar Listas Favoritas de Pratos</h2></style></td>
<td width="231" colspan="2" align="right"><?php echo $configs[footer];?></td>
</tr>
<tr>
<td colspan="3" align="right" ><table width="100%" border="0" align="center">
<tr>
<td align="center">Restaurante:</td>
<td width="84" align="center" valign="bottom">Adicionar Código</td>
<td width="350" align="center">Lista a ser atualizada:</td>
<td width="150" align="left" valign="bottom"><span class="error"><?php echo $favErr;?></span></td>
</tr>
<tr>
<td width="135" align="center"><b><?php echo $stlistrest; ?></b></td>
<td align="center">
<?php
echo $stcodeline;
?>
</td>
<td align="center"><b><?php echo $dllist; ?></b></td>
<td align="right"><input type="submit" name="editSave" style="background-color: #009900; color: #FFFFFF;" value="Submeter" /></td>
</tr>
</table></td>
</tr>
</table>
</form>
<?php
$_SESSION["module"] = 'st';
?>
</div>
</body>
</html>
The only possible explanation for your problem is that you might have not written <?php session_start();?> in the very beginning, before any HTML tags(even doctype). Write it on top of every relevant php document.
Look if all your files are saved as UTF-8 without BOM, not just UTF-8.
This BOM dissables sessions.
And look if all your files are called as they are in the same subdomain.
www.domain.com/file1.php,
ww2.domain.com/file2.php,
domain.com/file3.php
... with diferent subdomains should not work.

Updating mySQL DB but POST is not returning a value

I'm trying to update two fields in an individual record. However, when I click the "Update" button and the changes are submitted nothing is posted to the assigned_to=$_POST['assigned'], the completed='_POST['completedTime'] or the id='$_POST['ticket']. I think when I click "Update" it is looking at every field named "assigned"/"completedTime"/ and "ticket". How can I ensure only one record is selected?
<?php require_once('../con.php'); ?>
<?php
//query DB
$query = "SELECT * FROM table";
$results = mysql_query($query, $con) or die (mysql_error() . mysql_error($con));
$row = mysql_fetch_assoc($results);
$totalRows = mysql_num_rows($results);
//Update db
if (isset($_POST['update']))
{
$update = "UPDATE table SET assigned_to=$_POST['assigned'], completed='$_POST['completedTime'] WHERE id='$_POST['ticket']'";
mysql_query($update, $con);
if (!mysql_query($update, $con))
{
die('Error: ' . mysql_error($con));
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
h1,h2,h3,h4,h5,h6 {
font-family: Arial, Helvetica, sans-serif;
}
h1 {
font-size: 18px;
}
h2 {
font-size: 14px;
}
</style>
</head>
<body>
<h1>Report</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" accept-charset="iso-8859-1">
<hr size="1" noshade="noshade" />
<table border="1" cellpadding="3" cellspacing="0" class="small">
<tr>
<td><strong>TicketNum</strong></td>
<td><strong>User</strong></td>
<td><strong>Category</strong></td>
<td><strong>Description</strong></td>
<th>Comments</th>
<td><strong>Date</strong></td>
<td><strong>AssignedTo</strong></td>
<td><strong>CompletedDate</strong></td>
</tr>
<?php do { ?>
<tr bgcolor="<?php
$colorarray=array('#FFFFFF','#D9ECFF');
$colorarraysize=count($colorarray);
if ($BRB_rowcounter++%1 == 0){
if ($colorarrayindex<($colorarraysize-1)){
$colorarrayindex++;
}else{
$colorarrayindex=0;
}
}
echo "$colorarray[$colorarrayindex]"; ?>">
<td valign="top" nowrap="nowrap"><?php echo $row['id']; ?></td>
<td valign="top" nowrap="nowrap"><?php echo $row['username']; ?></td>
<td valign="top" nowrap="nowrap"><?php echo $row['category']; ?></td>
<td valign="top" nowrap="nowrap"><?php echo $row['title']; ?></td>
<td valign="top"><?php echo $row['issue_details']; ?></td>
<td valign="top" nowrap="nowrap"><?php echo $row['timestamp']; ?></td>
<td valign="top" nowrap="nowrap"><input type="text" name="assigned" value ='<?php echo $row['assigned_to']; ?>'></td>
<td valign="top" nowrap="nowrap"><input type="text" name="completedTime" value ='<?php echo $row['completed']; ?>'></td>
<td><input type="hidden" name="ticket" value ='<?php echo $row['id']; ?>'></td>
<td><input type="submit" name="update" value="Update"></td>
</tr>
<?php } while ($row = mysql_fetch_assoc($results)); ?>
</table>
</form>
</body>
</html>
<?php
mysql_free_result($update);
mysql_free_result($results);
?>
Try it:
<?php
require_once('../con.php');
//Update db
if (isset($_POST['update']))
{
$update = "UPDATE table SET assigned_to='{$_POST['assigned']}', completed='{$_POST['completedTime']}' WHERE id='{$_POST['ticket']}'";
$result = mysql_query($update, $con) or die ('Error' . mysql_error($con));
}
//query DB
$query = "SELECT * FROM table";
$results = mysql_query($query, $con) or die (mysql_error() . mysql_error($con));
$totalRows = mysql_num_rows($results);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
h1,h2,h3,h4,h5,h6 {
font-family: Arial, Helvetica, sans-serif;
}
h1 {
font-size: 18px;
}
h2 {
font-size: 14px;
}
</style>
</head>
<body>
<h1>Report</h1>
<hr size="1" noshade="noshade" />
<table border="1" cellpadding="3" cellspacing="0" class="small">
<tr>
<td><strong>TicketNum</strong></td>
<td><strong>User</strong></td>
<td><strong>Category</strong></td>
<td><strong>Description</strong></td>
<th>Comments</th>
<td><strong>Date</strong></td>
<td><strong>AssignedTo</strong></td>
<td><strong>CompletedDate</strong></td>
</tr>
<?php
while ($row = mysql_fetch_assoc($results)) {
$colorarray = array("#FFFFFF","#D9ECFF");
$colorarraysize = count($colorarray);
if ($BRB_rowcounter++%1 == 0){
if ($colorarrayindex<($colorarraysize-1)){
$colorarrayindex++;
}else{
$colorarrayindex=0;
}
}
$content .= <<< END
<form action="" method="POST" accept-charset="iso-8859-1">
<tr bgcolor="{$colorarray[$colorarrayindex]}">
<td valign="top" nowrap="nowrap">{$row['id']}</td>
<td valign="top" nowrap="nowrap">{$row['username']}</td>
<td valign="top" nowrap="nowrap">{$row['category']}</td>
<td valign="top" nowrap="nowrap">{$row['title']}</td>
<td valign="top">{$row['issue_details']}</td>
<td valign="top" nowrap="nowrap">{$row['timestamp']}</td>
<td valign="top" nowrap="nowrap"><input type="text" name="assigned" value="{$row['assigned_to']}"></td>
<td valign="top" nowrap="nowrap"><input type="text" name="completedTime" value="{$row['completed']}"></td>
<td><input type="submit" name="update" value="Update"></td>
</tr>
<input type="hidden" name="ticket" value="{$row['id']}">
</form>
END;
}
echo $content;
mysql_free_result($results);
?>
</table>
Your string interpolation syntax is incorrect. It should be:
$update = "UPDATE table SET assigned_to='{$_POST['assigned']}', completed='{$_POST['completedTime']}' WHERE id='{$_POST['ticket']}'";
You need to put { } around an array reference if the index contains quotes. You can also leave out the quotes:
$update = "UPDATE table SET assigned_to='$_POST[assigned]', completed='$_POST[completedTime] WHERE id='$_POST[ticket]'";
You also had some missing quotes and dollar signs, which I've fixed here.
See the PHP documentation for details of string syntax.
However, this is very poor style, since it's subject to SQL injection. You should preferable use an API that supports prepared queries (PDO, mysqli); if not, assign the $_POST parameters to variables and call mysql_real_escape_string() to sanitize them.

different account types with different Links in PHP

Trying to make a simple site where users can have different account levels.
For example, user with account type 'a' and 'b' will see a Link/button at the top which says basic and the users with account type 'c' will see a Link/button which says full member.
I have a code which will almost do what I need and it will save the users in different A/B/C categories in the database.
I just need to know what I have to do to be able to show different links to different account type as I explained above?
also, I know the code bellow is not the greatest codes but just need to achieve the results I am after for now with what I have.
<?php
session_start(); // Must start session first thing
// See if they are a logged in member by checking Session data
$toplinks = "";
if (isset($_SESSION['id'])) {
// Put stored session variables into local php variable
$userid = $_SESSION['id'];
$username = $_SESSION['username'];
$toplinks = '' . $username . ' •
Account •
Log Out';
} else {
echo 'Please log in to access your account';
exit();
}
?>
<?php
//Connect to the database through our include
include_once "scripts/connect_to_mysql.php";
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT * FROM members WHERE id='$userid'");
while($row = mysql_fetch_array($sql)){
$country = $row["country"];
$state = $row["state"];
$city = $row["city"];
$accounttype = $row["accounttype"];
$bio = $row["bio"];
}
// Give different options or display depending on which user type it is
if ($accounttype == "a") {
$userOptions = "You get options for Expert User";
} else if ($accounttype == "b") {
$userOptions = "You get options for Expert User";
} else if ($accounttype == "c") {
$userOptions = "You get options for Expert User";
} else {
$userOptions = "You get options for Super User";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Member Account</title>
<link rel="stylesheet" type="text/css" href="style/style.css">
<style type="text/css">
<!--
body {
margin: 0px;
background-image: url(imgs/bgnoise.png);
background-repeat: repeat;
}
-->
</style>
</head>
<body>
<?php include_once("temps/template_header.php");?>
<table style="background-image: url(imgs/horizontal_nav_bg.jpg);" repeat="x" width="100%" border="0" cellpadding="0">
<tr>
<td height="94" ><table style=" margin-left:20px; " width="734" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="156"><p><img src="imgs/info.png" width="35" height="35" border="0" "/>Edit Information</p></td>
<td width="179"><img src="imgs/very.png" width="35" height="35" border="0" />Verify Your Identity</td>
<td width="126"><img src="imgs/profile.png" width="35" height="35" border="0" />View Profile</td>
<td width="138"><img src="imgs/basket.png" width="35" height="35" />Buy Bitcoin</td>
<td width="135"><img src="imgs/user.png" width="35" height="35" alt="user" /><?php echo "$username"; ?></td>
</tr>
</table> <h1> </h1></td>
</tr>
</table>
<table width="700" align="right" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><h3></h3></td>
</tr>
</table>
<table width=950" cellpadding="3" cellspacing="3" style="line-height:1.5em;">
<tr>
<td width="118" valign="top" bgcolor="#E4E4E4"><h6>YOUR ACCOUNT<br />
Edit Information <br />
Verify Your Identity<br />
View Profile</h6>
<h6><?php echo "$bio"; ?><br />
</h6></td>
<!-- See the more advanced member system tutorial to see how to place default placeholder pic until member uploads one -->
<td width="160" valign="top"><div align="center"><img src="memberFiles/<?php echo "$userid"; ?>/pic1.jpg" alt="Ad" width="150" /></div></td>
<td width="201" valign="top">
Country: <?php echo "$country"; ?> <br />
State: <?php echo "$state"; ?><br />
City: <?php echo "$city"; ?>
<table width="50" border="0" cellspacing="0" cellpadding="0">
<tr>
</tr>
</table> <br />
</td>
<td width="430" margin="left" style="margin-right:0px;" rowspan="2" valign="top"><div id="veri"><img src="imgs/verifynote.png" width="430" height="600" /> </div></td>
</tr>
<tr>
<td colspan="3" valign="top"><br />
<br />
<br />
<div style="overflow:hidden; width:100%px;">
<iframe width="565" height="400" scrolling="no" frameBorder="0"
src="http://bitcoin.clarkmoody.com/widget/chart/"
style="width:728px; height:270px; border:none; margin-left:-60px;"/>
</div>
</td>
</tr>
</table>
<?php include_once("temps/template_footer.php");?>
</body>
</html>`
Please be gentle as I am a newbie in PHP and just learning the curves.
Thanks
I am not sure if I got this correctly but if you want according to the user's group to display different links just do:
if ($accounttype == "a") {
echo 'Page for user a';
}
else if ($accounttype == "b") {
echo 'Page for user b';
} else if ($accounttype == "c") {
echo 'Page for user c';
} else {
echo 'Page for others';
}
Also I suggest you to use mysqli. It is pretty similar to mysql. http://php.net/manual/en/book.mysqli.php (Myqsl is being removed)

Categories