PHP - Variable Doesn't Show Up In Url
hey guys,
I'm in the process of transforming my static html website into "something" more dynamic. I came across an article on bilingual website (http://www.jacksonengineering.net/proj_phplanguage.php) and I basically used the same idea for my project. Everything works fine except for one thing - links to different language web pages are generated correctly page.php?lang=pl but when I click on the link, the url loses the variable and looks like page.pl.php What to do? Code: [Select] language.php <?php //the url ? language declaration should have preference over the page name $pagename = basename($_SERVER['PHP_SELF'],".php"); $pagenamearray = explode(".",$pagename); if (count($pagenamearray) == 2){ //there is currently a bi-lingual site page loaded $_SESSION['language'] = $pagenamearray[1]; $urllang = $pagenamearray[1]; }else{ //this page must be a non bi-lingual page $urllang = 'en'; } //check for a language selection on the url if(isset($_GET["lang"])){//language has been passed via url $_SESSION['language'] = htmlspecialchars($_GET["lang"]); //set it what was found } ///if there still is no language set, go with english for a default if(!isset($_SESSION['language'])){ $_SESSION['language'] = 'en'; } //now we think we have the session language figured out // //now check for a version of the current page in the desired language //lets make some things clear first //the current page url is either en or pl from $urllang if($urllang != $_SESSION['language']){ //if the url isn't the same as the $_SESSION if($_SESSION['language'] == 'en'){//if it should be english then load the english header("Location: $pagenamearray[0].php"); exit; } if($_SESSION['language'] == 'pl'){ //construct the name of the file if it existed filename.pl.php $plVersion = $pagenamearray[0] . ".pl.php"; //we have to check if a pl version actually exists of this page if(file_exists($plVersion)){//redirect if it exists header("Location: $plVersion"); exit;//stop executing things }else{$pagelangnotfound = true;} } } ?> Code: [Select] header.php <?php if ($_SESSION['language'] != 'en'){ echo 'Select Language: <a href="'. $_SERVER['PHP_SELF'] . '?lang=en"><img src="img/gb.gif" alt="English" class="off" /></a>'; }else{echo 'Wybierz J&#281;zyk: <img src="img/gb.gif" alt="English" />';} ?> <?php if ($_SESSION['language'] != 'pl'){ echo '<a href="'. $_SERVER['PHP_SELF'] . '?lang=pl"><img src="img/pl.gif" alt="Polish" class="off" /></a>'; }else{ echo '<img src="img/pl.gif" alt="Polish" />'; } ?> Code: [Select] menu.php <?php if($pageOn == 'index.php'){?> id="selected"<?php }?>> <a href="index.php">Main Page</a> Code: [Select] page.php <?php session_start(); include "language.php"; $pageOn = basename($_SERVER['PHP_SELF']); $mItem = $pageOn; ?> <?php include("header.php"); ?> <?php include("menu.php"); ?> English content Code: [Select] page.pl.php <?php session_start(); include "language.php"; $pageOn = basename($_SERVER['PHP_SELF']); $mItem = $pageOn; ?> <?php include("header.php"); ?> <?php include("menu.php"); ?> Polish content Similar TutorialsHi im trying to pass a variable through a url. Here's the code : echo"<td class='tableContent'><span onmouseover=\"tooltip.show('Click to add details to ".$result['workObject']."');\" onmouseout=\"tooltip.hide();\"><a href='addRemarksBucc.php?workObject=".$result['workObject']."'>".$result['systemRemarks']."</a></span></td>"; and here's the code to the next page: <table width="550" border="0" cellspacing="5" cellpadding="0"> <tr> <td width="78" valign="top">Work Object</td> <td><input name="workObject" id="workObject" type="text" value="<?php $_GET['workObject']; ?>" /></td> </tr> <tr> <td valign="top">Remark Details</td> <td><textarea name="errorMessage2" cols="50" rows="10" id="errorMessage2" accesskey="p" tabindex="1"></textarea> <input name="workObject2" type="hidden" value="" /></td> </tr> <tr> <td valign="top"> </td> <td> </td> </tr> <tr> <td> </td> <td><input name="submit" type="submit" class="btn" id="submit" accesskey="R" tabindex="11" value="Submit" /> <input name="reset" type="reset" class="btn" id="reset" accesskey="e" tabindex="12" value="Reset" /></td> </tr> </table> What am I doing wrong? The address bar shows the right url but the second page doesn't display any value for workObject. Thanks! I'm trying to do a simple PHP form with Securimage Captcha and whenever I add this variable "$securimage = new Securimage();" the page displays nothing. Could someone please help me with this? My php file is already in the securimage directory so that's why I'm pointing directly to the file. I'm trying to expand my knowledge on some more str type functions, and I've always wanted to learn implode and explode, but I was just too lazy. Anyways, for some reason, if I type in: salad,pizza,apples - the first value in the array, salad, doesn't show up. o.O <?php $favorite_food = $_POST['favorite_food']; if(!$favorite_food) { ?> <form action="words.php" method="POST"> <input type="text" name="favorite_food"> <input type="submit"> </form> <?php } else { $ex = explode(",", $favorite_food); $amount = count($ex) + 1; while($i < $amount) { echo $ex[$i]."<br/>"; ++$i; } } ?> I know arrays start at 0, so thats why I added 1 to the count. I need to copy a table from one code to another. But I couldn't figure out how to do it properly. Just tried to copy code from one file to another but it doesn't work the same. I need to find where to change the code to show right columns.
https://easyupload.io/maoa9h - zipped cart.php (original code with right table) and review.php (the one that doesn't show right table)
We need to copy the table from cart.php: But it doesn't work. The quantity column doesn't show in review.php - as you can see here https://ibb.co/brP0yy1 I have a page that shows entries in a guestbook I'm making, and below the entries there is supposed to be a form to write an entry. Except, none of the HTML after the script to show the entries shows up on the page. I have no clue what's wrong. Here is the script to show the entries. $n is name, $d is date, $s is site (optional), and $m is message. $file = fopen("posts.txt", 'rb'); flock($file, LOCK_SH); while(!feof($file)){ $entry = fgetcsv($file, 0, '|'); if(empty($entry)){exit;} $d = $entry[1]; $n = $entry[2]; $s = $entry[3]; $m = $entry[4]; echo ' <table style="border: #3399AA 1px solid;"><tr style="background: #3399AA; font: bold 10px verdana,sans-serif; color: #FFFFFF;"> <td width="170">'.$n.'</td> <td align="right" width="170">'.$d.'</td> </tr> '; if($s != 'none'){ echo ' <tr><td colspan="2" style="font: 10px verdana,sans-serif; color: #3399AA;"> <b>Site: </b><a href="'.$s.'">'.$s.'</a> <center><div style="width: 250; height: 1px; background: #3399AA; margin: 10px;"></div></center></td></tr> '; } echo ' <tr> <td colspan="2" style="font: 10px verdana,sans-serif; color: #3399AA;">'.$m.'</td> </tr></table><br> '; } flock($file, LOCK_UN); fclose($file); The file it is reading looks like this: Code: [Select] |11:51 am, 3rd Nov 2010|Memoria|none|Hello. :) |11:51 am, 3rd Nov 2010|Memoria|http://sitehere|Hello again. |11:51 am, 3rd Nov 2010|Memoria|none|How are you doing? Thanks! Hello all, I can't get the data store in the $ART_ID variable to pass into the database. The original $Artisan variable is set up like this: 1. Artisan Name. So the explode is taking just the number. If I put an echo after the explode and the $ART_ID variable it outputs the correct information but it doesn't store in the database as that data. The query is in correct order too. Thanks in advance. $CType_Type = $_REQUEST["CTYPE_Type"]; $Artisan = $_REQUEST['Artisan']; $Quantity = $_POST['Quantity']; $HAnswer1 = $_POST["HAnswer1"]; $HAnswer2 = $_POST["HAnswer2"]; $HAnswer3 = $_POST["HAnswer3"]; $HAnswer4 = $_POST["HAnswer4"]; $break = explode(".", $Artisan); $ART_ID = $break[0]; if(!$Quantity) { die('Quantity field is empty. Please enter the quantity of handicrafts made.'); } else { $ctypeQuery = mysql_query("SELECT CTYPE_ID FROM CraftType WHERE CTYPE_Type = '".$CType_Type."'"); while($row = mysql_fetch_array($ctypeQuery)) { $CTYPE_ID = $row["CTYPE_ID"]; $sql = ("INSERT INTO Handicraft VALUES (`HANDI_ID`, '".$Quantity."', 'NULL', '".$CTYPE_ID."', '".$ART_ID."', 'NULL', '1')"); if(!mysql_query($sql)) { die('Error inserting Handicraft Type into table: ' . mysql_error()); } else { -----data in this section doesn't affect the rest of the code---- } } } How would I write this in php?: Code: [Select] If $url does not begin with 'http://' $url = '' I want to assign nothing to the variable if it doesn't begin with http:// Thanks!
When I echo out my variable in the php file it works fine but when I put the variable in a table cell it doesn't echo out. Hello, I am writing my first php script (of course) and it works except it only shows 4 variables. Example I have it to send me: mail($myemail, $fullname, $email, $message, $phone); But it will only send me the first four no matter what order they are in. It's driving me crazy. I can't think or find any reason why it would do this. If I change it to mail($myemail, $fullname, $email, $phone, $message); It will send me everything but $message if I change it to mail($myemail, $fullname, $message, $email, $phone ); It will send me everything but $phone Does anyone know why or what I need to change? I apologize if this sounds like a dumb question. I am very very new to php. Thank you for any guidance you can give. Here is the code: HTML: <form action="Contact.php" method="post" id="contact" name="contact" style="margin:0px";> <h2>Contact Form:</h2> <p>Fields marked (<span style="color:#F00;">*</span>) are required.</p> <p> <label for="text_fullname">Full Name<span style="color:#F00;">*</span>:</label> <input name="fullname" type="text" class="input" id="fullname" tabindex="1" /> <label for="text_email">Email<span style="color:#F00;">*</span>:</label> <input name="email" type="text" class="input" id="email" tabindex="2" /> <label for="text_phone">Phone:</label> <input name="phone" type="text" class="input" id="phone" tabindex="3" /> <label for="text_comments">Message/Comment:</label> <textarea name="message" cols="23" rows="3" class="input" id="message" tabindex="4"></textarea> <br> <div style="padding-left:200px;"> <button type="submit" id="send" name="send">Send!</button> <button type="reset">Reset</button> </div> </form> --------------------------------------- PHP: <?php /* Set e-mail recipient */ $myemail = "tkowebworks@gmail.com"; $fullname = $_POST['fullname'] ; $email = $_POST['email'] ; $phone = $_POST['phone'] ; $message = $_POST['message'] ; mail($myemail, $fullname, $email, $message, $phone); header( "Location: http://www.ppm-oc.com/thankyou.html" ); ?> ---------------------------------- Thank you hi im having trouble with my login script i keep getting the errors Deprecated: Function session_register() is deprecated in C:\wamp\www\login.php on line 53 Deprecated: Function session_register() is deprecated in C:\wamp\www\login.php on line 57 Deprecated: Function session_register() is deprecated in C:\wamp\www\login.php on line 61 i just wanted to knw wot they mean the page styll runs ok, is there any way i can make it work Code: [Select] $sql = mysql_query("SELECT * FROM myMembers WHERE email='$email' AND password='$pass' AND email_activated='1'"); $login_check = mysql_num_rows($sql); if($login_check > 0){ while ($row = mysql_fetch_array($sql)){ $id = $row["id"]; session_register('id'); $_SESSION['id'] = $id; $firstname = $row["firstname"]; session_register('firstname'); $_SESSION['firstname'] = $firstname; $email = $row["email"]; session_register('email'); $_SESSION['email'] = $email; mysql_query("UPDATE myMembers SET last_log_date=now() WHERE id='$id'"); $my_msg="Hello $firstname, you have succesfully logged in"; //print "return_msg=$my_msg&id=$id&firstname=$firstname"; } // close while } else{ $my_msg="Error Your Password Or Email Did Not Match"; // print "return_msg=$my_msg"; exit(); } } also im having trouble with my my_msg variable it does not seem to show up i keep gettin error if ($count==1){ header("Location:store.php"); }very simple I have issolated it and it doesn't redirect maybe u can see where my mistake is I want to show a cookie of a referral's username on a sign up page. The link is like this, www.mysite.com/signup?ref=johnsmith. The cookie doesn't show if I go to that url page. But it does show up once I reload the page. So I'm wondering if it's possible to show the cookie the first time around, instead of reloading the page? Here is my code. // This is in the header $url_ref_name = (!empty($_GET['ref']) ? $_GET['ref'] : null); if(!empty($url_ref_name)) { $number_of_days = 365; $date_of_expiry = time() + 60 * 60 * 24 * $number_of_days; setcookie( "ref", $url_ref_name, $date_of_expiry,"/"); } else if(empty($url_ref_name)) { if(isset($_COOKIE['ref'])) { $user_cookie = $_COOKIE['ref']; } } else {} // This is for the sign up form if(isset($_COOKIE['ref'])) { $user_cookie = $_COOKIE['ref']; ?> <fieldset> <label>Referred By</label> <div id="ref-one"><span><?php if(!empty($user_cookie)){echo $user_cookie;} ?></span></div> <input type="hidden" name="ref" value="<?php if(!empty($user_cookie)){echo $user_cookie;} ?>" maxlength="20" placeholder="Referrer's username" readonly onfocus="this.removeAttribute('readonly');" /> </fieldset> <?php }
I am displaying rows from a database onto a page using: while($row=mysql_fetch_array($query)){ echo $row['name']; } I need to figure out how to limit the rows shown to the page to 100. And if there are 100 rows on the page, a link will be displayed at the bottom, that says "Next 100". Then this will display the next 100 rows. Can you give an example how to do this please? Thanks Hi, I would like to do the following but not sure how. If the you/user is on index.php of http://www.domain.com/ show one page If not show another How would I do this? Thanks Hi , I know my code sucks but i'm learning fast!! I'm trying to show a form if the qty value in a database == 10 or a different form if the value ==20. I tried but failed. Any help really appreciated. Code: [Select] <?php require_once('Connections/book.php'); ?> <?php $colname_cardpayment = "-1"; if (isset($_GET['orderid'])) { $colname_cardpayment = (get_magic_quotes_gpc()) ? $_GET['orderid'] : addslashes($_GET['orderid']); } mysql_select_db($database_book, $book); $query_cardpayment = sprintf("SELECT * FROM cards WHERE orderid = '%s' ORDER BY qty ASC", $colname_cardpayment); $cardpayment = mysql_query($query_cardpayment, $book) or die(mysql_error()); $row_cardpayment = mysql_fetch_assoc($cardpayment); $totalRows_cardpayment = mysql_num_rows($cardpayment); // Database connect $con = mysql_connect("mysql1.myhost.ie","admin_book","root123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("book_test", $con); //Parse Values from Coupon.php Form $orderid = mysql_real_escape_string(trim($_POST['orderid'])); $name = mysql_real_escape_string(trim($_POST['name'])); $surname = mysql_real_escape_string(trim($_POST['surname'])); $add1 = mysql_real_escape_string(trim($_POST['add1'])); $add2 = mysql_real_escape_string(trim($_POST['add2'])); $town = mysql_real_escape_string(trim($_POST['town'])); $county = mysql_real_escape_string(trim($_POST['county'])); $postcode = mysql_real_escape_string(trim($_POST['postcode'])); $phone = mysql_real_escape_string(trim($_POST['phone'])); $email = mysql_real_escape_string(trim($_POST['email'])); $letterstyle = mysql_real_escape_string(trim($_POST['letterstyle'])); $sql="INSERT INTO custdetails (orderid, name, surname, add1, add2, town, county, postcode, phone, email, letterstyle) VALUES ('$orderid','$name','$surname','$add1','$add2','$town','$county','$postcode','phone','$email','$letterstyle')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Digital Scribe Books</title> <link href="style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> </head> <body onload="MM_preloadImages('images/buttons/home_over.png','images/buttons/books_over.png','images/buttons/cards_over.png','images/buttons/letters_over.png')"> <div id="snow"> <div id="wrapper"> <div id="header"> <div id="logo"><img src="images/digital_scripe.png" width="218" height="91" /></div> <div id="menu"><a href="index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Home','','images/buttons/home_over.png',1)"><img src="images/buttons/home_act.png" name="Home" width="131" height="132" border="0" id="Home" /></a><a href="books.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Books','','images/buttons/books_over.png',1)"><img src="images/buttons/books_act.png" name="Books" width="131" height="132" border="0" id="Books" /></a><a href="cards.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Cards','','images/buttons/cards_over.png',1)"><img src="images/buttons/cards_act.png" name="Cards" width="131" height="132" border="0" id="Cards" /></a><a href="letters.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Letters','','images/buttons/letters_over.png',1)"><img src="images/buttons/letters_act.png" name="Letters" width="131" height="132" border="0" id="Letters" /></a></div> </div> <div id="content"> <?php echo 'Order ID is : '. $orderid . '.<br />'; if ($row2['qty'] == 10) echo "<div> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="accounts@agraphics.ie"> <input type="hidden" name="lc" value="IE"> <input type="hidden" name="item_name" value="10 Christmas Cards"> <input type="hidden" name="item_number" value="<? echo $orderid; ?>"> <input type="hidden" name="amount" value="12.99"> <input type="hidden" name="currency_code" value="EUR"> <input type="hidden" name="button_subtype" value="services"> <input type="hidden" name="shipping" value="2.99"> <input type="hidden" name="return" value="http://www.digitalscribe/thanks.php"> <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> </div>"; if ($row2['qty'] == 20) echo "<div> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="accounts@agraphics.ie"> <input type="hidden" name="lc" value="IE"> <input type="hidden" name="item_name" value="20 Christmas Cards"> <input type="hidden" name="item_number" value="<? echo $orderid; ?>"> <input type="hidden" name="amount" value="21.99"> <input type="hidden" name="currency_code" value="EUR"> <input type="hidden" name="button_subtype" value="services"> <input type="hidden" name="shipping" value="2.99"> <input type="hidden" name="return" value="http://www.digitalscribe/thanks.php"> <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> </div>"; ?> </div> <div id="footer" class="clear"><div id="sign"><div id="sign_text">Personalised<br /> Books</div> </div></div> </div></div> </body> </html> <?php mysql_free_result($cardpayment); ?> I am trying to allow the user to update a variable he chooses by radio buttons, which they will then input text into a box, and submit, to change some attributes. I really need some help here. It works just fine until I add the second layer of variables on top of it, and I can't find the answer to this question anywhere. <?PHP require('connect.php'); ?> <form action ='' method='post'> <select name="id"> <?php $extract = mysql_query("SELECT * FROM cars"); while($row=mysql_fetch_assoc($extract)){ $id = $row['id']; $make= $row['make']; $model= $row['model']; $year= $row['year']; $color= $row['color']; echo "<option value=$id>$color $year $make $model</option> ";}?> </select> Which attribute would you like to change?<br /> <input type="radio" name="getchanged" value="make"/>Make<br /> <input type="radio" name="getchanged" value="model"/>Model<br /> <input type="radio" name="getchanged" value="year" />Year<br /> <input type="radio" name="getchanged" value="color" />Color<br /><br /> <br /><input type='text' value='' name='tochange'> <input type='submit' value='Change' name='submit'> </form> //This is where I need help... <?PHP if(isset($_POST['submit'])&&($_POST['tochange'])){ mysql_query(" UPDATE cars SET '$_POST[getchanged]'='$_POST[tochange]' where id = '$_POST[id]' ");}?> Hello all. I am very new to PHP, and I am not sure where to look or what I'm looking for in my current assignment. My task is to take in two numbers between 0-100. Once I take in that number, it should state beside it "The __ was accepted." The program should not accept any numbers greater than 100 or any characters. Once I do this, I must take a second number and do a similar thing. Finally, I must have a statement show up at the bottom stating which number is greater. Essentially, I need help in determining what I should use to place parameters, and how I can keep the program from echo ing any statement until input has been taken and tested for parameters. Any help you can provide will be greatly appreciated! I have just re-installed Xampp and suddenly my sites are now displaying lots of: Notice: Use of undefined constant name - assumed 'name' in ... Notice: Use of undefined constant price - assumed 'price' in ... this is an example of the line its refering too: $defineProducts[1001] = array(name=>'This is a product', price=>123); My login script stores the user's login name as $_SESSION[ 'name'] on login. For some unapparent reason, i'm getting errors stating that $user and $priv are undefined variables, though I've attempted to define $user as being equal to $_SESSION['name'], using $user to look up the the user's privilege level (stored as the su column ) in the SQL table, and then where the result of the sql query is $priv which is then evaluated in an if statement. I can't seem to figure out why this might not be working. The code I'm using: <?php session_start(); function verify() { //verify that the user is logged in via the login page. Session_start has already been called. if (!isset($_SESSION['loggedin'])) { header('Location: /index.html'); exit; } //if user is logged in, we then lookup necessary privleges. $_SESSION['name'] was written with the login name upon login. Privleges // are written in db as a single-digit integer of of 0 for users, 1 for administrators, and 2 for special users. $user === $_SESSION['name']; //Connect to Databse $link = mysqli_connect("127.0.0.1", "database user", "password", "database"); if (!$link) { echo "Error: Unable to connect to MySQL." . PHP_EOL; echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL; echo "Debugging error: " . mysqli_connect_error() . PHP_EOL; exit; } //SQL Statement to lookup privlege information. if ($result = mysqli_query($link, "SELECT su FROM accounts WHERE username = $user", MYSQLI_STORE_RESULT)) { //LOOP TO CYCLE THROUGH SQL RESULTS AND STORE Privlege information as vairable $priv. while ($row = $result->fetch_assoc()) { $priv === $row["su"]; } } // close SQL connection. mysqli_close($link); // Verify privleges and take action. Only a privlege of "1" is allowed to view this page. A privlege of "2" indicates special //accounts used in other scripts that have certain indermediate additional functions, but are not trusted administrators. if ($priv !== 1) { echo $_SESSION['name']; echo "you have privlege level of $priv"; echo "<br>"; echo 'Your account does not have the privleges necessary to view this page'; exit; } } verify(); ?>
Hello everyone, I can get Test 2 to successfully operate the if statement using a variable variable. But when I try the same method using a session variable (Test 1) the if statement is not executed. Please could you tell me why the if statement in Test 1 is not being executed? Code: [Select] <?php # TEST 1 $_SESSION[test_variable] = "abcd"; $session_variable_name = "_SESSION[test_variable]"; if ($$session_variable_name == "abcd") { echo "<br>line 373, abcd<br>"; } # TEST 2 $test_variable = "efgh"; $test_variable_name = "test_variable"; if ($$test_variable_name == "efgh") { echo "<br>line 379, efgh<br>"; } ?> Many thanks, Stu |