PHP - Trouble To Center Navbar With Css
Hey guys, I am having trouble centering a navbar with css on my template.
Here is a jsfiddle live preview for you.
http://jsfiddle.net/LRS38/
I added text-align:center; to it but it still wont center. I also added a margin:0 auto; but no luck.
Can anyone see what I am doing wrong?
<div id="navigation"> <ul> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li class="current"><a href="#">Services</a></li> <li><a href="#">Contact us</a></li> </ul> </div>and #navigation { text-align:center; background-color:#ef6b51; overflow:hidden; } Similar TutorialsHey guys, I am working on something and keep getting some padding on my css navabar, its pretty simple but I cant figure out where it grabbing the padding from pushing it about 5 pixels to the right. jsfiddle live preview is a demo and here is a picture of the hover over. Notice the little gray space in between the hovered over Update Profile? I cant seem to find the code anywhere that would cause that. Anyone notice anything in my code? <head> <title>2 Column CSS Layout</title> <style type="text/css"> body { margin: 20px; font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif; background-color: #555; } #nav { text-align:center; } /* Begin Navigation Bar Styling */ #nav ul { text-align: center; font-size: 11px; width: 100%; margin: 0; padding: 0; display:inline-block; padding: 0; list-style: none; background-color: #f2f2f2; border-bottom: 1px solid #ccc; border-top: 1px solid #ccc; } #nav li { display:inline-block; } #nav li a { display: block; padding: 8px 15px; text-decoration: none; font-weight: bold; color: #069; border-right: 1px solid #ccc; } #nav li a:hover { color: #c00; background-color: #fff; } /* End navigation bar styling. */ div { text-align:center; } div#page { background-color: white; margin: 0 auto; text-align: left; width: 755px; padding:0px 10px 0 10px; } div#header { border-bottom:1px solid black; height: 30px; line-height: 30px; } div#content { background: none repeat scroll 0 0 none; border:0px solid blue; width:100%; line-height: 500px; min-height:500px; _height:500px } div#footer { border:0px solid red; height:30px; line-height: 30px; border-top:1px solid black; font-size: 9pt; } </style> <body> <div id="page"> <div id="header"> <div style="float: left;">Welcome Admin</div> <div style="float: right;">LOGOUT</div> <div id="nav"> <ul id="nav"> <li><a href="#">Home Page</a></li> <li><a href="#">My Account</a></li> <li><a href="#">Update Profile</a></li> <li><a href="#">Change Avatar</a></li> <li><a href="#">Change Password</a></li> <li><a href="#">Support</a></li> </ul> </div> </div> <div id="content">Content</div> <div id="footer"><div style="float: right;">copyright 2014</div></div> </div> </body> Hello everybody, I have a problem with my site I am making.
http://gmann.gflclan.com/index.php (this is a test site, I am not even near close to being done with it).
The problem I am having is, when I make my browser smaller, the navbar body doesn't move down (expand).
#navbar { width:auto; height: 5%; position:relative; background:url(images/transbg4.png); border-radius:15px 15px 0px 0px; box-shadow: 5px 5px 10px #121212; margin-left: 30%; margin-right: 30%; color: white; text-align: left; }There's the code. I think it has to do with "height: 5%;". Do you guys have any idea on how to fix this. I am learning coding, and sorry if this is a "noob" question. Also, if you want, feel free to give suggestions for the site, I already know it looks horrible but I plan on making it better in the future. Here is the navbar in the PHP file I made: <div id="navbar"> <ul id="nav_links"> <?php $query = "SELECT * FROM `navlist` ORDER BY `lorder` ASC"; $result = mysqli_query($db, $query) or die ('Error with the nav list query! Error: ' . mysqli_error($db)); while ($nav = mysqli_fetch_assoc($result)) { echo '<div class="navlink">'; $target = ''; if($nav['newpage'] == 1) { $target = 'target=_blank'; } else { $target = ''; } echo '<li class="nav_button"><a href="' . $nav['link'] . '" ' . $target . '>' . $nav['name'] . '</a></li>'; echo '</div>'; } ?> </ul> </div>Thanks, Gamemann Hi! I have this code <?php /** * @Project: Virtual Airlines Manager (VAM) * @Author: Alejandro Garcia * @Web http://virtualairlinesmanager.net * Copyright (c) 2013 - 2016 Alejandro Garcia * VAM is licensed under the following license: * Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) * View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/4.0/ */ ?> <!DOCTYPE html> <html> <head> <script src="https://maps.googleapis.com/maps/api/js?key=XXX&callback=initMap" type="text/javascript"> </script> <meta http-equiv="refresh" content="300"> </head> <body> <?php include('./db_login.php'); $db_map = new mysqli($db_host , $db_username , $db_password , $db_database); $db_map->set_charset("utf8"); if ($db_map->connect_errno > 0) { die('Unable to connect to database [' . $db_map->connect_error . ']'); } $sql_map = "select plane_type,ias,flight_id,u.gvauser_id as gvauser_id,u.callsign as callsign,u.name as name,gs,altitude,surname,departure,arrival,latitude,longitude,flight_status,heading,perc_completed, pending_nm, a1.latitude_deg as dep_lat, a1.longitude_deg as dep_lon , a2.latitude_deg as arr_lat, a2.longitude_deg as arr_lon , network from vam_live_flights lf, gvausers u , airports a1, airports a2 where u.gvauser_id=lf.gvauser_id and lf.departure=a1.ident and lf.arrival=a2.ident"; if (!$result = $db_map->query($sql_map)) { die('There was an error running the query [' . $db_map->error . ']'); } unset($flights_coordinates); unset($flight); unset($liveflights); unset($datos); unset($jsonarray); $flights_coordinates = array(); $datos = array (); $flight = array(); $liveflights = array (); $jsonarray = array (); $index = 0; $index2=0; $flightindex=0; while ($row = $result->fetch_assoc()) { $flight["gvauser_id"]=$row["gvauser_id"]; $flight["callsign"]=$row["callsign"]; $flight["name"]=$row["name"]; $flight["gs"]=$row["gs"]; $flight["ias"]=$row["ias"]; $flight["altitude"]=$row["altitude"]; $flight["surname"]=$row["surname"]; $flight["departure"]=$row["departure"]; $flight["arrival"]=$row["arrival"]; $flight["latitude"]=$row["latitude"]; $flight["longitude"]=$row["longitude"]; $flight["flight_status"]=$row["flight_status"]; $flight["heading"]=$row["heading"]; $flight["dep_lat"]=$row["dep_lat"]; $flight["dep_lon"]=$row["dep_lon"]; $flight["arr_lat"]=$row["arr_lat"]; $flight["arr_lon"]=$row["arr_lon"]; $flight["perc_completed"]=$row["perc_completed"]; $flight["pending_nm"]=$row["pending_nm"]; $flight["network"]=$row["network"]; $flight["plane_type"]=$row["plane_type"]; $liveflights[$flightindex] =$flight; $sql_map2 = "select * from vam_live_acars where flight_id='".$row["flight_id"]."' order by id asc"; if (!$result2 = $db_map->query($sql_map2)) { die('There was an error running the query [' . $db_map->error . ']'); } while ($row2 = $result2->fetch_assoc()) { $flights_coordinates ["gvauser_id"] = $row2["gvauser_id"]; $flights_coordinates ["latitude"] = $row2["latitude"]; $flights_coordinates ["longitude"] = $row2["longitude"]; $flights_coordinates ["heading"] = $row2["heading"]; $datos [$index2][$index] = $flights_coordinates; $index ++; } $index=0 ; $index2 ++; $flightindex ++; } $jsonarray[0]=$liveflights; $jsonarray[1]=$datos; ?> <div class="container"> <div class="row"> <div id="map-outer" class="col-md-11"> <div id="map-container" class="col-md-12"></div> <div id="over_map"></div> </div><!-- /map-outer --> </div> <!-- /row --> </div><!-- /container --> <style> body { background-color:#FFFFF } #map-outer { padding: 0px; border: 0px solid #CCC; margin-bottom: 0px; background-color:#FFFFF } #map-container { height: 500px } @media all and (max-width: 800px) { #map-outer { height: 650px } } </style> <style> #wrapper { position: relative; } #over_map { position: absolute; top: 50px; left: 10px; z-index: 99; background: white;} </style> </body> <script type="text/javascript"> var mapCentre; var map ; function init_map() { var flights = <?php echo json_encode($jsonarray[0]); ?>; var locations = <?php echo json_encode($jsonarray[1]); ?>; var numpoints=(locations.length); console.log(locations); var var_location = new google.maps.LatLng(<?php echo $datos[0][0]["latitude"]; ?>,<?php echo $datos[0][0]["longitude"]; ?>); var var_mapoptions = { center: var_location, zoom: 5, styles: [{"featureType":"all","elementType":"all","stylers":[{"saturation":"0"},{"lightness":"0"}]},{"featureType":"all","elementType":"geometry","stylers":[{"lightness":"20"}]},{"featureType":"administrative","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"visibility":"on"}]},{"featureType":"administrative","elementType":"labels","stylers":[{"visibility":"on"},{"color":"#716464"},{"weight":"0.01"}]},{"featureType":"administrative.country","elementType":"labels","stylers":[{"visibility":"on"}]},{"featureType":"landscape","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"landscape.natural","elementType":"geometry","stylers":[{"visibility":"simplified"}]},{"featureType":"landscape.natural.landcover","elementType":"geometry","stylers":[{"visibility":"simplified"}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"poi","elementType":"geometry.fill","stylers":[{"visibility":"simplified"}]},{"featureType":"poi","elementType":"geometry.stroke","stylers":[{"visibility":"simplified"}]},{"featureType":"poi","elementType":"labels.text","stylers":[{"visibility":"simplified"}]},{"featureType":"poi","elementType":"labels.text.fill","stylers":[{"visibility":"simplified"}]},{"featureType":"poi","elementType":"labels.text.stroke","stylers":[{"visibility":"simplified"}]},{"featureType":"poi.attraction","elementType":"geometry","stylers":[{"visibility":"on"}]},{"featureType":"road","elementType":"all","stylers":[{"visibility":"on"}]},{"featureType":"road","elementType":"labels","stylers":[{"visibility":"on"}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"visibility":"on"}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#ffad99"},{"lightness":"45"}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"visibility":"on"},{"color":"#fbac99"},{"lightness":"1"}]},{"featureType":"road.highway","elementType":"labels","stylers":[{"visibility":"on"}]},{"featureType":"road.highway.controlled_access","elementType":"geometry.fill","stylers":[{"color":"#ffff80"},{"lightness":"50"}]},{"featureType":"road.highway.controlled_access","elementType":"geometry.stroke","stylers":[{"color":"#ff6666"},{"lightness":"59"},{"visibility":"on"},{"weight":"1.10"}]},{"featureType":"road.arterial","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#fff13a"}]},{"featureType":"road.arterial","elementType":"geometry.stroke","stylers":[{"color":"#f2d344"},{"visibility":"off"},{"weight":"1.41"}]},{"featureType":"road.local","elementType":"all","stylers":[{"visibility":"on"}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"visibility":"simplified"}]},{"featureType":"transit.station","elementType":"geometry","stylers":[{"visibility":"on"}]},{"featureType":"water","elementType":"all","stylers":[{"visibility":"simplified"},{"color":"#12586f"},{"lightness":"20"},{"gamma":"6.95"},{"saturation":"-29"}]},{"featureType":"water","elementType":"geometry","stylers":[{"visibility":"on"}]},{"featureType":"water","elementType":"geometry.fill","stylers":[{"visibility":"on"}]}] }; map = new google.maps.Map(document.getElementById('map-container'), var_mapoptions); var mapas=[]; var flightPlanCoordinates=[]; var flightPath = new google.maps.Polyline({ strokeColor: "#c3524f", strokeOpacity: 1, strokeWeight: 2, geodesic: true }); var k=0; var z=0; var coordinate; while (k<numpoints) { while (z < locations[k].length) { coordinate =new google.maps.LatLng(locations[k][z]['latitude'],locations[k][z]['longitude']); flightPlanCoordinates.push(coordinate); z=z+1; } ruta = new google.maps.Polyline({ geodesic: true, strokeColor: '#FF0000', strokeOpacity: 1.0, strokeWeight: 2 }); ruta.setPath(flightPlanCoordinates); mapas.push(ruta); z=0; k=k+1; }; function createMarker(pos, t) { var coord=[]; var pathcoord=[]; var flight_id = t; currentPath = new google.maps.Polyline({ geodesic: true, strokeColor: '#FF0000', strokeOpacity: 1.0, strokeWeight: 2 }); // Plane marker begin var image = new google.maps.MarkerImage("./map_icons/"+flights[t]['heading'] +".png",null,new google.maps.Point(0,0),new google.maps.Point(15, 15),new google.maps.Size(30, 30)); var icon_airport = new google.maps.MarkerImage("./map_icons/airport_yellow_marker.png"); var lineSymbol = {path: 'M 0,-1 0,1', strokeOpacity: 1, scale: 1 }; var lat1 = flights[t]["dep_lat"]; var lat2 = flights[t]["arr_lat"]; var lng1 = flights[t]["dep_lon"]; var lng2 = flights[t]["arr_lon"]; var dep = new google.maps.LatLng(lat1, lng1) var arr = new google.maps.LatLng(lat2, lng2) var icon_plane = 'images/plane.png'; var marker = new google.maps.Marker({ position: pos, icon: image, name: t , contenido: flights[t]['callsign']+ ' '+flights[t]['name']+ ' '+flights[t]['surname'] , icao1:new google.maps.Marker({ position: dep, map: map, icon: icon_airport, visible: false }), icao2:new google.maps.Marker({ position: arr, map: map, icon: icon_airport, visible: false }), line1:new google.maps.Polyline({ path: [dep, pos], strokeColor: "#08088A", strokeOpacity: 1, strokeWeight: 2, geodesic: true, map: map, polylineID: t, visible: false }) , line2:new google.maps.Polyline({ path: [pos, arr], strokeColor: "#FE2E2E", strokeOpacity: .3, geodesic: true, map: map, icons: [{ icon: lineSymbol, offset: '0', repeat: '5px' }], polylineID: t, visible: false }) }); // On mouse over google.maps.event.addListener(marker, 'mouseover', function () { //infowindow.open(map, marker); this.get('line1').setVisible(true); this.get('line2').setVisible(true); this.get('icao1').setVisible(true); this.get('icao2').setVisible(true); infowindow.open(map,marker); infowindow.setContent(marker.contenido); var s=0; coord.length = 0; pathcoord.length = 0; while (s < locations[flight_id].length) { coord= new google.maps.LatLng(locations[flight_id][s]['latitude'],locations[flight_id][s]['longitude']); pathcoord.push(coord); s=s+1; } currentPath.setPath(pathcoord); currentPath.setMap(map); }); // On mouse end // mouse out google.maps.event.addListener(marker, 'mouseout', function () { //infowindow.close(); //this.get('line1').setVisible(false); //this.get('line2').setVisible(false); //this.get('icao1').setVisible(false); //this.get('icao2').setVisible(false); //currentPath.setMap(null); }); // mouse out end // On Click begin google.maps.event.addListener(marker, 'click', function() { infowindow.open(map,marker); infowindow.setContent(marker.contenido); var s=0; coord.length = 0; pathcoord.length = 0; while (s < locations[flight_id].length) { coord= new google.maps.LatLng(locations[flight_id][s]['latitude'],locations[flight_id][s]['longitude']); pathcoord.push(coord); s=s+1; } currentPath.setPath(pathcoord); currentPath.setMap(map); if (this.get('line1').visible ='true') { this.get('line1').setVisible(false); } if (this.get('line2').visible ='true') { this.get('line2').setVisible(false); } if (this.get('icao1').visible ='true') { this.get('icao1').setVisible(false); } if (this.get('icao2').visible ='true') { this.get('icao2').setVisible(false); } flight_detail='<div class="panel panel-map">\ <!-- Default panel contents -->\ <div class=\"panel-heading\">'+flights[t]['departure'] + ' <i class="fa fa-arrow-right"></i> ' + flights[t]['arrival']+'</div>\ <table class="table-map">\ <tr>\ <td><small>Flight completed</small><br><div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="\ '+flights[t]['perc_completed'] + '" aria-valuemin="0" aria-valuemax="100" style="width:'+flights[t]['perc_completed']+'%">\ '+flights[t]['perc_completed'] + ' %</div></td>\ </tr>\ <tr>\ <td><small>Callsign</small><br><strong>\ '+flights[t]['callsign'] + '</strong></td>\ </tr>\ <tr>\ <td><small>Flight Status</small><br><strong>\ '+flights[t]['flight_status'] + '</strong></td>\ </tr>\ <tr>\ <td><small>Plane Type</small><br><strong>\ '+flights[t]['plane_type'] + '</strong></td>\ </tr>\ <tr>\ <td><small>Network</small><br><strong>\ '+flights[t]['network'] + '</strong></td>\ </tr>\ <tr>\ <td><small>Pending NM</small><br><strong>\ '+flights[t]['pending_nm'] + '</strong></td>\ </tr>\ <tr>\ <td><small>GS</small><br><strong>\ '+flights[t]['gs'] + '</strong></td>\ </tr>\ <tr>\ <td><small>IAS</small><br><strong>\ '+flights[t]['ias'] + '</strong></td>\ </tr>\ <tr>\ <td><small>Altitude</small><br><strong>\ '+flights[t]['altitude'] + '</strong></td>\ </tr>\ <tr>\ <td><small>Heading</small><br><strong>\ '+flights[t]['heading'] + '</strong></td>\ </tr>\ </table>\ </div>'; //flights[t]['departure'] + '-' + flights[t]['arrival'] + '<br />' + flights[t]['callsign']+ ' '+flights[t]['name']+ ' '+flights[t]['surname'] + '<br />' + 'ALTITUDE: ' + flights[t]['altitude'] + '<br />' + 'GS: ' + flights[t]['gs']+ '<br />' + 'HEADING: ' + flights[t]['heading'] + '<br />' + flights[t]['flight_status']; $('#over_map').html("<div id='mySecondDiv'>"+flight_detail+"</div>"); }); // On Click end return marker; } var numflight=0 while (numflight < flights.length ) { var avionicon =new google.maps.LatLng(flights[numflight]['latitude'],flights[numflight]['longitude']); var m1 = createMarker(avionicon, numflight); m1.setMap(map); numflight = numflight +1; } var s=0; while (s < mapas.length) { s=s+1; } var infowindow = new google.maps.InfoWindow({ }); google.maps.event.addListener(infowindow, 'closeclick', function() { $('#over_map').html(""); }); } google.maps.event.addDomListener(window, 'load', init_map); $( document ).ready(refreshflights); function refreshflights(){ setInterval(function () {$.ajax({ url: 'get_map_coordinates.php', data: "", dataType: 'json', success: function(data, textStatus, jqXHR) { init_map(); } })}, 120000); } </script> </html> I need map to be centered on marker every time i go on my webpage. Right now is centered on deparrture aiport. So this is map for flights, as flight is ongoing , aircraft (marker) on route, map should be tracking it so every time i refresh my wepage, map should point to marker, not to departure airport. Can anyone halp me. Thank you Edited December 23, 2020 by mrshiljoI tried to code this, but failed miserably. What I wanted was a admin page that contained various stats of a football match. TEAM 1....................TEAM 2 0...........Score...........0 0.......Shots on target.......0 0.......Shots off target.......0 ect, ect.... The first way I layed it out was a table, i entered the data and it saved to a text file, which then displayed on stats.php in a table format. That then displayed elsewhere via an iframe. I was wondering if someone would code me a stats center like I've explained! You could even help me do it, I don't mind....As long as I get it! Hi, I have the code below: <? /* * search.php * * Script for searching a datbase populated with keywords by the * populate.php-script. */ print "<html><head><title>[Squashy] Search! NOT MESSED UP.</title></head><body>\n"; if( $_POST['keyword'] ) { /* Connect to the database: */ mysql_pconnect("www.freesqldatabase.com","sql01_44052","censored") or die("ERROR: Could not connect to database!"); mysql_select_db("sql01_4405hahamo1"); /* Get timestamp before executing the query: */ $start_time = getmicrotime(); /* Execute the query that performs the actual search in the DB: */ $query = ' SELECT p.page_url AS url, COUNT(*) AS occurrences FROM page p, word w, occurrence o WHERE p.page_id = o.page_id AND w.word_id = o.word_id AND (false '; $words = explode(' ', $_POST['keyword']); foreach ($words as $word) { $query .= 'OR w.word_word = "' . $word . '" '; } $query .= ') GROUP BY p.page_id ORDER BY occurrences DESC LIMIT ' . $_POST['results']; $result = mysql_query($query); /* Get timestamp when the query is finished: */ $end_time = getmicrotime(); /* Present the search-results: */ print "<h2>[Squashy] Search Results For '".$_POST['keyword']."':</h2>\n"; for( $i = 1; $row = mysql_fetch_array($result) or die(mysql_error()); $i++ ) { print "$i. <a href='".$row['url']."'>".$row['url']."</a>\n"; print "(occurrences: ".$row['occurrences'].")<br><br>\n"; } /* Present how long it took the execute the query: */ print "This search took: ".(substr($end_time-$start_time,0,5))." seconds."; } else { /* If no keyword is defined, present the search-page instead: */ print "<form method='post'>[Squashy Search] <input type='text' size='20' name='keyword'>\n"; print "Results: <select name='results'><option value='5'>5</option>\n"; print "<option value='10'>10</option><option value='15'>15</option>\n"; print "<option value='20'>20</option></select>\n"; print "<input type='submit' value='Search [Squashy]'></form>\n"; } print "</body></html>\n"; /* Simple function for retrieving the currenct timestamp in microseconds: */ function getmicrotime() { list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } ?> How do I: a) Center the search box and title and add an image above it like in google, the code for the search box and title is (taken from the code above) { /* If no keyword is defined, present the search-page instead: */ print "<form method='post'>[Squashy Search] <input type='text' size='20' name='keyword'>\n"; print "Results: <select name='results'><option value='5'>5</option>\n"; print "<option value='10'>10</option><option value='15'>15</option>\n"; print "<option value='20'>20</option></select>\n"; print "<input type='submit' value='Search [Squashy]'></form>\n"; } b) How do I protect the code so that people can't see the database name and password? Thanks, Will Dear All, Hope all are fine. Need one hep to align the logo in the center of the footer. I tried align = Center but didn't help, please see below code ad advise. <div class="image"> <img src="images/icon/logo.jpg" alt="John Doe"/> </div>
Kind Regards, Naveed. Edited August 2, 2020 by Naveed786Hello,
Trying to rearrange a data on the website. Looks normal when looking through preview on IE and chrome. But once moved to live website, the whole alignment changes from left to center , including the text that needs to show up. I am a newbie to coding and dont have a clue. tried puttng something together based on what i foud on the web. attaching screenshot and the code that i did. any help is highly appreciated. also attached is a screenshot of what happens when the php file is uploaded. Prior to doing that, the menu on the left is aligned properly and the assets that we have show properly.
What we are trying to do is rearrage the whole assets into different categories.
many thanks
Attached Files
portfolio.php 3.27KB
2 downloads
noalignment.png 11KB
0 downloads Building a website for work. I am struggling with the login for some reason. I`m using a lot of the same code as I did for my personal site and a few other websites I`ve programmed which has always worked. But for some reason, it isn`t working now. I`ve already told it to display to me the information that`s being processed and that is all correct (it even updates the database like it`s supposed to). It just won`t show the person being logged in, which defeats the purpose of logging in, yanno? Here are all the files in question. login.php <?php include "file_calls.php"; $title = "Business Name (Beta): Log In"; include "functions.php"; session_start(); echo "$title"; echo "<p>"; echo "Log into the Business Name website. Only authorized members of the Business Name Staff can log into the website."; echo "<p>"; include "login_form.php"; ?> login_form.php <?php echo "<form action='logging.php' method='post'>"; echo "E-Mail Address:"; echo "<br><input type='text' name='email' size=60 maxlength=100>"; echo "<p>"; echo "Password:"; echo "<br><input type='password' name='pass' size=60 maxlength=25>"; echo "<p>"; $buttonlabel = "Log In"; include "formbutton_format.php"; echo "</form>"; ?> logging.php <?php include "file_calls.php"; $title = "Business Name (Beta): Logging In"; include "functions.php"; session_start(); echo "$title"; echo "<p>"; echo "Logging into the Business Name website. Only authorized members of the Business Name Staff can log into the website."; echo "<p>"; $email = $_POST['email']; $pass = $_POST['pass']; $entry_date = strftime("%B\ %e\,\ %Y %I:%M:%S %p", time()); $res = mysql_query("SELECT id, memlev, pwd1, pwd2, email, name FROM user_data WHERE email='$email'"); $by = mysql_fetch_row($res); mysql_free_result($res); $log = $by[4]; $pas = $by[2]; $pas2 = $by[3]; if ($email && $pass) { if ($by[0]) { if ($by[1] == 2) { $passwd = crypt($_REQUEST['pass'],$by[5]); if ($pass == $pas2) { mysql_query("UPDATE user_data SET lastlogin='$entry_date' WHERE email='$email'"); mysql_close($con); header("Location: index.php"); } elseif ($passwd != $pas) { header("Location: nolog.php?logout=1&m=4"); } } elseif ($by[1] == 1) { header("Location: nolog.php?logout=1&m=2"); } elseif ($by[1] == 0) { header("Location: nolog.php?logout=1&m=3"); } } elseif (!$by[0]) { header("Location: nolog.php?logout=1&m=1"); } } elseif (!$email || !$pass) { echo "<b>Error:</b> Both username and password must be entered in order to log in."; echo "<p>"; include "login_form.php"; } ?>[/php index.php [php]<?php include "file_calls.php"; $title = "Business Name (Beta)"; include "functions.php"; session_start(); echo "$title"; echo "<p>"; echo "This website is currently under construction. Thank you for your patience."; echo "<p>"; if ($lev > 1) { echo "Hello, $loggeduser !"; } elseif ($lev < 2) { echo "Not logged in."; } echo "<p>"; echo "$lev"; echo "<br>$loggeduser<br>$email"; ?> auth.php <?php // Defines DEFINE('SESSION_MAGIC','sadhjasklsad2342'); // Initialization @session_start(); @ob_start(); /* Redirects to another page */ function Redirect($to) { @session_write_close(); @ob_end_clean(); @header("Location: $to"); } /* Deletes existing session */ function RemoveSession() { $_SESSION = array(); if (isset($_COOKIE[session_name()])) { @setcookie(session_name(), '', time()+(60*60*24*365), '/'); } } /* Checks if user is logged in */ function isLoggedIn() { return(isset($_SESSION['magic']) && ($_SESSION['magic']==SESSION_MAGIC)); } /* read message count */ function CountMessages($id) { if ($res=mysql_query("SELECT * FROM user_data WHERE email='$email'")) { $count=mysql_num_rows($res); mysql_free_result($res); return($count); } return 0; } /* Go login go! */ function Login($email,$pass) { global $nmsg, $rows; $ok=false; if ($res=mysql_query("SELECT id, email, name, pwd1, pwd2, memlev FROM user_data WHERE email='$email' AND pwd2='$pass'")) { if ($rows=mysql_fetch_row($res)) { $_SESSION['sess_name'] = $rows[2]; $_SESSION['pass'] = $pass; $_SESSION['gal'] = $rows[0]; $_SESSION['level2'] = $rows[5]; $_SESSION['email'] = $rows[1]; $_SESSION['magic'] = SESSION_MAGIC; $nmsg = CountMessages($rows[0]); $ok=true; } else { include('login_failed.php'); } mysql_free_result($res); } return($ok); } /* Terminates an existing session */ function Logout() { @RemoveSession(); @session_destroy(); } /* Escape array using mysql */ function Escape(&$arr) { if (Count($arr)>0) { foreach($arr as $k => $v) { if (is_array($v)) { Escape($arr[$k]); } else { if (function_exists('get_magic_quotes')) { if(!get_magic_quotes_gpc()) { $arr[$k] = stripslashes($v); } } $arr[$k] = mysql_real_escape_string($v); } } } } // ----------------------------------------------- // Main // ----------------------------------------------- Escape($_POST); Escape($_GET); Escape($_COOKIE); Escape($_REQUEST); Escape($_GLOBALS); Escape($_SERVER); ?> file_calls.php <?php include "info_con.php"; include "auth.php"; ?> functions.php <?php echo "<title>$title</title>"; $lev=isset($_SESSION['level2'])?$_SESSION['level2']:0; $logged=isset($_SESSION['gal'])?$_SESSION['gal']:0; $loggeduser=$_SESSION['sess_name']; $nmsg = 0; $rows = isset($_SESSION['rows'])?$_SESSION['rows']:array(); $email = isset($_SESSION['email'])?$_SESSION['email']:''; $pass = isset($_SESSION['pass'])?$_SESSION['pass']:''; function rand_chars($c, $l, $u = FALSE) { if (!$u) for ($s = '', $i = 0, $z = strlen($c)-1; $i < $l; $x = rand(0,$z), $s .= $c{$x}, $i++); else for ($i = 0, $z = strlen($c)-1, $s = $c{rand(0,$z)}, $i = 1; $i != $l; $x = rand(0,$z), $s .= $c{$x}, $s = ($s{$i} == $s{$i-1} ? substr($s,0,-1) : $s), $i=strlen($s)); return $s; } function ShowLoggedInBar() { global $email,$pass,$rows,$logid; $nmes=""; if($nmsg){ $nmes="($nmsg New)"; } echo "Hello, $loggeduser !"; } /* check if we are logging out */ if (isset($_REQUEST['logout'])) { Logout(); } /* check if already logged in */ if (isset($_SESSION['magic']) && ($_SESSION['magic']==SESSION_MAGIC)) { ShowLoggedInBar(); } else { /* not logged in, is it a form post? */ if (isset($_REQUEST['email']) && isset($_REQUEST['pass'])) { $email = $_REQUEST['email']; $pass = crypt($_REQUEST['pass'],$email); Login($email,$pass); } else { } } ?> Can anyone see why it works on everything but getting the person logged in? Hello everyone, I am new to this forum and PHP world. Doing my first project, a pretty complicated one to start with. I will be needing your help a lot to accomplish it. Here is the first one. 1. I have a certain field called 'country' 2. I have small flag icons for every country. WHAT DO I WANT TO DO? Example - If the country is U.S.A., the U.S. flag shows up and is a link to www.domain.com/usa If the country is Germany, the German flags shows up and is a link to www.domain.com/germany If the country is not set, no flag shows up. END. How do I execute this? This is what I am doing to get the image <img src="images/flags/<?php echo $row_rsPilots['country']; ?>.gif" alt="" name="Flag" width="20" height="20" id="Flag" /> How do make it a link to www.domain.com/'country' Thanks in advance Hi Chaps, I have a PHP FTP App, where users can log in using a unique code and a password. Their unique code corresponds to an FTP folder, e.g. Quote \FTP_Root\Customer A & Co\ So when the user logs in, they can see their FTP directory and contents, in this case an Inbox and an Outbox. This works as the FTP folder contains both an Inbox and an Outbox. The problem I am having is when I try browsing within this directory (say the Inbox), ftp-chdir fails. I have a hyperlink that sends a 'dir' parameter to the same ftp.php page, and if set, will attempt to change to the given directory. So even though the URL Hyperlink reads: Quote ....server.co.uk/ftp.php?dir=/FTP_Root/Customer A & Co/Inbox When you click on this link, the page tries to load: Quote ....server.co.uk/ftp.php?dir=/FTP_Root/Customer A So my question is what do I need to change, the Hyperlink to read something like: Quote ....server.co.uk/ftp.php?dir=/FTP_Root/Customer%20A%20&%20Co/Inbox Do something to the ftp-chdir function, where I encode/decode/whatever to make sure it tries to change to the correct FTP directory? Or exclude all ampersand entirely? I'm attempting to rewrite my urls but don't seem to be getting it to work. I've tried: RewriteEngine On RewriteRule /(.*)/(.*)/$ listings.php?ident=$1&facility=$2 And I've also tried: RewriteEngine On RewriteRule ^([^/\.]+)/([^/\.]+)?$ listings.php?ident=$1&facility=$2
Any suggestions? I'm attempting to multiply a number. It does fine unformatted, but when I add number_format and the number is above 1,000 with a comma separator, it has problems. I tried formatting with out the comma, then adding back in after the calculation, but that did not work. $value = 1000; $multiplier = 1.02; for ($i = 1; $i <= 10; $i++) { $value = number_format($value, 2, '.', ''); $value = $value * $multiplier; $value = number_format($value, 2); echo "$$value<br />"; }
Is it just me or is anyone else having problems with the site? When I make a reply to a post and submit it, my post is added but it also appears as an edit window still below my just-posted post. Also - when I try and edit my post the edit window opens up but the text of my post flashes by and does not show. If I re-type the entire post with my edits and save it, the edits do not appear. This has been happening for 3-4 days now. Edited by ginerjm, 30 December 2014 - 01:33 PM. Hey guys I am trying to read my xml file and itterate through the list. I am having trouble.
<?xml version="1.0" encoding="UTF-8"?> <stock> <itemPlace id="1"> <name>null</name> <image>null</image> <wholeSale>44</wholeSale> <retailPrice>null</retailPrice> <quantity>null</quantity> <location>null</location> <color>null</color> <size>null</size> <weight>null</weight> <description>null</description> <itemType>null</itemType> <date>null</date> </itemPlace> <itemPlace id="2"> <name>null</name> <image>null</image> <wholeSale>55</wholeSale> <retailPrice>null</retailPrice> <quantity>null</quantity> <location>null</location> <color>null</color> <size>null</size> <weight>null</weight> <description>null</description> <itemType>null</itemType> <date>null</date> </itemPlace> </stock> <?php $xml = simplexml_load_file('stock.xml'); foreach ($xml->xpath('itemPlace') as $eq) { echo "<p><a class='inline' href=\"#inline_content\"> {$eq->name}</a></p>"; echo '<br>'; echo " <div style='display:none'>"; echo " <div id='inline_content' style='padding:10px; background:#fff;'>"; echo " <p>"; echo " <strong>{$eq->wholeSale}</strong>"; echo "</div></div>";Is there a way I can look up the object through the itemPlace id="#" and call out the parameters of the item? Like the name price, etc? I know how to mySQL query but not XML, and this is a project that needs to use xml... FML..I have been looking for a few hours so any help would be appreciated! I'm currently in the middle of rewriting my website and have run into a little trouble.
When floating the unordered list to the right, the span no longer displays inline, despite having the unordered list's display to "inline".
Here's an image to show you what I mean:
Here's the markup:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <head> <title>Matthew Noskiw's website</title> <link rel='stylesheet' type='text/css' href='./inc/CSS/styles/default.css' /> <link rel='stylesheet' type='text/css' href='./inc/CSS/static/navigation.css' /> </head> <body> <div id='Container'> <div id='Header'> <div style='float: right'> <ul id='Navigation'> <li id='NavButton' class='active'><a href='./'>Home</a></li> <li id='NavButton'><a href='./about'>About</a></li> <li id='NavButton'><a href='./blog'>Blog</a></li> <li id='NavButton'><a href='./contact'>Contact</a></li> </ul> </div> <span>noskiw.co.uk</span> </div> </div> </body> </html>Specifically, this section: <div id='Container'> <div id='Header'> <div style='float: right'> <ul id='Navigation'> <li id='NavButton' class='active'><a href='./'>Home</a></li> <li id='NavButton'><a href='./about'>About</a></li> <li id='NavButton'><a href='./blog'>Blog</a></li> <li id='NavButton'><a href='./contact'>Contact</a></li> </ul> </div> <span>noskiw.co.uk</span> </div> </div>And here is the CSS: body { font-family: arial; font-size: 14px; color: #000000; } #Container { width: 800px; border: 1px solid #000000; margin: 0 auto; padding: 3px; } #Header { overflow: hidden; border: 1px solid #000000; padding: 5px; }Any help will be appreciated, thanks. This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=342058.0 I created an array using the array_diff function and it worked fine. My resulting array has lots of keys/values (like teamid, teamname, teamcity). I want to now display the teamid and teamcity as options in an HTML SELECT menu. I thought I would do something like this below, but it's only giving me the teamid (NOTE, I left out the Select tags because I'm good with that part of it ). How do I write the code to get the teamcity to show as well? Obviously doing something very wrong Code: [Select] $remainingteams = array_diff($allteams, $chosenteams); foreach($remainingteams as $teamid => $value){ echo "<option>" . $teamid . "-" . $remainingteams['teamcity'] . "</option>"; } Hi, My mother-in-law asked me to check on her laptop (win8) and I tried but was unable to find a solution. The problem is that the hard-drive is at a constant 100% which makes the laptop really slow except in safe mode. Process list shows no process using 100% of the hdd, I already did a chkdsk and it returned no errors. I suspect it's due to the task scheduler and stopping the active tasks indeed lowers the hdd usage to 6-11% but it does not remain there probably because new tasks are started. I also removed several software which I suspected were the ones creating the tasks to no avail. It appears as if Windows itself is running tasks that slow down the laptop to a crawl, but disabling task scheduler does not seem a good idea. Any ideas? $titleurl = preg_replace('/[^a-zA-Z0-9_ -%]/', '-', $d); $titleurl = preg_replace('/[ ]/', '-', $titleurl); How do you add to this to replace ---- with - --- with - -- with - and remove quotes? How do you remove a - if it's at the very end of $titleurl. For example, replace My-iPhone- with My-iPhone |