PHP - Getting Error In The Php Code That Makes A Status Inactive For A News Posted
My issue
in my php page where i need to show all the news that have the status only active. in my mysql table i have 3 fiels news,posted date and expiry date. on page load i check the status of the news and displays only the active news.For that i am doing the following code,which gives me error. that is on page load, first i select all the news ,update the status inactive for the news which has crossed expiry time i check the status of the news and displays only the active news.For that i am doing the following code,which gives me error. $query1="select time(date_posted),time(expiry_time) from muh_title where status='Active'"; $res=mysql_query($query1); $row=mysql_fetch_row($res); $expiry_time=$row[0];$dateposted=$row[1]; $query11="select addtime(time(date_posted),time(expiry_time)) from muh_title"; $res11=mysql_query($query11); $row11=mysql_fetch_row($res11); $newtime=$row11[0]; $query2="SELECT TIMEDIFF(time(date_posted) ,time(NOW())) FROM muh_title"; $res2=mysql_query($query2); $row2=mysql_fetch_row($res2); $diff=$row2[0]; //while($newtime){ $query5="select *from muh_main_title where date_posted> date_sub(now(),interval (expiry_time) hour-minute )"; //$query3="update muh_title set status='Inactive' "; $res3=mysql_query($query5); } $q="select * from muh_title where status='Active' "; $r= mysql_query($q); $row= mysql_fetch_row($r); echo "<font size='6' color='white'><b><marquee direction='left' loop='-1' align='absmiddle' behaviour='scroll' scrolldelay='90'>$row[1]</marquee></b></font>"; ?> i am sure some where i have lost the flow of code. Similar TutorialsI'm using this web script that works successfully. It has a section where I can add a text box to appear upon a web user log-in. Instead, what I'd like to do is make the log-in box (form) disappear as soon as the user logs-in. Can you tell where(how) I can change this code to accomplish that? Thanks for any help. Code: [Select] <br/> <form action="login.php" method="post" accept-charset="UTF-8" class="middletext"> <label><font class="font4_15">Username</font></label><span class="username"><input type="text" name="user_name_login" size="9" style="width:70px;" /> <label><font class="font4_15">Password</font></label><span class="password"><input type="password" name="password_login" size="9" style="width:70px;" /> <input type="submit" value="[var.lang_login_now]" class="btn_vid1" /></a><!--<a href="login.php"></a>--> <input type="hidden" name="submitted" value="yes" /> <input type="hidden" name="remember_me" value="remember_me" /> </form> </td></tr></table> <!--Begin Text Box--> <!--<div id="txt-box">--> <table id="tabX44"> <tbody> <tr><td> <!--<div class="header-narrow">Text Box</div>--> <div class="txt-narrow"> </div> <!--<div class="container-narrow-bottom"></div>--> <!--[onload_337;block=div;when [var.show_login_box]!=1;comm]--> </td></tr> </tbody> </table> <!--</div>--> <!--End Text Box--> Hello there, I have a problem with this project I'm working on, everything is working fine except for one last thing. it goes as you go to the website, search for a city, choose a hotel from a list in that city, then book a room in that hotel, go to confirmation page then to paypal. everything is fine except after the booking when you go to the confirmation page, it shows correctly the number of nights you booked and everything, all except the rooms, it shows 0 rooms selected, and it doesn't give any price at all. here is the code Code: [Select] <?php include("db.class.php"); class hotelManager { public function getHotel($where) { $where = isset($_POST['where']) ? $_POST['where'] : ""; $dbObj = new DB(); $where = $_POST['where']; $sql = "select * from hotels where city_id IN (select id from cities where name = '$where') or country_id IN (select id from countries where name = '$where')"; $result = mysql_query($sql); $arr = array(); echo "<table>"; while($row = mysql_fetch_array($result) or die(mysql_error())) { echo "<tr>"; echo "<td valign=\"top\" width=\"120px\">"; $rowid = $row['id']; $imageqry=mysql_query("SELECT * FROM `hotelphotos` where hotel_id='$rowid'"); $image=mysql_fetch_array($imageqry); $imagename=$image['attachmentName']; echo "<img src=\"foxmaincms/webroot/files/small/$imagename\"/>"; echo "</td>"; echo "<td valign=\"top\">"; echo "<table> <tr> <td valign=\"top\"> <a href=\"hotels.php?id=".$row['id']."\" class=\"titleslink\">".$row['name']."</a> </td> </tr> <tr> <td class=\"text\" valign=\"top\"> ".$row['location']." </td> </tr> </table>"; echo "</td>"; echo "</tr>"; } echo "</table>"; //return $arr; // array of arrays } /*************************** GET ONE HOTEL *****************************/ public function getHotelbyID($hotelID) { $dbObj = new DB(); $result = mysql_query("select * from hotels where id = '$hotelID'"); return $result; } public function HotelDatatabel($result) { $row = @mysql_fetch_array($result); echo "<table width=98%>"; echo "<tr>"; echo "<td valign=\"top\" width=\"120px\">"; $rowid = $row['id']; $imageqry=mysql_query("SELECT * FROM `hotelphotos` where hotel_id='$rowid' LIMIT 1"); $image=mysql_fetch_array($imageqry); $imagename=$image['attachmentName']; echo "<img src=\"foxmaincms/webroot/files/small/$imagename\"/>"; echo "</td>"; echo "<td valign=\"top\">"; echo "<table> <tr> <td valign=\"top\" class=\"searchtitle\"> ".$row['name']." </td> </tr> <tr> <td class=\"text\" valign=\"top\"> ".$row['location']." </td> </tr> <tr> <td> ".$row['details']." </td> </tr> <tr> <td> <a href=\"http://".$row['website']."\" class=\"link\">".$row['website']."</a> </td> </tr> </table>"; echo "</td>"; echo "</tr>"; echo "</table>"; } /************************************ GET ROOMS **************************************/ public function getHotelRooms($hotelID) { $result = mysql_query("select * from rooms where hotel_id = '$hotelID'"); echo "<form name='bookingform' id='bookingform' method='post' action='book.php'>"; echo "<input name=\"roomid\" id=\"roomid\" type=\"hidden\" />"; echo "<input name=\"roomnum\" id=\"roomnum\" type=\"hidden\" />"; echo "<input name=\"hotelid\" id=\"hotelid\" type=\"hidden\" value=\"$hotelID\"/>"; echo "<table width=80% >"; echo"<tr>"; echo "<td>Check-in date</td>"; echo "<td>"; echo "<input type=\"text\" name=\"datein\" class=\"date_input\" />"; echo "</td>"; echo "<td>Check-out date</td>"; echo "<td>"; echo "<input type=\"text\" name=\"dateout\" class=\"date_input\" />"; echo "</td>"; echo"</tr>"; echo "<table>"; echo "<table class=\"rooms\" width=100% cellspacing=\"1\" >"; echo "<tr> <th class=\"rooms\">Room Type</th> <th class=\"rooms\">Rate for night</th> <th class=\"rooms\">MAX</th> <th class=\"rooms\">Nr.rooms</th> <th class=\"rooms\">Book</th> </tr>"; while($row = @mysql_fetch_array($result)) { echo "<tr>"; echo "<td class=\"text\" align=center>".$row['room_type']."</td>"; echo "<td class=\"text\" align=center>".$row['price_per_day']."</td>"; echo "<td class=\"text\" align=center>".$row['people']." People</td>"; echo "<td class=\"text\" align=center>"; ?> <select name="nrooms" id="nrooms" onchange=" //alert('<?php echo $row['id'] ; ?>'); //alert(this.value); var exist = 0; if(roomids.length > 0) { for(var hh = 0;hh < roomids.length; hh++) { if(roomids[hh] == <?php echo $row['id'] ; ?>) { exist = 1; //alert(hh); roomnumar[hh] = this.value; } } if(exist == 0) { roomids.push(<?php echo $row['id'] ; ?>); roomnumar.push(this.value); } } else { roomids.push(<?php echo $row['id'] ; ?>); roomnumar.push(this.value); } document.bookingform.roomid.value = roomids; document.bookingform.roomnum.value = roomnumar; "> <option value=0> 0 </option> <?php for($i = 0; $i < $row['available_rooms']; $i++) { $nr = $i+1; $pr=$nr * $row['price_per_day']; echo "<option value=$nr>$nr ($pr\$)</option>"; } echo "</select> </td>"; echo "<td align=center> </td>"; echo "</tr>"; echo "<tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr>"; } echo "<tr class=\"rooms\"> <td colspan=\"4\"> </td> <td align=center><input type=\"submit\" value=\"book\" id=\"bookroom\" name=\"bookroom\"/></td> </tr>"; echo "</table>"; echo "</form>"; print_r($_SESSION['order']); $_SESSION['order']=0; unset($_SESSION['order']); } } ?> BookinManager.php Code: [Select] <?php include("hotelsManager.php"); ?> <?php include("config.php"); ?> <?php include("textManager.php"); ?> <?php function echoPostedData() { $dbo = new DB(); $hotelObj = new hotelManager(); $hotelID = $_POST['hotelid']; $datein = $_POST['datein']; $dateout = $_POST['dateout']; $roomid = $_POST['roomid']; $pr = $_POST['pr']; $_SESSION['hotelID'] = isset($_POST['hotelid']) ? $_POST['hotelid'] : $_SESSION['hotelID']; $_SESSION['datein'] = isset($_POST['datein']) ? $_POST['datein'] : $_SESSION['datein']; $_SESSION['dateout'] = isset($_POST['dateout']) ? $_POST['dateout'] : $_SESSION['dateout']; $_SESSION['roomid'] = isset($_POST['roomid']) ? $_POST['roomid'] : $_SESSION['roomid']; $roomsarray = explode(",",$_POST['roomid']); $_SESSION['roomsarray'] = isset($_POST['roomid']) ? explode(",",$_POST['roomid']) : $_SESSION['roomsarray']; $roonsNo = $_POST['nrooms']; $_SESSION['nrooms'] = isset($_POST['roomnum']) ? explode(",",$_POST['roomnum']) : $_SESSION['nrooms']; /********************** hotels ************************/ /******************************************************/ echo "<table width=95% border=0 align=\"center\" cellpadding=\"0\" cellspacing=\"0\"> <tr><td valign=\"top\">"; echo "<table>"; echo "<tr>"; echo "<td valign=top>"; $imageqry=mysql_query("SELECT * FROM `hotelphotos` where hotel_id='".$_SESSION['hotelID']."' LIMIT 1"); $image=mysql_fetch_array($imageqry); $imagename=$image['attachmentName']; echo "<img src=\"foxmaincms/webroot/files/small/$imagename\"/>"; echo "</td>"; echo "<td>"; $result=$hotelObj->getHotelbyID($_SESSION['hotelID']); $row = mysql_fetch_array($result); echo "<table>"; echo "<tr><td valign=top><strong class=subtitle3>".$row['name']."</strong></td></tr>"; echo "<tr><td class=text valign=top>".$row['location']."</td></tr>"; echo "<tr><td class=text valign=top>check-in Date: ".$_SESSION['datein']."</td></tr>"; echo "<tr><td class=text valign=top>check-out Date: ".$_SESSION['dateout']."</td></tr>"; echo "<tr><td class=text valign=top>"; $newdate = $_SESSION['dateout'] - $_SESSION['datein']; $totalprice = array_sum($_SESSION['totalprice']) echo "</td></tr>"; echo "<tr><td class=text valign=top>Total Price: ".$totalprice."</td></tr>"; echo "</table>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</td></tr></table>"; } function echoForm2() { ?> <form id="userDetails" name="userDetails" action="" method="post"> <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td valign="top" class="subtitle3"><strong>Your Name</strong><br /> <input type="text" name="name" size="50" /></td> </tr> <tr> <td valign="top" class="subtitle3"><strong>Email address</strong><br /> <input type="text" name="email" size="50" /> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td valign="top" class="subtitle3"> <?php $roomsarray = explode(",",$_POST['roomid']); $roonsNo = explode(",",$_POST['roomnum']); for($i = 0;$i<count($roomsarray);$i++) { if($roonsNo[$i] > 1) { for($j = 0;$j<$roonsNo[$i];$j++) { echo "<div>"; $result = mysql_query("select * from rooms where id = '$roomsarray[$i]'"); $row = mysql_fetch_array($result); echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']." #".($j+1)."</span>"; echo "</div>"; echo "<table>"; echo "<tr>"; echo "<td>"; echo "<span class=subtitle3><strong> Full guest name </strong></span>"; echo "<br />"; echo "<input type=text name=\"guest_name[]\" size=30/>"; echo "</td>"; echo "<td align=center> <span class=subtitle3><strong> Max people</strong></span> <br /> <span class=subtitle3>".$row['people']."guests</span> </td>"; echo "<td align=center> <span class=subtitle3><strong>Smoking</strong></span><br /> <select name='smoking'> <option value=\"\">...</option> <option value=\"yes\">Yes</option> <option value=\"no\">No</option> </select> </td>"; echo "</tr>"; echo "</table>"; echo "<br />"; } } else { if($roonsNo[$i] != 0) { echo "<div>"; $result = mysql_query("select * from rooms where id = '$roomsarray[$i]'"); $row = mysql_fetch_array($result); echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']."</span>"; echo "</div>"; echo "<table>"; echo "<tr>"; echo "<td>"; echo "<span class=subtitle3><strong> Full guest name</strong></span>"; echo "<br />"; echo "<input type=text name=\"guest_name[]\" size=30/>"; echo "</td>"; echo "<td align=center> <span class=subtitle3><strong> Max people</strong></span> <br /> <span class=subtitle3>".$row['people']."guests</span> </td>"; echo "<td align=center> <span class=subtitle3><strong>Smoking</strong></span><br /> <select name='smoking'> <option value=\"\">...</option> <option value=\"yes\">Yes</option> <option value=\"no\">No</option> </select> </td>"; echo "</tr>"; echo "</table>"; echo "<br />"; } } } ?> <hr> </td> </tr> <tr> <td align="right"> <input type="submit" name="submit" id="submit" value="Make the reservation" /> </td> </tr> </table> </form> <?php } ?> Code: [Select] <?php include("includes/bookinManager.php"); ?> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="formtable"> <tr> <th align="left" valign="top" class="formtable"> Booking Data </th> </tr> <tr> <td valign="top"> </td> </tr> <tr> <td valign="top"> <?php echoPostedData(); ?> </td> </tr> <tr> <td valign="top"> </td> </tr> </table> </td> </tr> <tr> <td valign="top"><img src="images/spacer.gif" width="28" height="10" /></td> </tr> <tr> <td valign="top"> <?php if(isset($_POST['bookroom'])) {?> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="formtable"> <tr> <th align="left" valign="top" class="formtable"> Your Details </th> </tr> <tr> <td valign="top" > <form action="book.php" method="post" id="payPalForm"> <table width="60%" border="0" cellpadding="0" cellspacing="0" class="formtable"> <tr> <td>First name :</td> <td><input type="text" name="first_name" /></td> </tr> <tr> <td>Last name :</td> <td><input type="text" name="last_name" /></td> </tr> <tr> <td>Email address :</td> <td><input type="text" name="email" /></td> </tr> <tr> <td>Full guest name :</td> <td><input type="text" name="full" /></td> </tr> <tr> <td>Address :</td> <td><INPUT type="text" NAME="address1" VALUE=""/></td> </tr> <tr> <td>Special Requests :</td> <td><input type="text" name="special" /></td> </tr> </table> </td> </tr> <tr> <td valign="top"> <?php //echoForm2(); ?> <input type="hidden" name="item_number" value="<?php echo $row['id']; ?>"> <input type="hidden" name="cmd" value="_ext-enter"> <input type="hidden" name="redirect_cmd" value="_xclick"> <input type="hidden" name="business" value="tarek_1305896294_biz@gotharious.com"> <input type="hidden" name="item_name" value="Standard Room: Dar El Masyaf Hotel : 2 nights : 9th, july, 2011"> <input type="hidden" name="currency_code" value="USD"> <INPUT TYPE="hidden" NAME="first_name" VALUE="Tarek"> <INPUT TYPE="hidden" NAME="last_name" VALUE="Sabrouty"> <INPUT TYPE="hidden" NAME="address1" VALUE="9th Popastes St."> <INPUT TYPE="hidden" NAME="address2" VALUE="Cleopatra Hamamat"> <INPUT TYPE="hidden" NAME="city" VALUE="Alexandria"> <INPUT TYPE="hidden" NAME="Country" VALUE="Egypt"> <INPUT TYPE="hidden" NAME="lc" VALUE="US"> <INPUT TYPE="hidden" NAME="email" VALUE="tarek@gotharious.com"> <INPUT TYPE="hidden" NAME="night_phone_a" VALUE="+20166005733"> <INPUT TYPE="hidden" NAME="amount" VALUE="100.00"> <?php $roomsarray = explode(",",$_POST['roomid']); $roonsNo = explode(",",$_POST['roomnum']); for($i = 0;$i<count($roomsarray);$i++) { if($roonsNo[$i] > 1) { for($j = 0;$j<$roonsNo[$i];$j++) { echo "<div>"; $result = mysql_query("select * from rooms where id = '$roomsarray[$i]'"); $row = mysql_fetch_array($result); echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']." #".($j+1)."</span>"; echo "</div>"; echo "<table>"; echo "<tr>"; echo "<td>"; echo "<span class=subtitle3><strong> Full guest name </strong></span>"; echo "<br />"; echo "<input type=text name=\"guest_name[]\" size=30/>"; echo "</td>"; echo "<td align=center> <span class=subtitle3><strong> Max people</strong></span> <br /> <span class=subtitle3>".$row['people']."guests</span> </td>"; echo "<td align=center> <span class=subtitle3><strong>Smoking</strong></span><br /> <select name='smoking'> <option value=\"\">...</option> <option value=\"yes\">Yes</option> <option value=\"no\">No</option> </select> </td>"; echo "</tr>"; echo "</table>"; echo "<br />"; } } else { if($roonsNo[$i] != 0) { echo "<div>"; $result = mysql_query("select * from rooms where id = '$roomsarray[$i]'"); $row = mysql_fetch_array($result); echo "<span class=subtitle3><strong>Room: </strong>".$row['room_type']."</span>"; echo "</div>"; echo "<table>"; echo "<tr>"; echo "<td>"; echo "<span class=subtitle3><strong> Full guest name</strong></span>"; echo "<br />"; echo "<input type=text name=\"guest_name[]\" size=30/>"; echo "</td>"; echo "<td align=center> <span class=subtitle3><strong> Max people</strong></span> <br /> <span class=subtitle3>".$row['people']."guests</span> </td>"; echo "<td align=center> <span class=subtitle3><strong>Smoking</strong></span><br /> <select name='smoking'> <option value=\"\">...</option> <option value=\"yes\">Yes</option> <option value=\"no\">No</option> </select> </td>"; echo "</tr>"; echo "</table>"; echo "<br />"; } } } ?> <input type="submit" name="Submit" value="Submit"> </form> <tr> <td valign="top"> </td> </tr> </table> <?php } ?> Hello I recently got a "to many connection" error on my site, and want to know if anyone here knows a few codes that will show how many connection currently are in use (maybe even what files that creates them). I found I can use "Threads_connected" to show current open connections, but no info on how to write the code or where to pu the file. I hope you can show my what to do I have an AJAX request but my problem is that is always returns a status code of 0. Below I have my JavaScript function. They send a request to a page called inc_submit.php which just echo's "hi" (as I'm just try to test it). Code: [Select] function submitForm(website_name, website_caption, website_contact, website_email, website_link) { var url4 = "includes/inc_submit.php?website_name=" + escape(website_name) + "&website_caption=" + escape(website_caption) + "&website_contact=" + escape(website_contact) + "&website_email=" + escape(website_email) + "&website_link=" + escape(website_link); alert (url4); request4.open("GET", url4, true); request4.onreadystatechange = confirmSubmit; request4.send(null); } function confirmSubmit() { if (request4.readyState == 4) { if (request4.status == 200) { var response4 = request4.responseText; document.getElementById("submit_status").innerHTML = response4; } else { alert("Error: status code is " + request4.status); } } } I am working on a feed but am getting the nesting wrong, the </event> is appearing at the end of the whole feed and not at the end of the particular event. Here is a link to the feed http://www.horseeventsuk.com/events-feed-test.php and my code is Code: [Select] ?> <?php :'( $output_as_html=false; if ($output_as_html) echo '<html><head><title>Events Feed</title></head><body><h1>Events Feed</h1>'; $xml='<events>'; $sql="SELECT * FROM `events` WHERE event_status='live' ORDER BY event_created DESC LIMIT 3;"; $xml.='<event>'; $result=mysql_query($sql); if ($result) { while ($row=mysql_fetch_array($result)) { $event_id=$row['event_id']; $venue_id=$row['ven_id']; $county_id=FindVenueCountyId($venue_id); //print("Found event ".$event_id.'<br />'); $xml.=EchoRowItem($row,'title',$output_as_html); //$xml.=EchoRowItem($row,'description',$output_as_html,'event_details'); $xml.=EchoTag('contact_email','gilly@rackfield.co.uk',$output_as_html); $xml.=EchoTag('county',FindVenueCountyName($venue_id),$output_as_html); $xml.=EchoTag('postcode',FindVenuePostcode($venue_id),$output_as_html); $xml.=EchoTag('website_address',BuildEventURL($event_id,$county_id),$output_as_html); $xml.=EchoRowItem($row,'startdate',$output_as_html); $xml.=EchoTag('category','Animals, Convservation',$output_as_html); $xml.=EchoTag('category','Sport',$output_as_html); $xml.=EchoTag('category','Exhibitions, Shows',$output_as_html); } } $xml.='</event>'; $xml.='</events>'; if ($output_as_html) echo '</body></html>'; else { // serve the xml file header("Content-type: text/xml"); echo '<?xml version="1.0" encoding="UTF-8"?>'; echo $xml; } exit; Hello everyone, I have a script that shows the news posted on my website in a bigger format with comments ect... but it gives me the error Code: [Select] Parse error: syntax error, unexpected '}' in /home/stormgc/public_html/sources/news_view.php on line 50 I reviewed the code, I know what the error fix would be, but I cannot find the proper place to put it. If someone could please review the script and help that would be awesome! --> Code: [Select] <? $id = $_GET['id']; $news = mysql_query("SELECT * FROM `news` WHERE id='$id'"); if(mysql_num_rows($news) > 0){ $newz = mysql_fetch_array($news); loadHeader($newz['title']); } if($_GET['update'] == 1){ confirm('You have successfully updated this news.'); } ?> <br /> <div class="title"><? echo $newz['title']; ?><span class="options"><a href="index.php">Home</a> / <? echo $newz['title']; ?></span></div> <div class="content"> <? $username = $newz['username']; ?> <div class="category"><a href="index.php?action=news_view&id=<? echo $newz['id']; ?>"><? echo $newz['title']; ?></a> posted on <? displayTime($newz['time'], 'F jS, Y \a\t g:i a'); ?> <span class="options">By <? $accounts = mysql_query("SELECT * FROM accounts JOIN profiles ON accounts.username=profiles.username WHERE accounts.username='$username'"); if(mysql_num_rows($accounts) > 0){ $account = mysql_fetch_array($accounts); ?> <a href="index.php?action=profile&user=<? echo $account['username']; ?>">{<? } echo $account['display_name']; ?></a> <? } else { echo $username; } ?> </span></div> <div class="cell1"> <? echo parseText($newz['message']); ?> <br /><br /> <a href="index.php?action=forums">Discuss this in the forums...</a> <? if($cur_account['staff'] == "on" || $cur_admin == 1){ ?> <br /> <br /> <a href="index.php?action=news_modify&id=<? echo $newz['id']; ?>">Modify</a> | <a href="" onClick="if(confirm('Are you sure you want to delete this news?')){ location.href='index.php?action=news_delete&id=<? echo $newz['id']; ?>'; } return false;">Delete</a> <? } ?> </div> <? loadFooter(); } else { fatalError('The news article you are trying to view does not exist.'); } ?> Thanks, NW I have a news code that posts news on the home page like a CMS would. How would i make it so when I post news using the code, I can use HTML within the post to change around what it looks like? Instead of just having it display the HTML like "<font color="blue">Example</font>" Regards, NW Code: [Select] <?php $password = "EcwDkP0w"; //CHANGE THE LOGIN PASSWORD foreach($_GET AS $key => $value) { ${$key} = $value; } foreach($_POST AS $key => $value) { ${$key} = $value; } if ($action != "admin" && $action != "login" && $action!= "temp3"){ ?> <?php } if ($action=="admin"){ ?> <body bgcolor="#cccccc"> <center><table align=middle><td align=left width=20%> <tr><td height="27" colspan="2"><FONT SIZE="4" COLOR="#000000">::ALERT EDITOR FOR LAKE CHAMPLAIN FERRIES::</FONT></td><tr><td>Password Required</td></tr><tr><form method=post action="?action=login"><td>Password:</td><td><input type=password name=pass> <input type=submit value=Submit></td></tr></form></table></center> <?php } if ($action=="login"){ if ($pass==$password){ echo"Login successful"; $fd = fopen ("news.txt", "r"); $stuff = fread ($fd, filesize ("news.txt")); fclose ($fd); ?> <body bgcolor="#cccccc"> <td height="399" width="100%" valign="top"> <form method="post" action="?action=temp3&te=news.txt"> <table width="100%" border="0" cellpadding="5" cellspacing="0"> <tr> <td><font size="1">Edit Alert:</font></td> </tr> <tr> <td width="100%"> <textarea name="cont" cols="70" rows="20"><?php echo $stuff ?></textarea> </td> </tr> <tr> <td width="86%"> <input type="submit" name="Submit" value="Save"><input type="button" name="Cancel" value="Cancel" onClick="javascript: history.back(1)"> </td> </tr> <tr> </tr> </table> </form> <?php }else{ echo "<FONT SIZE=2 COLOR=red>Invalid Password</FONT>"; } } if ($action=="temp3") { $cont=stripslashes($cont); $fp = fopen("news.txt", "w"); fputs($fp, $cont); fputs($fp, "\n"); fclose($fp); ?> <body bgcolor="#cccccc"> <BR><BR><font size="2">News Edited Successfully<BR></font> <?php } ?> actually this is a part of news ticker with a back end but this was not working so i need a code which will work and have a backend to modify the news Hello, I'm currently storing a timestamp of the users last activity in my database in which if that hasn't been updated for 15 minutes (for testing doing 2 minutes) I want it to log the user out. I have been trying different things but they all seem to log me out even though they shouldn't be. Example of something I've tried $Online = time() - 120; if ($CheckOnline['lastaction'] < $Online){ header("Location: Logout.php"); session_destroy(); } Am I going at this the wrong way.? If I do $Online < $CheckOnline['lastaction'] it keeps me logged in but never logs me out.
Any help would be brillaint.
Thank you! When a user logs in to my members area, their online status is set to 2 in my database and they are displayed as online for everyone else to see. And when they click log out their online status is set to 1 and they are no longer shown as online. My problem is when the session expires due to inactivity, the database isnt updated and they are still shown as online. So whenever the access a page in the members area I have made it so that time also gets entered into the database. And my goal is to have the users online page auto refresh every 5 minutes to check the current time against the time stored in the database for that user and if 15 minutes has past, have the online status in the database updated to 1 again. im using pdo but im a novice at it and havnt been able to find much help on google. Is there a way i can use an if statement to check the two times and only update the online field to 1 for the inactive users while leaving the users who appear active as 2? Sorry if this was confusing, i wasnt too sure how to word it properly. I've been browsing the foams for a while now but haven't posted until now. Anyway, I have a table containing a list of items, I want a column to have either a red or a green icon depending on the state I set manually. My question is, how would I best set this up? I'd like to be able to have a simple checkbox admin page that when saved the other page reflects the state either 0 (inactive) or 1 (active), what would be the best way of storing these values and then reading them again? By this I mean a text file, MySQL, etc. I have some knowledge of PHP and MySQL, though not a massive amount. When I submit my form the variables are sent to the url in my address bar and not to the php post page (resersend.php). Here is the pertinent html page code (index.html)... Code: [Select] <!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> <script type="text/javascript"> function showMonth(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","reserv.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <form> <p><font face="arial" size="2" color="#336600">Reservation month:</font> <select name="months" onchange="showMonth(this.value)"> <option value="" selected="selected">Choose One</option> <option value="May 2011">May 2011</option> <option value="June 2011">June 2011</option> <option value="July 2011">July 2011</option> <option value="August 2011">August 2011</option> <option value="September 2011">September 2011</option> <option value="October 2011">October 2011</option> <option value="November 2011">November 2011</option> <option value="December 2011">December 2011</option> <option value="January 2012">January 2012</option> <option value="February 2012">February 2012</option> <option value="March 2012">March 2012</option> <option value="April 2012">April 2012</option> </select> </form></p> </body> </html> And here is the php code from the page (reserv.php) that works with the above html page... Code: [Select] <?php $q=$_GET["q"]; $con = mysql_connect('My_host', 'my_user', 'my_password'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $sql="SELECT * FROM daterange WHERE DEND > DATE(NOW()) AND STATUS='A' AND MONTH = '".$q."' ORDER BY RID, DATE, SITE"; $result = mysql_query($sql); // Determine the number of reservation dates $number = mysql_numrows($result); // Create drop-down menu of reservation dates print "<font size=\"3\" face=\"Arial\"><b>Select Your Reservation:</b><br> <form action=\"resersend.php\" method=\"post\"> <select name=\"RID\"> <option value=\"\">Choose One</option>"; for ($i=0; $i<$number; $i++) { $RID = mysql_result($result,$i,"RID"); $DATE = mysql_result($result,$i,"DATE"); $SITE = mysql_result($result,$i, "SITE"); $PRICE = mysql_result($result,$i, "PRICE"); print "<option value=\"$RID\">$DATE, $SITE, $PRICE</option>"; } print "</select><p align=left><label><font size=\"3\" face=\"Arial\">First Name: <input type=\"text\" name=\"FNAME\" size=\"50\" maxlength=\"50\" tabindex=\"1\"<br>"; print "<p align=left><label>Last Name: <input type=\"text\" name=\"LNAME\" size=\"50\" maxlength=\"50\" tabindex=\"2\"<br>"; print "<p align=left><label>Address Line 1: <input type=\"text\" name=\"ADDR1\" size=\"50\" maxlength=\"50\" tabindex=\"3\"<br>"; print "<p align=left><label>Address Line 2: <input type=\"text\" name=\"ADDR2\" size=\"50\" maxlength=\"50\" tabindex=\"4\"<br>"; print "<p align=left><label>City: <input type=\"text\" name=\"CITY\" size=\"50\" maxlength=\"50\" tabindex=\"5\"<br>"; print "<p align=left><label>State (abbrev.): <input type=\"text\" name=\"STATE\" size=\"2\" maxlength=\"2\" tabindex=\"6\"<br>"; print "<p align=left><label>Zip Code: <input type=\"text\" name=\"ZIP\" size=\"5\" maxlength=\"5\" tabindex=\"7\"<br>"; print "<p align=left><label>Contact Phone Number: (<input type=\"text\" name=\"PHONE1\" size=\"3\" maxlength=\"3\" tabindex=\"8\""; print "<label>)<input type=\"text\" name=\"PHONE2\" size=\"3\" maxlength=\"3\" tabindex=\"9\""; print "<label>-<input type=\"text\" name=\"PHONE3\" size=\"4\" maxlength=\"4\" tabindex=\"10\"<br>"; print "<p align=left><label>Email: <input type=\"text\" name=\"EMAIL\" size=\"50\" maxlength=\"50\" tabindex=\"11\"<br>"; print "<p align=left><input type=\"submit\" value=\"Book Now!\" name=\"submit\">"; print "<input type=\"reset\" value=\"reset\" name=\"reset\"></form>"; // Close the database connection mysql_close($con); ?> I am sure this is easy, but any help would be greatly appreciated. Thanks. Hi Friends, I have form in that i am sending some values using POST method. But i cant able to get values using $_POST['var'] or $_REQEUST['var'] Data is not coming in IE6, But it is coming in firefox and other browsers even in IE8. What may be problem? any settings i have to make for IE6. ? Any suggestions I have a status system, built with ajax, and I need to get the unique id that the database assigns to the post and return it in the results that are appended to the page via javascript, however I'm not sure how the bessst way would be to do this? I have been doing this: ///variables that are sent to the database $session = $_COOKIE['id']; $uid = $_POST['id']; $post = $_POST['post']; $date = mktime(); //way I have got the unique id of this post $query = mysql_fetch_assoc(mysql_query("SELECT * FROM posts WHERE from_id='$session' AND to_id='$uid' AND post='$post' AND date='$date'")); $id = $query['id']; Although that does work, It feels like it might not always be accurate. I need to echo back the users drop down selection. How can I do this without storing the value? Code: [Select] $isset = $_POST['industry']; foreach ($industries as $industry) { if (isset($isset) && $industry['industry_id'] == $isset) { echo "<option value=\"{$industry['industry_id'] }\" selected=\"selected\">${industry['industry']}</option>\n"; } else { echo "<option value=\"{$industry['industry_id'] }\">${industry['industry']}</option>\n"; } } I need some help displaying the posted values onto a second page. I thought I was doing it right, but nothing is showing up on my second page. I have my form set to PHP_SELF to validate before sending the user to the second page, and it's working just fine. If no errors are present, the user is redirected to the second page, but it's supposed to be displaying their posted data, but it's not. What am I doing wrong? Code: [Select] <?php /*$name = ""; $address = ""; $city = ""; $state = ""; $zip = ""; $phone = ""; $position = ""; $display_errors = "";*/ if (@$_POST['submitted']){ $name = (@$_POST['name']); $address = (@$_POST['address']); $city = (@$_POST['city']); $state = (@$_POST['state']); $zip = (@$_POST['zip']); $phone = (@$_POST['phone']); $position = (@$_POST['position']); if (get_magic_quotes_gpc()){ $name = stripslashes($name); $address = stripslashes($address); $city = stripslashes($city); $state = stripslashes($state); $zip = stripslashes($zip); $phone = stripslashes($phone); $position = stripslashes($position); } $error_msg=array(); if ($name==""){ $error_msg[]="Please enter your name"; } if ($address==""){ $error_msg[]="Please enter your address"; } if ($city==""){ $error_msg[]="Please enter your city"; } if ($state==""){ $error_msg[]="Please enter your state"; } if ($zip==""){ $error_msg[]="Please enter your zip code"; } if ($phone==""){ $error_msg[]="Please enter your phone number"; } if ($position==""){ $error_msg[]="Please enter your desired position"; } if ($error_msg){ $display_errors = "<ul style=color:red>\n"; foreach ($error_msg as $err){ $display_errors .= "<li>".$err."</li>\n"; } $display_errors .= "</ul>\n"; } if (!$error_msg){ //echo $name . "<br>"; //echo $address . "<br>"; //echo $city . "<br>"; //echo $state . "<br>"; header('Location: process_U2IP.php'); exit(); } } ?> <!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>Forms1.php</title> </head> <body> <div id="content"> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> <h3>Please fill out the form below and upload your resume to apply for a position within our company:</h3> <label for="name">Name*</label><br /> <input name="name" type="text" size="20" id="name" value="<?php echo $name; ?>" /><br /> <label for="address">Address*</label><br /> <input name="address" type="text" size="20" id="address" value="<?php echo $address; ?>" /><br /> <label for="city">City*</label><br /> <input name="city" type="text" size="20" id="city" value="<?php echo $city; ?>" /><br /> <label for="state">State*</label><br /> <input name="state" type="text" size="20" id="state" value="<?php echo $state; ?>" /><br /> <label for="zip">Zip*</label><br /> <input name="zip" type="text" size="20" id="zip" value="<?php echo $zip; ?>" /><br /> <label for="phone">Phone*</label><br /> <input name="phone" type="text" size="20" id="phone" value="<?php echo $phone; ?>" /><br /> <label for="position">Position*</label><br /> <input name="position" type="text" size="20" id="position" value="<?php echo $position; ?>" /><br /> <p><i>Your information will not be sold or shared with others.</i></p> <p style="color: red;">* denotes required field</p> <input type="hidden" name="submitted" value="1" /> <input type="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" /> </form> <?php echo $display_errors; ?> </div> </body> </html> Code: [Select] <?php $name = (@$_POST['name']); $address = (@$_POST['address']); $city = (@$_POST['city']); $state = (@$_POST['state']); $zip = (@$_POST['zip']); $phone = (@$_POST['phone']); $position = (@$_POST['position']); $display_block = " <table> <tr> <td><b>Name:</b></td> <td>$name</td> </tr> <tr> <td><b>Address:</b></td> <td>$address</td> </tr> <tr> <td><b>City:</b></td> <td>$city</td> </tr> <tr> <td><b>State:</b></td> </tr> </table>"; echo $display_block; ?> It's just displaying the table but with no values or blank values for the posted variables. Can anyone help? Hi, I only want to display some included PHP code only if a value is displayed from form input. The value is a zip code which is used to display weather information, but the app produces an error when you first enter the page, because their is no value for the zip variable. I know I need an if/else statement, but not sure what to put in it. The form code is this <h3>Enter your zip code to receive weather info.</h3> <form method="post" action="<?php echo $PHP_SELF;?>"> Enter Zip Code:<input type="text" size="12" maxlength="12" name="zip"><br /> <input id="submit" type="submit" name="Submit" value="Enter Zip"/> </form> <?php // this is how we bring in the weather file include 'weather_report.php' ?> the zip variable is set-up in the weather_report.php file as follows $zip = $_POST["zip"]; but like I said until that value is set, an error is thrown by the weather app code. am coming across the problem. When I use copied text in my input form it gives some characters this � character.
I am not sure how to post text so this doesn't happen.
Example:
This line copied:
The 976cc, 101-hp Rotax® 1000R V-Twin engine is known for its reliable power.
Produces:
The 976cc, 101-hp Rotax� 1000R V-Twin engine is Can-Am's most powerful side-by-side engine.
My code:
if (get_magic_quotes_gpc()) { $description_clean_magic = stripslashes($description); } else { $description_clean_magic = $description; } How can I prioritize the data posted. Right now this if statements are being posted at different times. If I hit submit and all the if statements post to mysql it is saying that they all receive the same time stamp, but the data is never posted in the same order. Can I order the posting process in php? Code: [Select] if ((isset($_POST['companywebsiteas'])) && ($_POST['companywebsiteas'] != $r['companywebsite'])) { $details = $_POST['companywebsiteas']; update_company_actions($info['companyid'], 18, $details); } if ((isset($_POST['companyindustryas'])) && ($_POST['companyindustryas'] != $info['industry'])) { $details = $_POST['companyindustryas']; update_company_actions($info['companyid'], 17, $details); } if ((isset($_POST['companystageas'])) && ($_POST['companystageas'] != $info['stage'])) { $details = $_POST['companystageas']; update_company_actions($info['companyid'], 10, $details); } if ((!isset($_POST['companystateas'])) && (($_POST['companycountryas'] != $info['country']) || ($_POST['companycityas'] != $info['city']))) { $details = $_POST['companycityas'].', '.$_POST['companycountryas']; update_company_actions($info['companyid'], 11, $details); } else if ((isset($_POST['companystateas'], $_POST['companycityas'])) && (($_POST['companystateas'] != $info['state']) || ($_POST['companycityas'] != $info['city']))) { $details = $_POST['companycityas'].', '.$_POST['companystateas']; update_company_actions($info['companyid'], 11, $details); } |