PHP - Conditional Display Issue
Hello, this is my first PHP project, and I am having issues getting it to correctly display an error ONLY if the input is an error
It displays the error upon first load of the page w/o pressing submit. How would I use Code: [Select] isset($_POST['submit'])to fix it? Code: [Select] <?php $inputid = $_POST['steamid']; $steam_prefix = substr($inputid, 0, 10); $prefix_length = 10; $char_total = strlen($inputid); $steam_suffixchars = ($char_total - $prefix_length); $suffix_check = substr($inputid, 10, $steam_suffixchars); $class_set = "notranslate"; $is_submit = isset($_POST['submit']); if(is_numeric($suffix_check) == true) $suffix_valid = true; elseif(is_int($suffix_check) == false) $suffix_valid = false; if($char_total > 25 || $char_total < 11) $char_valid = false; else $char_valid = true; if($steam_prefix === "STEAM_0:1:" || $steam_prefix === "STEAM_0:0:") $prefix_check = true; elseif($steam_prefix != "STEAM_0:1:" || $steam_prefix != "STEAM_0:0:") $prefix_check = false; if (preg_match('/^[A-Z0-9-:-_-]+$/', $inputid)) $chars_matched = true; else $chars_matched = false; if($suffix_check == true && $prefix_check == true && $char_valid == true && $chars_matched == true) echo "Approved!"; elseif(isset($_POST['anon'])) echo "Approved!"; else echo "error!"; ?> Similar TutorialsHi,
I have a website that is 80% done when my programmer dropped the ball. I am trying to get it all to work, but have only rudimentary knowledge on what I am doing thus far and need a bit of help, please.
I have a couple of popups links that writes a reminder to check the size of necks and arms at the top of certain pages.
One of my product groups is called Collars and Armbands
which consists of 1 x category "Collars and Armbands" whic has 2 x Subcategories which are "Collars" and "Armbands" if I click on the "Collars and Armbands" tab, it displays all the contents of both subcategories Collars and Armbands, as expected. It displays the popup links for both subcategories. I don't want the popups to appear on the "Collars and Armbands" page but only on the individual "Collars" or "Armbands" pages if I click on Collars or Armbands subcategory tabs it displays the single popup link for that category. (which is what I want it to do) The problem lies in the category and subcategory names which I can't really change without making it non-logical for the customer. this the code that makes is happen if ( substr_count($sectionname,'Collars')>0 || substr_count($productname,'Collar')>0 ) { echo '<p class="measurelink noprint">Remember to <a href="neckmeasurepop.php" class="lnkpopup sllink" title="click for popup measuring instructions" onclick="slf_popupwin();return false;">Measure Your Collar Size !</a></p>'; } My question is, is there a way to set a condition that I can use for this code that says "if the $sectionname = "Collars" but NOT "Collars and Armbands" and $productname = "Collar" then display the popup link "neckmeasurepop.php". I had considered renaming the base category to something else, but that would just make things confusing for the customers. Cheers and thanks in advance Hi, I've been playing around with inserting the name of a file ($additional_upload_nameX) into the database only if it has been uploaded (it's not mandatory). When I submit the form, I'm told I have a problem with my WHERE clause. Any idea what I'm doing wrong here? Code: [Select] $query2 = "INSERT INTO uploads (date, upload_name, topic, year, status, keywords, description )" . "VALUES (NOW(), '$additional_upload_nameX', '$topic', '$year', '$status', '$keywords' , '$description') WHERE $additional_upload_nameX != ''"; //if($query){echo 'data has been placed'} mysql_query($query2) or die(mysql_error()); I have a database with one row and about 50 columns, where the inserted data is being displayed on a page. But a lot of the time not all columns are being used. So say only 25 columns have data, there will be 25 blanks spaces with an • symbol. Is there a way to ignore to columns that have no data in them? Such as SELECT * from notices WHERE [columns have data] Code: [Select] <?php $html="<table>"; $q="select * from notices"; $r=mysql_query($q); while($o=mysql_fetch_object($r)){ foreach($o as $key=>$val){ $html.="<tr><td colspan='2' bgcolor='#896B45'><div style='padding:10px;'>&#8226; {$val}<br></div></td></tr>"; }} $html.="</table>"; echo $html; ?> CREATE TABLE `notices` ( `id` int(11) NOT NULL auto_increment, `notice1` text, `notice2` text, `notice3` text, `notice4` text, `notice5` text, `notice6` text, `notice7` text, `notice8` text, `notice9` text, `notice10` text, `notice11` text, `notice12` text, `notice13` text, `notice14` text, `notice15` text, `notice16` text, `notice17` text, `notice18` text, `notice19` text, `notice20` text, `notice21` text, `notice22` text, `notice23` text, `notice24` text, `notice25` text, `notice26` text, `notice27` text, `notice28` text, `notice29` text, `notice30` text, `notice31` text, `notice32` text, `notice33` text, `notice34` text, `notice35` text, `notice36` text, `notice37` text, `notice38` text, `notice39` text, `notice40` text, `notice41` text, `notice42` text, `notice43` text, `notice44` text, `notice45` text, `notice46` text, `notice47` text, `notice48` text, `notice49` text, `notice50` text, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=40 DEFAULT CHARSET=utf8 I have an admin page for the posting of the date to the database: Code: [Select] <?php include_once($_SERVER["DOCUMENT_ROOT"] . "/main.inc.php"); $page_content = db_select("select * from notices"); $pc = $page_content[0]; $ff=$_POST; if ($ff['submit']) { $insc="UPDATE notices SET notice1='".$ff['notice1']."' , notice2='".$ff['notice2']."' , notice3='".$ff['notice3']."' , notice4='".$ff['notice4']."' , notice5='".$ff['notice5']."' , notice6='".$ff['notice6']."' , notice7='".$ff['notice7']."' , notice8='".$ff['notice8']."' , notice9='".$ff['notice9']."' , notice10='".$ff['notice10']."' , notice11='".$ff['notice11']."' , notice12='".$ff['notice12']."' , notice13='".$ff['notice13']."' , notice14='".$ff['notice14']."' , notice15='".$ff['notice15']."' , notice16='".$ff['notice16']."' , notice17='".$ff['notice17']."' , notice18='".$ff['notice18']."' , notice19='".$ff['notice19']."' , notice20='".$ff['notice20']."' , notice21='".$ff['notice21']."' , notice22='".$ff['notice22']."' , notice23='".$ff['notice23']."' , notice24='".$ff['notice24']."' , notice25='".$ff['notice25']."' , notice26='".$ff['notice26']."' , notice27='".$ff['notice27']."' , notice28='".$ff['notice28']."' , notice29='".$ff['notice29']."' , notice30='".$ff['notice30']."' , notice31='".$ff['notice31']."' , notice32='".$ff['notice32']."' , notice33='".$ff['notice33']."' , notice34='".$ff['notice34']."' , notice35='".$ff['notice35']."' , notice36='".$ff['notice36']."' , notice37='".$ff['notice37']."' , notice38='".$ff['notice38']."' , notice39='".$ff['notice39']."' , notice40='".$ff['notice40']."' , notice41='".$ff['notice41']."' , notice42='".$ff['notice42']."' , notice43='".$ff['notice43']."' , notice44='".$ff['notice44']."' , notice45='".$ff['notice45']."' , notice46='".$ff['notice46']."' , notice47='".$ff['notice47']."' , notice48='".$ff['notice48']."' , notice49='".$ff['notice49']."' , notice50='".$ff['notice50']."' , id='1' WHERE id='1'"; mysql_query($insc); } ?> <html> <head> </head> <body> <form name="noticesform" method="post" action="notices_admin.php" enctype="multipart/form-data"> <textarea name='notice1' cols='110' rows='3' class='input'><?=$pc["notice1"]?> </textarea> <textarea name='notice2' cols='110' rows='3' class='input'><?=$pc["notice2"]?> </textarea> <textarea name='notice3' cols='110' rows='3' class='input'><?=$pc["notice3"]?> </textarea> <textarea name='notice4' cols='110' rows='3' class='input'><?=$pc["notice4"]?> </textarea> <textarea name='notice5' cols='110' rows='3' class='input'><?=$pc["notice5"]?> </textarea> <textarea name='notice6' cols='110' rows='3' class='input'><?=$pc["notice6"]?> </textarea> <textarea name='notice7' cols='110' rows='3' class='input'><?=$pc["notice7"]?> </textarea> <textarea name='notice8' cols='110' rows='3' class='input'><?=$pc["notice8"]?> </textarea> <textarea name='notice9' cols='110' rows='3' class='input'><?=$pc["notice9"]?> </textarea> <textarea name='notice10' cols='110' rows='3' class='input'><?=$pc["notice10"]?> </textarea> <textarea name='notice11' cols='110' rows='3' class='input'><?=$pc["notice11"]?> </textarea> <textarea name='notice12' cols='110' rows='3' class='input'><?=$pc["notice12"]?> </textarea> <textarea name='notice13' cols='110' rows='3' class='input'><?=$pc["notice13"]?> </textarea> <textarea name='notice14' cols='110' rows='3' class='input'><?=$pc["notice14"]?> </textarea> <textarea name='notice15' cols='110' rows='3' class='input'><?=$pc["notice15"]?> </textarea> <textarea name='notice16' cols='110' rows='3' class='input'><?=$pc["notice16"]?> </textarea> <textarea name='notice17' cols='110' rows='3' class='input'><?=$pc["notice17"]?> </textarea> <textarea name='notice18' cols='110' rows='3' class='input'><?=$pc["notice18"]?> </textarea> <textarea name='notice19' cols='110' rows='3' class='input'><?=$pc["notice19"]?> </textarea> <textarea name='notice20' cols='110' rows='3' class='input'><?=$pc["notice20"]?> </textarea> <textarea name='notice21' cols='110' rows='3' class='input'><?=$pc["notice21"]?> </textarea> <textarea name='notice22' cols='110' rows='3' class='input'><?=$pc["notice22"]?> </textarea> <textarea name='notice23' cols='110' rows='3' class='input'><?=$pc["notice23"]?> </textarea> <textarea name='notice24' cols='110' rows='3' class='input'><?=$pc["notice24"]?> </textarea> <textarea name='notice25' cols='110' rows='3' class='input'><?=$pc["notice25"]?> </textarea> <textarea name='notice26' cols='110' rows='3' class='input'><?=$pc["notice26"]?> </textarea> <textarea name='notice27' cols='110' rows='3' class='input'><?=$pc["notice27"]?> </textarea> <textarea name='notice28' cols='110' rows='3' class='input'><?=$pc["notice28"]?> </textarea> <textarea name='notice29' cols='110' rows='3' class='input'><?=$pc["notice29"]?> </textarea> <textarea name='notice30' cols='110' rows='3' class='input'><?=$pc["notice30"]?> </textarea> <textarea name='notice31' cols='110' rows='3' class='input'><?=$pc["notice31"]?> </textarea> <textarea name='notice32' cols='110' rows='3' class='input'><?=$pc["notice32"]?> </textarea> <textarea name='notice33' cols='110' rows='3' class='input'><?=$pc["notice33"]?> </textarea> <textarea name='notice34' cols='110' rows='3' class='input'><?=$pc["notice34"]?> </textarea> <textarea name='notice35' cols='110' rows='3' class='input'><?=$pc["notice35"]?> </textarea> <textarea name='notice36' cols='110' rows='3' class='input'><?=$pc["notice36"]?> </textarea> <textarea name='notice37' cols='110' rows='3' class='input'><?=$pc["notice37"]?> </textarea> <textarea name='notice38' cols='110' rows='3' class='input'><?=$pc["notice38"]?> </textarea> <textarea name='notice39' cols='110' rows='3' class='input'><?=$pc["notice39"]?> </textarea> <textarea name='notice40' cols='110' rows='3' class='input'><?=$pc["notice40"]?> </textarea> <textarea name='notice41' cols='110' rows='3' class='input'><?=$pc["notice41"]?> </textarea> <textarea name='notice42' cols='110' rows='3' class='input'><?=$pc["notice42"]?> </textarea> <textarea name='notice43' cols='110' rows='3' class='input'><?=$pc["notice43"]?> </textarea> <textarea name='notice44' cols='110' rows='3' class='input'><?=$pc["notice44"]?> </textarea> <textarea name='notice45' cols='110' rows='3' class='input'><?=$pc["notice45"]?> </textarea> <textarea name='notice46' cols='110' rows='3' class='input'><?=$pc["notice46"]?> </textarea> <textarea name='notice47' cols='110' rows='3' class='input'><?=$pc["notice47"]?> </textarea> <textarea name='notice48' cols='110' rows='3' class='input'><?=$pc["notice48"]?> </textarea> <textarea name='notice49' cols='110' rows='3' class='input'><?=$pc["notice49"]?> </textarea> <textarea name='notice50' cols='110' rows='3' class='input'><?=$pc["notice50"]?> </textarea> <input type="submit" name="submit" value="Click here to update" class="input"> </form> </body> </html> Hi... I encountered problem in my query and while loop my data was duplicates when I join 2 tables, because the one field that I need to display is from another table. here is my code: Code: [Select] <div> <table> <thead> <th>Items</th> <th>Sub Items</th> <th>Item Code</th> <th>Demanded Qty</th> <th>UoM</th> <th>Class</th> <th>Description</th> <th>BIN Location</th> </thead> <?php $sql = "SELECT Items FROM bom_items ORDER BY Items"; $res_bom = mysql_query($sql, $con); while($row = mysql_fetch_assoc($res_bom)){ echo "<tr> <td style='border: none;font-weight: bold;'> $row[Items]</td> </tr>"; //$sql = "SELECT SubItems, ItemCode, UoM, Class, Description FROM bom_subitems WHERE Items = '$row[Items]' ORDER BY Items"or die(mysql_error()); //$sql = "SELECT DISTINCT bs.SubItems, bs.ItemCode, bs.UoM, bs.Class, bs.Description,w.BINLocation FROM bom_subitems bs LEFT JOIN wms w ON bs.Items = w.Items WHERE bs.Items = '$row[Items]' AND w.Items = '$row[Items]' ORDER BY bs.Items, w.Items"or die(mysql_error()); $sql = "SELECT DISTINCT bs.SubItems, bs.ItemCode, bs.UoM, bs.Class, bs.Description,w.BINLocation FROM bom_subitems bs, wms w WHERE bs.Items = '$row[Items]' AND w.Items = '$row[Items]' ORDER BY bs.Items, w.Items"or die(mysql_error()); $res_sub = mysql_query($sql, $con); while($row_sub = mysql_fetch_assoc($res_sub)){ echo "<tr> <td style='border: none;'> </td> <td style='border: none;'> $row_sub[SubItems]</td> <td style='border: none;'> $row_sub[ItemCode]</td> <td> </td> <td style='border: none;' size='3'> $row_sub[UoM]</td> <td style='border: none;'> $row_sub[Class]</td> <td style='border: none;'> $row_sub[Description]</td> <td style='border: none;'> $row_sub[BINLocation]</td> </tr>"; } } ?> I will attach my sample page. Thank you i have a code that generates a random code and displays it as an image. But the problem the image can be displayed only if it is called before any other output. How do i run it so that it can be displayed after any output.. Code: [Select] <? //Security Word for the form $codelenght = 10; while($newcode_length < $codelenght) { $x=1; $y=3; $part = rand($x,$y); if($part==1){$a=48;$b=57;} // Numbers if($part==2){$a=65;$b=90;} // UpperCase if($part==3){$a=97;$b=122;} // LowerCase $code_part=chr(rand($a,$b)); $newcode_length = $newcode_length + 1; $newcode = $newcode.$code_part; } header('Content-Type: image/png'); $im = imagecreatetruecolor(200, 40); $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $blue = imagecolorallocate($im, 0, 0, 238); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 1, 1, 200, 40, $white); $font = '/home/vhosts/master_files/advertising/fonts/arialbd.ttf'; imagettftext($im, 12, 0, 10, 18, $blue, $font, $newcode); imagepng($im); imagedestroy($im); ?> Hi, I am having an issue with displaying an image that is uploaded in a mysql database. The table format is ----------------------------------------------------------- | id | name | mime | size | data | ----------------------------------------------------------- | 1 | test | image/jpeg| 74857 | BLOB | The data has uploaded fine. I then have the following script on my 'displayimage.php?imgid=1' page... Code: [Select] $id = $_GET['imgid']; $result = mysql_query("SELECT * FROM images WHERE id = '$id'"); while($row = mysql_fetch_array($result)) $size = $row['size']; $mime = $row['mime']; $name = $row['name']; { header("Content-length: $size"); header("Content-type: $mime"); header("Content-Disposition: attachment; filename=$name"); echo $row['data']; However everytime i try to open this page, Firefox or Internet Explorer just ask's me to try and download the file as a php file. Any ideas what is going wrong? Thanks! Matt Hi guys its me again, I am having a problem that I cant figure out... Here is my code: <?php $sqlCommand = "SELECT image FROM background"; $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); $sqlCommand2 = "SELECT backgroundimage FROM site"; $query2 = mysqli_query($myConnection, $sqlCommand2) or die (mysqli_error()); while ($row = mysqli_fetch_array($query)) { while ($row2 = mysqli_fetch_array($query2)) { if($row['image'] == $row2['backgroundimage']){ echo '<img src="site_background/'.$row['image'].'" width="75px" height="75px" style="border:2px solid red;" /><br /><br />'; } if($row['image'] != $row2['backgroundimage']){ echo '<img src="site_background/'.$row['image'].'" width="50px" height="50px" style="border:2px solid black;" />'; } } } mysqli_free_result($query); mysqli_free_result($query2); ?> What is will do is get the images from the "backgrounds" table and the image from the "site" table (the current image). I am then wanting to pick out the current image and give it a red border and then display the other left over images smaller with a black border. I can get the images to all display with the black border or the current image to display with a red border but the other images dont show... I have tried mixing things around but I have not been able to get all the images to display with the formatting I want. I dont know if it is a simple syntax error or I am doing things completely wrong... I have been looking at it for so long its just become one big mess of code to me lol Any help to get this working as I want would be great! Cheers Ben i wanna put condition that if ($signupbonus > 0.00) then following should not be executed <font size="3" color="red"><b>Referral bonus: <font color="green" size="4">$<? echo $signupbonus; ?></font></b></font><br><br> please help Hi, I've written a conditional statement to give my body tag a unique ID, depending on three conditions. (body id="red" etc..) The statement does indeed work when tested, but dreamweaver is highlighting the conditional in yellow - So I'm wondering if there is an alternate (and perhaps cleaner) way of writing the following.. It's for a joomla site btw.. (I've spread the code out a little here, so it's easier for you guys to see what I'm doing) Code: [Select] <body <?php if($this->countModules('headerlow')) : ?> id="up" <?php endif; ?> <?php if (JRequest::getVar('Itemid')==104) { ?> id="red" <? } else {?> id="low" <? } ?> > I have a problem when trying to query the table closed_mbl. I want to return the COUNT of all records that contain the locations below while excluding all these records that contain anything else besides AIR. How would I do this? Right now it returns the count of everything from all these locations. The field "method" is ignored. SELECT COUNT(*) FROM closed_mbl WHERE location = 'ALL' OR location = 'AUCKLAND' OR location = 'BRAZIL' OR location = 'DALIAN' OR location = 'EXPORT' OR location = 'GALWAY' OR location = 'ISUNICOV' OR location = 'KOLIN' OR location = 'SGALWAY' OR location = 'SHANNON' OR location = 'SOMI' OR location = 'SUZHOU' OR location = 'UNICOV' OR location = 'WUJIANG' OR location = 'WUJIANGCC' AND method = 'AIR' Hello.
I have a sports league and the captain's page has a menu bar allowing links to sub pages. I would like to only add the URL part if a condition is met. In my database I have a league field called "session" for Spring or Summer sessions.
The menu bar has 5 simple columns for hyperlinks:
Home | Edit Team | Add Player | Edit My Information | Log Out |
What I would like to do is to only display say the "Edit Team" with hyperlink if the league session = "Summer" (that was Spring teams cannot edit their information at this point in time). I am trying to create an IF-Else statement, but can't quite get it right. I am a novice PHP coder, so I could really use some help. Here is the current code for this short section:
<table width="800" border="0" cellpadding="0" cellspacing="0"> <tr> <td><img src="images/BBV_CP_top.jpg" width="800" height="200"></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td width="6%" class="menu"><a href="home.php"> Home</a> </td> <td width="9%" class="menu">Edit Team </a></td> <td width="12%" class="menu">Add Player</td> <td width="63%" class="menu">Edit My Information</a> </td> <td width="10%" class="menu"><a href="logout.php">Log Out </a></td> </tr> </table>How can I create "Edit Team" to be a hyperlink ONLY IF the condition (league = Summer) is TRUE? $team is the query that returns the league results from the MSSQL query. Thanks in advance for your help. I have the following code which seems to be in error in the conditional statement. The queries to the database produce the expected results, and the echo statements work OK. I want to make a selection based on whether data exists in the database for passState when passState=1. Can anyone tell me what is wrong with the conditional statement? Code: [Select] <?php $query1 = mysql_query("SELECT DISTINCT quizTitle, userId, passState, userScore, totalScore, DATE_FORMAT(userDate,'%b %e, %Y') AS userDate FROM quiz WHERE managerId = '$managerId' AND userId = '$userId' AND passState = 1 ORDER BY quizTitle ASC, passState DESC, userDate DESC "); $query2 = mysql_query("SELECT DISTINCT quizTitle, userId, passState, userScore, totalScore, DATE_FORMAT(userDate,'%b %e, %Y') AS userDate FROM quiz WHERE managerId = '$managerId' AND userId = '$userId' AND passState = 0 ORDER BY quizTitle ASC, passState DESC, userDate DESC "); ?> <table width="778" style="font-size:16px"> <tr> <?php if ($query1) { while ($row1 = mysql_fetch_array($query1)) { echo'<td width="13"></td> <td width="137" style="vertical-align:middle; text-align:left;">' ?> <?php echo "{$row1['quizTitle']} <br />\n"; ?> <?php echo '</td> <td width="13"></td> <td width="132" style="vertical-align:middle; text-align:left;;">' ?> <?php echo "{$row1['userDate']} <br />\n"; ?> <?php echo '</td> <td width="22"></td> <td width="112" style="text-align:center; text-align:center;">' ?> <?php if ("{$row1['passState']}" == 1) {echo "<img src=' ../wood/wood_tool_images/tick2.png' /><br />\n";}?> <?php echo '</td> <td width="30"></td> <td width="103" style="text-align:center; text-align:center;">' ?> <?php if ("{$row1['passState']}" == 0) {echo "<img src=' ../wood/wood_tool_images/cross2.png' /><br />\n";} ?> <?php echo '</td> <td width="19"></td> <td width="126" style="vertical-align:middle; text-align:center;">' ?> <?php echo "{$row1['userScore']}".'/'."{$row1['totalScore']} <br />\n"; ?> <?php echo '</td> <td width="23"></td> </tr>'; } }else{ while ($row2 = mysql_fetch_array($query2)) { echo '<td width="13"></td> <td width="137" style="vertical-align:middle; text-align:left;">' ?> <?php echo "{$row2['quizTitle']} <br />\n"; ?> <?php echo '</td> <td width="13"></td> <td width="132" style="vertical-align:middle; text-align:left;;">' ?> <?php echo "{$row2['userDate']} <br />\n"; ?> <?php echo '</td> <td width="22"></td> <td width="112" style="text-align:center; text-align:center;">' ?> <?php if ("{$row2['passState']}" == 1) {echo "<img src=' ../wood/wood_tool_images/tick2.png' /><br />\n";}?> <?php echo '</td> <td width="30"></td> <td width="103" style="text-align:center; text-align:center;">' ?> <?php if ("{$row2['passState']}" == 0) {echo "<img src=' ../wood/wood_tool_images/cross2.png' /><br />\n";} ?> <?php echo '</td> <td width="19"></td> <td width="126" style="vertical-align:middle; text-align:center;">' ?> <?php echo "{$row2['userScore']}".'/'."{$row2['totalScore']} <br />\n"; ?> <?php echo '</td> <td width="23"></td> </tr>'; } } ?> </table> Hi, I asked a question about Tokens earlier. After debugging I've found the reason as to why my program isn't working. It's related to this statement: if($token == $_SESSION['token']) { ........; return true; }$token is generated in form using md5(uniqid()). When I echo both $token and $_SESSION['token'] before the if statement they both turn out to be the same. Yet for some reason the if statement is not being satisfied and is not returning true as it's supposed to do. (I've tried $token === $_SESSION['token'] as well.) I don't know if some kind of type casting or other is required for the conditional statement to work. Would be grateful for any suggestions. Edited by mac_gyver, 30 October 2014 - 10:53 PM. removed links from copied text I want to write a conditional statement like the following: if ($value = "300x") { however, I want this to work if x is changed to anything. So the conditional should work if the following is true: if ($value = "300dog") { or if ($value = "300cat") { How do I make it work as long as 300 is present regardless of what follows after. Thanks in advance! I am trying to identify the username from a series of windows logs. I have been using (?:User Name:|Account Name:)\s*([\S]+) and it works for examples 1-4, however I'm having problems with example 5. Because it has two occurrences of the pattern Account Name: in the string I can only get the regex to return the first match, i.e. USER-PC$. How can I tell regex, that if there are two Account Name: patterns in the string, or the string contains the pattern "New Logon:" then return the second Account Name: match, i.e. John.Doe? eg 1 - The screen saver was invoked. Subject: Security ID: S-X-X Account Name: John.Doe Account Domain: INTERNAL Logon ID: 0xa4091 Session ID: 1 eg 2 - User initiated logoff: Subject: Security ID: S-X-X Account Name: John.Doe Account Domain: INTERNAL Logon ID: 0x3d95c This event is generated when a logoff is initiated. No further user-initiated activity can occur. This event can be interpreted as a logoff event. eg 3 - User Logoff: User Name: John.Doe Domain: INTERNAL Logon ID: (0x0,0x458E4AB4) Logon Type: 8 eg 4 - Successful Network Logon: User Name: John.Doe Domain: INTERNAL Logon ID: (0x0,0x43) Logon Type: 8 Logon Process: Advapi Authentication Package: Negotiate Workstation Name: USER-PC Logon GUID: {2e483a4f-} Caller User Name: USER-PC $ Caller Domain: INTERNAL Caller Logon ID: (0x0,0x7) Caller Process ID: 4816 Transited Services: - Source Network Address: xx.xxx.xx.x Source Port: 35029 eg 5 - An account was successfully logged on. Subject: Security ID: S-X-X Account Name: USER-PC$ Account Domain: INTERNAL Logon ID: 0x3e7 Logon Type: 2 New Logon: Security ID: S-X-X Account Name: John.Doe Account Domain: INTERNAL Logon ID: 0xa4062 Logon GUID: {23-xx-22} Process Information: Process ID: 0x2fc Process Name: C:\Windows\System32\winlogon.exe Network Information: Workstation Name: USER-PC Source Network Address: xx.x.x.x Source Port: 0 Any help would be appreciated:) Hello, I am trying to have users select multiple options from a dropdown list. But before each selection, I would like to have a message appear on the screen asking if the user if they would like to select another option - Yes or No. Yes or No would be required fields. If the user select Yes, they can select another option from the drop down list (displaying all selected options on the screen before processing). If the user select No, they can proceed to the next fields. I have to searched the Internet for days, but was unable to locate anything close. If possible I would like to implement the amselect.js code into this difficult task. Can you guys please assist or point me in the right direction? I would like to have a script that would check certain parameters and if none of them returns TRUE, execute a set of codes. So the idea is somehow like if...else(). Code: [Select] <?php // trying to put if() directly within if() if ( // checking of variables if (!isset($transaction)) { echo '<font color="#FF0000">Type of transaction is not set.</font>'. '<br />'; } else { if ($transaction == 'sell') { if (empty($BV)) { echo '<font color="#FF0000">Book value is not set.</font>'. '<br />'; } } } if (empty($stock)) { echo '<font color="#FF0000">Stock symbol is not set.</font>'. '<br />'; } if (empty($price)) { echo '<font color="#FF0000">Price per share is not set.</font>'. '<br />'; } if (empty($volume)) { echo '<font color="#FF0000">Volume of shares is not set.</font>'. '<br />'; } ) { echo 'Go back and fill out necessary fields.'; } // if none of the above parameters returns TRUE else { echo 'Copy and paste the following in the email that you would be submitting.' </tr> <tr> <td> switch ($transaction) { case 'buy': include('calc_buy.php'); break; case 'sell': include('calc_sell.php'); break; default: echo '<font color="#FF0000"><b>If you see this message there is something wrong with your session. Please send us a feedback with the details of your session before seeing this message.</b></font>'; } } ?> This code returns an error and as I understand the error, it is because of if (if ()). How can I make it work? Thanks in advance! I have a membership directory that I've been working with for a long time, and recent server upgrades with MySQL, PHP, etc. forced me to do some recoding. While I was doing that, I wanted to try and make some improvements. I must give a brief description of the intent, and then the results I got, so someone can sort out the problem for me. I have a query that selects all "Agent" members, then orders them by County, then by Company Name. What I am trying to do is create a new heading in my list every time the County information changes as the list is sorted and output to my table.
I am going to attache 2 .php files with my code. The agent_member_list.php is the original code that pulls all of the members properly, and results can be viewed he http://www.nmlta.org...member_list.php
The agent2_member_list.php is where I'm trying to insert the new conditional statement to print my County headings when a new County is encountered in the results. The heading actually works, and changes correctly, but the problem is that the first member entry in every county is not printed in the output. I know the query is correct, so I'm sure I've got the conditional "if" for checking County field wrong, or misplaced. Here is the link to it: http://www.nmlta.org...member_list.php
I'm hoping someone can spot my error pretty quickly, I only dabble in this very rarely. Thanks for any help!
Attached Files
agent2_member_list.php 5.06KB
3 downloads
agent_member_list.php 4.82KB
2 downloads Hey, been banging my head against the wall for a couple of hours now. There is an If () in the code that is driving me crazy because it is not behaving like I expect it to.. foreach ( $types as $type ) { if ( !isset( $type->modclass ) or !isset( $type->typestr ) ) { debugging( 'Incorrect activity type in ' . $modname ); continue; } $var = (string)$type->type; if ( $var != 'assignment&type=online' ) { print '<br/>' . $var . '<br/>'; if ( $type->modclass == MOD_CLASS_RESOURCE ) { $resources[$type->type] = $type->typestr; } else { $activities[$type->type] = $type->typestr; } } } results in... Code: [Select] label resource&type=text resource&type=html resource&type=file resource&type=directory resource&type=ims assignment_group_start assignment&type=upload assignment&type=online assignment&type=uploadsingle assignment&type=offline assignment_group_end Notice the assignment&type=online in the output... I'm just about ready to give up as to why it is still outputting $var when it is clearly equal to the compared string? Any ideas? is it possible to have a script that changes header based on what page the user came from. something like Code: [Select] if ($_SERVER['HTTP_REFERER']) == http://www.site.com/pagebefore.php) { // do nothing, letting page generate } else { header("Location: back_to_the_start_buddy.php"); } |