PHP - Using $row And Changing Values
Hi,
I'm using the following code: <td>$row[color]</td> and the possible values for this field are 1, 2 and 3. But I want the return to be red for 1, blue for 2, and green for 3. How do I write it so that instead of getting a row of 1's, 2's and 3's, I change those numbers to their corresponding colors? Thanks! Similar Tutorials
Table Issue - Multiple Location Values For User Pushes Values Out Of Row Instead Of Wrapping In Cell
I have a form for a sign in page that I want the label for the form field to actually be displayed in the text box and clear when the box is selected to enter text. I've accomplished this using the code below and it works fine. The problem that I'm having is in IE the password field does not change to display dots or asterisk in place of each character. It works fine in Fire Fox but not in IE. Is there way to accomplish this using php or so that it is compatible with most browsers? Here's the code that I'm using: Code: [Select] <?php echo "<input type=\"text\" name=\"pword\" size=\"17\" value=\"Password...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Password...') {this.value=''; this.style.color='#000000'; this.type='password';}\"> "; ?> Can be those <input ...> types with values changed from a script ?. Imagine it like we have an admin and we want to change some input values with a generated form on that page instead of going source and changing 1 by 1 ? Hi Just learning PHP and I'm struggling with a very simple problem. I'm playing around with arrays as i figure they're one of the most important things to know inside out but I can't work out how to change the value of an array element via a loop. I can obviously do it if I just directly write $cars[2] = "test" but not having any luck with the loop. I've tried using "foreach" and passing a new value to the $value variable but when i do a print_r the values in the array are unchanged. Code: [Select] $cars[0]="Saab"; $cars[1]="Volvo"; $cars[2]="BMW"; $cars[3]="Toyota"; foreach ($cars as $key => $value) { $value = "TEST"; echo $key . " " . $value . "<br />"; } print_r($cars) I then tried using a for loop Code: [Select] for ($i=0; $i <= count($cars); $i++) { echo $cars[$i]; $cars[$i] = "2"; } But this code just threw up a fatal error as follows: "Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 16 bytes) in /home/zzzzzzzz/public_html/php_testing/arrays.php on line 27" So would someone be kind enough to explain where i'm going wrong and why i get the fatal error on the second for loop. Thanks Drongo I'm not completely sure how to implement this so I'd like to ask you to give me an idea if you can For a tennis booking system.. it will look something similar to (should be a table but this is for the sake of the idea) Date: Oct 25th, 2010 (go to oct 26) Court 1 Court 2 Court 3 Court 4 8:00 Open(bookit) Tally Open Hellio 9:00 Andy Roger Barney Training ...etc Now everyday, this table should be empty, so new bookings can be made how would I make it so a new table is empty /or has dif bookings every day (based on date) efficiently? Im guessing I will have dif values in the sql table for dif dates but what I'm not sure of is how to display it in page for ex, if someone presses the button oct 26, the new table is for that date, wif diff values Hi I have an array which looks like this when i do a print_r(): Array ( => Array ( [path] => 1 [order] => 2 ) [1] => Array ( [path] => 2 [order] => 1 ) [2] => Array ( [path] => 3 [order] => 2 ) ) In this instance, I want to change the values of the order key. So I do something like this so that the last array has a path of 3 and an order of 1, and the others have orders of 2 foreach ($old_images as $old_image){ if($old_image['path']==3){ $old_image['order']="1"; } else{ $old_image['order']="2"; } } When i step through, i see that the order is changed, but when i do a print_r(), i get the same result. So even though im resetting the order value of the inside arrays, the multidimensional array does not change.... any ideas? I am trying to make a Web Form for people to fill out that has two drop down menus where i want the first drop down menu's selection changes the values of the selections in the second drop down. ((IE. If the first drop down value is "product 01" then the second drop down shows values "Red, Green, Blue" while if the first drop down value is "product 02" then the second drop down shows values "Yellow, Green")) Anyone have any ideas? Thanks in Advance. Ok I am testing foreach in an array as my practice. I wonder how can I assign values in the key of the array.. Here's the code Code: [Select] <?php $username = me_mysql_prep(trim($_POST['username'])); $first_name = me_mysql_prep(trim($_POST['first_name'])); $last_name = me_mysql_prep($_POST['last_name']); $email = me_mysql_prep($_POST['email']); $position = me_mysql_prep($_POST['Position']); $password = me_mysql_prep($_POST['password']); $hashed_password = sha1($password); $required_fields = array($username,$first_name,$last_name, $email, $position, $password); foreach($required as $key => $value) { if($value == "") { echo $key . " Cannot be empty<br>"; } } ?> So the result would be like this... IF username, first name and last name are EMPTY it will echo: Quote username cannot be empty first name cannot be empty last name cannot be empty Anyone? I posted a topic earlier and there was confusion as to what I could not work out.
I am able to display the checkbox, either checked or unchecked depending of the value or 1 or 0 in the obcDisplay field.
<input type="checkbox" name="obcDisplay" value="<?=$r['obcDisplay'] ?>" <?=($r['obcDisplay']) ? 'checked="checked"' : ''; ?>/>I am trying to update the DB table by the checkbox. If the checkbox is checked (obcDisplay = 1) and I uncheck the box and submit, I want the table updated so that obcDisplay now equals 0. When the form is displayed, the checkbox is now uncheck (obcDisplay = 0). Now I check the box and submit and the update changes the field from 0 to 1. I can display the checkbox as checked or unchecked by the DB field obcDisplay being either 0 or 1. It is changing the value where I am having the problem. Dear All Members here is my table data.. (4 Columns/1row in mysql table)
id order_no order_date miles How to split(miles) single column into (state, miles) two columns and output like following 5 columns /4rows in mysql using php code.
(5 Columns in mysql table) id order_no order_date state miles 310 001 02-15-2020 MI 108.53 310 001 02-15-2020 Oh 194.57 310 001 02-15-2020 PA 182.22
310 001 02-15-2020 WA 238.57 ------------------my php code -----------
<?php
if(isset($_POST["add"]))
$miles = explode("\r\n", $_POST["miles"]);
$query = $dbh->prepare($sql);
$lastInsertId = $dbh->lastInsertId(); if($query->execute()) {
$sql = "update tis_invoice set flag='1' where order_no=:order_no"; $query->execute();
} ----------------- my form code ------------------
<?php -- Can any one help how to correct my code..present nothing inserted on table
Thank You Edited February 8, 2020 by karthicbabuHi, My company has 240+ locations and as such some users (general managers) cover multiple sites. When I run a query to pull user information, when the user has multiple sites to his or her name, its adds the second / third sites to the next columns, rather than wrapping it inside the same table cell. It also works the opposite way, if a piece of data is missing in the database and is blank, its pull the following columns in. Both cases mess up the table and formatting. I'm extremely new to any kind of programming and maybe this isn't the forum for this question but figured I'd give it a chance since I'm stuck. The HTML/PHP code is below: <table id="datatables-column-search-select-inputs" class="table table-striped" style="width:100%"> <thead> <tr> <th>ID</th> <th>FirstName</th> <th>LastName</th> <th>Username</th> <th>Phone #</th> <th>Location</th> <th>Title</th> <th>Role</th> <th>Actions</th> </tr> </thead> <tbody> <?php //QUERY TO SELECT ALL USERS FROM DATABASE $query = "SELECT * FROM users"; $select_users = mysqli_query($connection,$query);
// SET VARIABLE TO ARRAY FROM QUERY while($row = mysqli_fetch_assoc($select_users)) { $user_id = $row['user_id']; $user_firstname = $row['user_firstname']; $user_lastname = $row['user_lastname']; $username = $row['username']; $user_phone = $row['user_phone']; $user_image = $row['user_image']; $user_title_id = $row['user_title_id']; $user_role_id = $row['user_role_id'];
// POPULATES DATA INTO THE TABLE echo "<tr>"; echo "<td>{$user_id}</td>"; echo "<td>{$user_firstname}</td>"; echo "<td>{$user_lastname}</td>"; echo "<td>{$username}</td>"; echo "<td>{$user_phone}</td>";
//PULL SITE STATUS BASED ON SITE STATUS ID $query = "SELECT * FROM sites WHERE site_manager_id = {$user_id} "; $select_site = mysqli_query($connection, $query); while($row = mysqli_fetch_assoc($select_site)) { $site_name = $row['site_name']; echo "<td>{$site_name}</td>"; } echo "<td>{$user_title_id}</td>"; echo "<td>{$user_role_id}</td>"; echo "<td class='table-action'> <a href='#'><i class='align-middle' data-feather='edit-2'></i></a> <a href='#'><i class='align-middle' data-feather='trash'></i></a> </td>"; //echo "<td><a href='users.php?source=edit_user&p_id={$user_id}'>Edit</a></td>"; echo "</tr>"; } ?>
<tr> <td>ID</td> <td>FirstName</td> <td>LastName</td> <td>Username</td> <td>Phone #</td> <td>Location</td> <td>Title</td> <td>Role</td> <td class="table-action"> <a href="#"><i class="align-middle" data-feather="edit-2"></i></a> <a href="#"><i class="align-middle" data-feather="trash"></i></a> </td> </tr> </tbody> <tfoot> <tr> <th>ID</th> <th>FirstName</th> <th>LastName</th> <th>Username</th> <th>Phone #</th> <th>Location</th> <th>Title</th> <th>Role</th> </tr> </tfoot> </table>
Hi all, I'm a first time poster here and I would really appreciate some guidance with my latest php challenge! I've spent the entire day googling and reading and to be honest I think I'm really over my head and need the assistance of someone experienced to advise the best way to go! I have a multi dimensional array that looks like (see below); the array is created by CodeIgniter's database library (the rows returned from a select query) but I think this is a generic PHP question as opposed to having anything to do with CI because it related to working with arrays. I'm wondering how I might go about searching the array below for the key problem_id and a value equal to a variable which I would provide. Then, when it finds an array with a the matching key and variable, it outputs the other values in that part of the array too. For example, using the sample data below. How would you recommend that I search the array for all the arrays that have the key problem_id and the value 3 and then have it output the value of the key problem_update_date and the value of the key problem_update_text. Then keep searching to find the next occurrence? Thanks in advance, as above, I've been searching really hard for the answer and believe i'm over my head! Output of print_r($updates); CI_DB_mysql_result Object ( [conn_id] => Resource id #30 [result_id] => Resource id #35 [result_array] => Array ( ) [result_object] => Array ( ) [current_row] => 0 [num_rows] => 5 [row_data] => ) Output of print_r($updates->result_array()); Array ( [0] => Array ( [problem_update_id] => 1 [problem_id] => 3 [problem_update_date] => 2010-10-01 [problem_update_text] => Some details about a paricular issue [problem_update_active] => 1 ) [1] => Array ( [problem_update_id] => 4 [problem_id] => 3 [problem_update_date] => 2010-10-01 [problem_update_text] => Another update about the problem with an ID of 3 [problem_update_active] => 1 ) [2] => Array ( [problem_update_id] => 5 [problem_id] => 4 [problem_update_date] => 2010-10-12 [problem_update_text] => An update about the problem with an ID of four [problem_update_active] => 1 ) [3] => Array ( [problem_update_id] => 6 [problem_id] => 4 [problem_update_date] => 2010-10-12 [problem_update_text] => An update about the problem with an ID of 6 [problem_update_active] => 1 ) [4] => Array ( [problem_update_id] => 7 [problem_id] => 3 [problem_update_date] => 2010-10-12 [problem_update_text] => Some new update about the problem with the ID of 3 [problem_update_active] => 1 ) ) Hi all, Just curious why this works: Code: [Select] while (($data = fgetcsv($handle, 1000, ",")) !== FALSE){ $import="INSERT into $prodtblname ($csvheaders1) values('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]')"; } And this does not: $headdata_1 = "'$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]'"; while (($data = fgetcsv($handle, 1000, ",")) !== FALSE){ $import="INSERT into $prodtblname ($csvheaders1) values($headdata_1)"; }it puts $data[#'s] in the database fields instead of the actual data that '$data[0]','$data[1]'... relates to. I wrote a script to create the values in $headdata_1 based on the number of headers in $csvheaders1 but can't seem to get it working in the sql statement. Thanks As I am VERY new to PDO, can someone help me in converting the below 2 codes so that I can setup the testing site knowing at least this part works. Below is the old SQL that I need to convert but don't have to foggiest on where to start. If I can get some help with this I can slowly work through the rest of my site with a bit more ease. LOGIN CODE: <?php if($_POST['submit']){ $Username = protect($_POST['Username']); $Password = protect(sha1($_POST['Password'])); if(!$Username || !$Password){ echo "<center>Please enter your <b>Username</b> and <b>Password</b>!</center>"; }else{ $res = mysql_query("SELECT * FROM `eusers` WHERE `Username` = '".$Username."'"); $num = mysql_num_rows($res); if($num == 0){ echo "<center>The <b>Username</b> or <b>Password</b> you supplied is incorrect!</center>"; }else{ $res = mysql_query("SELECT * FROM `eusers` WHERE `Username` = '".$Username."' AND Password = '".$Password."'"); $num = mysql_num_rows($res); if($num == 0){ echo "<center>The <b>Password</b> you supplied is incorrect!</center>"; }else{ $row = mysql_fetch_assoc($res); if($row['Active'] != 1){ echo "<center>Your login has been <b>deactivated</b>, Please contact your Manager for assistance.</center>"; }else{ header('Location: secure.php'); $time = date('U')+7200; //2 Hours mysql_query("UPDATE `eusers` SET `Online` = '".$time."' WHERE `id` = '".$_SESSION['uid']."'"); $_SESSION['uid'] = $row['id']; }}}}} ?> ACCESS GRANTED (Each Page): <?php if(strcmp($_SESSION['uid'],"") == 0){ printf("<script>location.href='index.php'</script>"); }else{ $time = date('U')+7200; //2 Hours $update = mysql_query("UPDATE `eusers` SET `Online` = '".$time."' WHERE `id` = '".$_SESSION['uid']."'"); } ?>
Hi, I am changing my ISP and need to import my databases.
Do I I have to create a new datarbase or can I change my database name to import?
My new host has a different database prefix ie: -web147xxxxxxxx
My old one was arewene1_wor1.
Many thanks.
// SESSION TEST if ($_SESSION['username']) { require_once("../mysql.php"); // Find Username from Session ID // Find Username from ID $finduser="SELECT username FROM users WHERE id='$_SESSION[username];'"; $finduserquery=mysql_query($finduser)or die(mysql_error()); $userfetch = mysql_fetch_array($finduserquery); // Set Username Variable $userfromid = $userfetch['username']; echo "lol" . ucwords($userfromid); } else { } Everytime I load this page more than once when logged in, it seems to turn the variable blank. Therefore making the user not be able to view other pages that use a session. Help? Thanks Hi, I'm having a problem with a hidden input value not changing on the browser after a request. I can change the value and alert or console log the new value but it won't change the DOM. Here's the section I'm having problems with:
xhr.onload = function() { if (xhr.status === 200) { var data = JSON.parse(this.responseText); $(".token").attr('value', data.token); alert($(".token").val()); } else { console.log('Something went terribly wrong...'); } }; Edited by Millertime1, 16 August 2014 - 03:34 PM. Hi I'm using a form that uses number_format. It works fine until the number in question gets into the thousands. I can enter "3000", click Calculate and it comes back as "3,000.00" which is perfect. But if I click Calculate again, it changes to "3.00". How can I get it to remain "3,000.00"? Here's the code: Code: [Select] <form action="test.php" method="POST" > <?php if (empty($_POST['data1'])) { $number = ''; } else { str_replace(",","",$_POST['data1']); $number = number_format((double)$_POST['data1'],2); } ?> <input type="text" style="40" name="data1" value="<?php echo $number; ?>"> <input type="submit" name="submitCalc" value="Calculate" /><br /> <a href="test.php">Reset Form</a> </form> Hi, I have a second website under the same domain www.lucyeleanorbrown.com/weddings.html which I wanted to change to www.weddings.lucyeleanorbrown.com, I have been looking around for PHP for this but am unsure of what to search for, could anyone give me a suggestion? Thank you Hi all I have a string called $voucher_code which is a value used to deduct or add value to a shopping cart. If the value is a minus I need it to show the minus sign, or if it's a plus value, it needs to show a plus sign. Here's my code: <strong>£ -".number_format(($voucher_code),2)."</strong> How do I modify the above code to show + instead of -- which it does at the moment? Many thanks for your help Pete Hi guys, i have a system and was asked to develop the site with the current system. These are sometimes a pain but it is an old system and i'm trying to change the url's which is seems to be hard to do with this kind of code. set_time_limit(60); include 'includes/config.php'; include 'includes/logfile.php'; include 'includes/databasefile.php'; include 'includes/templatefile.php'; $log = new cLog; $db = new cDatabase; //first run ssl check if necessary if ($_SERVER['SERVER_PORT'] == "80" && $sslredirect == 1) { header ("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . "?" . $_SERVER['QUERY_STRING']); exit(0); } //first, determine page requested list ($junk, $request) = split ("\?/", $_SERVER['REQUEST_URI']); list ($uri, $data) = split ("!", $request); $uriarray = split ("/", $uri); //check for login/logout request list ($junk, $request) = split ("\?", $_SERVER['REQUEST_URI']); if ($request == 'login') { header ("Location: login.php"); exit(0); } else if ($request == 'logout') { header ("Location: logout.php"); exit(0); } if ($data != "") { //parse internal variables $dataarray = split ("&", $data); foreach ($dataarray as $line) { list ($cmd, $val) = split ("=", $line); $arr_cmds[$cmd] = urldecode ($val); } } $pagename = $db->escape($uriarray[count($uriarray)-2]); $sectionname = $db->escape($uriarray[count($uriarray)-3]); if ($pagename == "") { $pagename = "home"; } if ($sectionname == "") { $sectionname = "home"; } $urlpagename = $pagename; $urlsectionname1 = $sectionname; $urlsectionname2 = $db->escape($uriarray[count($uriarray)-4]); //handle any commands, then redirect back to page $cmd = $_REQUEST['cmd']; if ($cmd == "-displayelement") { $elementid = $db->escape($_REQUEST['elementid']); if ($_REQUEST['surpresshtml'] == "") { echo "<html><head><link href='templates/css.css' rel='stylesheet' type='text/css'></head>\n"; } if ($_REQUEST['global'] == "1") { $query = $db->query("select ComponentName, Data from table_globalelements where (ElementID = '$elementid')"); } else { $query = $db->query("select ComponentName, Data from table_elements where (ElementID = '$elementid')"); } $r = $db->fetch_array($query); $currentcomponentname = $r['ComponentName']; $data = stripslashes($r['Data']); //find matching component and launch display function $dir_handle = opendir("com/components/"); while ($file = readdir($dir_handle)) { $filenoext = str_replace (".php", "", $file); if ($filenoext == $currentcomponentname) { include "com/components/" . $file; echo call_user_func(array($currentcomponentname, 'display'), $data); break; } } if ($_REQUEST['surpresshtml'] == "") { echo "</body></html>\n"; } exit (0); } else if ($cmd == '-editelement') { $elementid = $db->escape($_REQUEST['elementid']); if (isset($_SESSION['UserID'])) { $query = $db->query("select UserID, AdminFlag from table_users where (UserID = '" . $_SESSION['UserID'] . "')"); $r = $db->fetch_array($query); $userid = $r['UserID']; $adminflag = $r['AdminFlag']; if ($adminflag != "1") { $query = $db->query ("select ComponentName, Data, PageID from table_elements where (ElementID = '$elementid' and UserID = '$userid')"); } else { $query = $db->query ("select ComponentName, Data, PageID from table_elements where (ElementID = '$elementid')"); } $r = $db->fetch_array($query); $currentcomponentname = $r['ComponentName']; $data = stripslashes($r['Data']); $pageid = $r['PageID']; //handle request $cmd = $_REQUEST['greyboxcmd']; if ($cmd == 'save') { $elementid = $db->escape($_REQUEST['ElementID']); $data = $db->escape($_REQUEST['Data']); //find matching component and launch save function $dir_handle = opendir("com/components/"); while ($file = readdir($dir_handle)) { $filenoext = str_replace (".php", "", $file); if ($filenoext == $currentcomponentname) {; include "com/components/" . $file; $data = call_user_func(array($currentcomponentname, 'save')); if ($adminflag != "1") { $query = $db->query("update table_elements set Data = '$data' where (ElementID = '$elementid' and UserID = '$userid')"); } else { $query = $db->query("update table_elements set Data = '$data' where (ElementID = '$elementid')"); } echo "<script type='text/javascript'>parent.location.reload(true); parent.GB_hide();</script>\n"; exit(0); } } echo "Error: component not found..."; } //find matching component and launch edit function echo "<html><head><link href='templates/css.css' rel='stylesheet' type='text/css'><script type='text/javascript' src='templates/openwysiwyg/wysiwyg.js'></script></head>\n"; echo "<body style='text-align: center;'><form name='Form0' enctype='multipart/form-data' method='post' action='" . $_SERVER['REQUEST_URI'] . "'>\n"; $dir_handle = opendir("com/components/"); while ($file = readdir($dir_handle)) { $filenoext = str_replace (".php", "", $file); if ($filenoext == $currentcomponentname) {; include "com/components/" . $file; echo call_user_func(array($currentcomponentname, 'edit'), $data); break; } } echo "<input type='hidden' name='ElementID' value='$elementid'><input type='submit' name='Save' value='Save' class='smallbutton'>\n"; echo "<input type='button' name='Cancel' value='Cancel' onclick='parent.GB_hide();' class='smallbutton'>\n"; echo "<input type='hidden' name='greyboxcmd' value='save'></form></body></html>\n"; exit (0); } else { echo "<script type='text/javascript'>parent.GB_hide();</script>\n"; exit (0); } } else if ($cmd == '-editglobalelement') { $elementid = $db->escape($_REQUEST['elementid']); if (isset($_SESSION['UserID'])) { $query = $db->query("select UserID, AdminFlag from table_users where (UserID = '" . $_SESSION['UserID'] . "')"); $r = $db->fetch_array($query); $userid = $r['UserID']; $adminflag = $r['AdminFlag']; if ($adminflag != "1") { echo "Security - Out of bounds"; exit(0); } $query = $db->query ("select ComponentName, Data from table_globalelements where (ElementID = '$elementid')"); $r = $db->fetch_array($query); $currentcomponentname = $r['ComponentName']; $data = stripslashes($r['Data']); //handle request $cmd = $_REQUEST['greyboxcmd']; if ($cmd == 'save') { $elementid = $db->escape($_REQUEST['ElementID']); $data = $db->escape($_REQUEST['Data']); //find matching component and launch save function $dir_handle = opendir("com/components/"); while ($file = readdir($dir_handle)) { $filenoext = str_replace (".php", "", $file); if ($filenoext == $currentcomponentname) {; include "com/components/" . $file; $data = call_user_func(array($currentcomponentname, 'save')); $query = $db->query("update table_globalelements set Data = '$data' where (ElementID = '$elementid')"); echo "<script type='text/javascript'>parent.location.reload(true); parent.GB_hide();</script>\n"; exit(0); } } echo "Error: component not found..."; } //find matching component and launch edit function echo "<html><head><link href='templates/css.css' rel='stylesheet' type='text/css'><script type='text/javascript' src='templates/openwysiwyg/wysiwyg.js'></script></head>\n"; echo "<body style='text-align: center;'><form name='Form0' enctype='multipart/form-data' method='post' action='" . $_SERVER['REQUEST_URI'] . "'>\n"; $dir_handle = opendir("com/components/"); while ($file = readdir($dir_handle)) { $filenoext = str_replace (".php", "", $file); if ($filenoext == $currentcomponentname) {; include "com/components/" . $file; echo call_user_func(array($currentcomponentname, 'edit'), $data); break; } } echo "<input type='hidden' name='ElementID' value='$elementid'><input type='submit' name='Save' value='Save' class='smallbutton'>\n"; echo "<input type='button' name='Cancel' value='Cancel' onclick='parent.GB_hide();' class='smallbutton'>\n"; echo "<input type='hidden' name='greyboxcmd' value='save'></form></body></html>\n"; exit (0); } else { echo "<script type='text/javascript'>parent.GB_hide();</script>\n"; exit (0); } } //lookup page details $query = $db->query("select p.PageID, p.PageTitle, p.SectionID, p.TemplateID, p.UserID, p.LastUpdate, p.SectionName, s.SectionTitle, s.GroupID, s.Protected, p.Keywords, p.PageName from table_pages as p left join table_sections as s on s.SectionName = p.SectionName where (p.PageName = '$pagename' and s.SectionName = '$sectionname') limit 1"); if (!$pagedetails = $db->fetch_array($query)) { echo "404"; exit(0); } //check for privileges section if ($pagedetails[8] != "" && $pagedetails[8] != "0") { $sectionname = stripslashes($pagedetails[6]); if (!isset($_SESSION['Username']) && !isset($_REQUEST['Username'])) { echo "This is a restricted area. Please login.<br/><br/>"; echo "<form action='index.php' method='get'>Username: <input type='text' name='Username'><br/>\n"; echo "Password: <input type='password' name='Password'><br/>\n"; echo "<input type='submit' name='Login' value='Login'></form><br/>\n"; exit; } else { $username = $db->escape ($_REQUEST['Username']); $password = $db->escape ($_REQUEST['Password']); if ($username == "") { $username = $db->escape ($_SESSION['Username']); } if ($password == "") { $password = $db->escape ($_SESSION['Password']); } $query = $db->query("select UserID, Password, RealName, Email, GroupID, AdminFlag from table_users where (Username = '$username')"); $r = $db->fetch_array($query); $dbpassword = $r['Password']; if ($password == $dbpassword) { $_SESSION['Username'] = $username; $_SESSION['UserID'] = $r['UserID']; $_SESSION['RealName'] = $r['RealName']; $_SESSION['Email'] = $r['Email']; $_SESSION['GroupID'] = $r['GroupID']; } } if ($_SESSION['GroupID'] != $pagedetails[8]) { echo "This is a restricted area. Please login.<br/><br/>"; echo "<form action='index.php' method='get'>Username: <input type='text' name='Username'><br/>\n"; echo "Password: <input type='password' name='Password'><br/>\n"; echo "<input type='submit' name='Login' value='Login'></form><br/>\n"; exit; } } else { //check login details if user appears to be already logged in if (isset($_SESSION['Username'])) { $username = $db->escape ($_SESSION['Username']); $password = $db->escape ($_SESSION['Password']); $query = $db->query("select UserID, Password, RealName, Email, GroupID, AdminFlag from table_users where (Username = '$username')"); $r = $db->fetch_array($query); $dbpassword = $r['Password']; if ($password == $dbpassword) { $_SESSION['Username'] = $username; $_SESSION['UserID'] = $r['UserID']; $_SESSION['RealName'] = $r['RealName']; $_SESSION['Email'] = $r['Email']; $_SESSION['GroupID'] = $r['GroupID']; } } } //load template $tplate = new cTemplate($pagedetails['TemplateID'], $pagedetails['PageID']); $tplate->loadtemplate(); //add logout button if (isset($_SESSION['UserID'])) { echo "<div align='center'><small><a href='index.php?logout'>logout</a></small></div>\n"; } //log request if (getenv(HTTP_X_FORWARDED_FOR)) { $ip = getenv(HTTP_X_FORWARDED_FOR); } else { $ip = getenv(REMOTE_ADDR); } $log->writelog("/$sectionname/$pagename", "Access"); In the includes/templatefile.php file the code is like: function parsetemplate($templatefile) { global $db, $pageid, $pagedetails, $fullbaseurl, $adminemail; //first, find internal metacodes $pagetitle = stripslashes($pagedetails[1]); $lastupdate = date('l dS \of F Y h:i:s A', $pagedetails[5]); $sectiontitle = stripslashes($pagedetails[7]); $sectionname = stripslashes($pagedetails[6]); $templatefile = str_replace ("!PAGETITLE!", $pagetitle, $templatefile); $templatefile = str_replace ("!ADMINEMAIL!", $adminemail, $templatefile); $templatefile = str_replace ("!REQUEST_DOCUMENTID!", $_REQUEST['DocumentID'], $templatefile); $templatefile = str_replace ("!SECTIONTITLE!", $sectiontitle, $templatefile); $templatefile = str_replace ("!LASTUPDATE!", $lastupdate, $templatefile); $templatefile = str_replace ("!URL!", $_SERVER['REQUEST_URI'], $templatefile); $templatefile = str_replace ("!FULLBASEURL!", $fullbaseurl, $templatefile); $templatefile = str_replace ("!KEYWORDS!", $pagedetails[10], $templatefile); if ($_SESSION['UserID'] != "") { $templatefile = str_replace ("!LOGINDETAILS!", "- You are logged in as " . $_SESSION['Username'], $templatefile); } else { $templatefile = str_replace ("!LOGINDETAILS!", "", $templatefile); } $templatefile = str_replace ("!SECTIONLINK!", $fullbaseurl . "?/" . $sectionname . "/Home/", $templatefile); What i am getting via the links a Code: [Select] http://www.mydomain.com/?/Shop/Home/ How do i get rid of the "?" mark and the "/Home/". The /Home/ is also stored in the Database. I have tried a number of solutions by getting rid of the "?" and "/Home/" but i get the 404 error as the code shows. Can you please help with this? |