Jump to content

Search the Community

Showing results for tags 'PHP'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Found 982 results

  1. Hi All, I need to login to zoho crm using a url which will be in my own site. But i am unable to do this as i read the zoho api, i got confused and i am not getting a right way to go forward. I need some code example or any good tutorial. Thanks,
  2. Hello all. Been away from working on my website for some time now but I have decieded now that I have a job which will start 1st October that I should get the site finished off. Im intending on coding a email form for the site but seem to be stuck installing and working with Wampserver and PHP-5.4.6. Wampserver says put PHP files into my \wamp\www location but when I do it does nothing and wampserver just stays offline and when going to localhost it goes oops nothing there on google chrome Please help as I know I need PHP installed before I can attempt to learn to code it. Its got to be something silly im doing but I cannot see it Thanks for taking the time to read this post. Richard
  3. Net123

    how they do it

    hello anyone could please explain me how they doing this ?AUTOLOGIN URLhttp://wapzan.com/au...ODYzN2M3/229700 MAIN EDITORhttp://wapzan.com/ed...k3M/root/395384 i having a doubt for a long time how they doing up this "how they ordering codes one by one "?i know they used mysql for order these kinds but what is their basic program for order one by onelike if there was in (Main EDITOR)1st code2nd code3rd code4th code if i tried a insert some codes before 2nd they moving all the things to afterwards ....they doing this again and again really what was happening inside how they marking this orders ???
  4. Hi I want to access javascript vaibale in PHP on the same page. How it can be possible?Anybody can help? Thanks.
  5. `Am doing small project on Php.I need to show the address(output) on google map.and .,I need to show recently requested pincodes also.please help.... thanks in advance.. this is my code---------------------------
  6. How to display recent searches on a web page using php.......need help Thanks in advance
  7. BigD

    different behavior

    My code ran ok on my PC, ran differently after I uploaded to web server. The code checks if user in database. brings up std.php if it is.On web server it passed the check but failed to bring up std.php. it just sits there. <?phpsession_start();include ("mylibrary/login.php");login();$userid = $_POST['userid'];$password = $_POST['password'];$query = "SELECT stdid, classid, lastname, firstname from student where userid = '$userid' and password = '$password'";$result = mysql_query($query);if (mysql_num_rows($result) == 0){ echo "<h2>Sorry, your account was not validated.</h2><br>\n"; echo "<a href=\"std.php\">Try again</a><br>\n";} else{ $_SESSION['store_admin'] = $userid; header("Location: std.php");}?>
  8. How to connect notepad++ to xamp..........,am unable to get output,,,I got output using same php file in (dreamweaver to xamp) please help...
  9. I used a select statement and found a record in DB, When I tried to update the record, returned 0 rows and not updated. Here is the code. Please help.$query="SELECT classtype,startdate,enddate,classstatus from class where classname = '$classnameval'"; $result = mysql_query($query); echo "select class sql $query</br>"; $num_rows = mysql_num_rows($result); if (!$num_rows) { echo nl2br("Class $classname not in DB\n"); goto bye; } if ($result) { $row = mysql_fetch_array($result, MYSQL_ASSOC); $classtypeo = $row['classtype']; $classstatuso = $row['classstatus']; $sdateo = $row['startdate']; $edateo = $row['enddate']; echo "<h2>Class '$classname' found</h2>\n";var_dump($classstatuso,$sdateo,$edateo,$classtypeo); } else { echo "<h2>Sorry, unable to change class $classname </h2>\n"; goto bye; }var_dump($classstatusval,$sdate,$edate,$classtype); if ($classstatusval == '') $classstatusval = $classstatuso; if ($classtype == '') $classtype = $classtypeo; if ($edate == '') $edate = $edateo; if ($sdate == '') $sdate = $sdateo; $query="UPDATE class SET classstatus = '$classstatusval', startdate = '$sdate', enddate = '$edate', classtype = '$classtype', where classname = '$classnameval'"; $result = mysql_query($query); echo "update class sql $query</br>"; $num_rows = mysql_num_rows($result); if (!$num_rows)// if (!$mysql_num_rows($result)) { echo nl2br("Class $classname not in DB\n"); goto bye; }
  10. At the beginning i thought that i should double click it to open it but it didn't work,i installed Apache and php, but i don't know anything about how to use them and even why i installed them, just followed the tutrial,so can you please explain to me what do i do because ... the php tutorial is extremely good like any other in w3schools,i am 13 years old and i got how to write scripts but not how to run them,so please explain how to.
  11. Hello W3S people again. once again im in a little need of help. at least to get it started, im a little lost in this matter...im in the half-way exams at this week. and we got told to make a admin system that could upload images to products... that part i (CAN) do...but here comes my problem... i dont know the part of resizing the images...any ideas or suggestions would be pretty awsome! and thats not for kidding...i just need a little help for the beginning of it, so i can see the syntax... Hoping answers or suggestions soon!... thanks alot in advance! .
  12. sepoto


    I have this code that does some AJAX to go back into my database and extract an array of bars. I have developed the code to change one of my div's to display all the data for each bar. In addition to displaying the data I also need to modify the contents of #latestFromDSGbuffer to contain a twitter feed of 5 tweets each per bar that was queried. I have tried a number of samples but for some reason I am able to get the twitter samples working in a sandbox but when I try to integrate that code things don't seem to be working out. I don't know if maybe that is because I was trying to call $.ajax(); inside of the callback function from another $.ajax(). Maybe the design needs to be modified? Maybe I should use some DOM storage to store barLocations? I'm wondering what to do with it. All of the data is located in "barLocations". Although I have attempted to make "barLocations" "global" I am not able to access it from within button.onclick where it is showing as "undefined". $.ajax({ url: 'ajax.php', data: { lat: results[0].geometry.location.lat(), lng: results[0].geometry.location.lng(), radius: radius }, type: 'post', success: function(output) { barLocations = $.parseJSON(output); //alert(obj[0].lat); /* So now that we have the JSON encoded array it has to be displayed into one of the div's probably below the map someplace */ var newInnerHTML = ""; for(var i = 0; i < barLocations.length; i++) { newInnerHTML = newInnerHTML + "<strong>" + barLocations[i].company + "</strong></br>"; newInnerHTML = newInnerHTML + barLocations[i].first_name + " " + barLocations[i].last_name + "</br>"; newInnerHTML = newInnerHTML + barLocations[i].street_address1 + "</br>" + barLocations[i].street_address2 + "</br>" + barLocations[i].city + "</br>"; newInnerHTML = newInnerHTML + "Phone: " + barLocations[i].phone_number + "</br>"; newInnerHTML = newInnerHTML + "Email: " + barLocations[i].email + "</br>"; newInnerHTML = newInnerHTML + "Website: " + barLocations[i].website + "</br>"; newInnerHTML = newInnerHTML + "<a href=\"standardprofile.php\" target=\"_blank\">Profile page >>>></a>"; newInnerHTML = newInnerHTML + "</br></br>"; } for (i = 0; i < barLocations.length; i++) { var markerImage = 'image/baricon.png'; marker = new google.maps.Marker({ position: new google.maps.LatLng(barLocations[i].lat,barLocations[i].lng), map: map, icon: markerImage, title: barLocations[i].company }); } if(barLocations.length > 0) { document.getElementById('divBarLocations').innerHTML = newInnerHTML; } } }); Thanks in advance for any help comments or commentary. Your input is most welcome... The whole code looks more like this: (function() { var map, geocoder, marker, infowindow, barLocations; window.onload = function() { $('#hdivBarLocations').hide(); // Creating a reference to the mapDiv var mapDiv = document.getElementById('map'); // Creating a latLng for the center of the map var latlng = new google.maps.LatLng(37.09, -95.71); // Creating an object literal containing the properties // we want to pass to the map var options = { center: latlng, zoom: 4, mapTypeId: google.maps.MapTypeId.ROADMAP }; // Creating the map map = new google.maps.Map(mapDiv, options); // Getting a reference to the HTML form var button = document.getElementById('addressButton'); // Catching the forms submit event button.onclick = function() { button.disabled = true; // Getting the address from the text input var address = document.getElementById('addressBox').value; var radius = document.getElementById('radialDistance').value; // Making the Geocoder call getCoordinates(address, radius); // Preventing the form from doing a page submit //return false; $('#hdivBarLocations').show(); } } // Create a function the will return the coordinates for the address function getCoordinates(address, radius) { // Check to see if we already have a geocoded object. If not we create one if(!geocoder) { geocoder = new google.maps.Geocoder(); } // Creating a GeocoderRequest object var geocoderRequest = { address: address } // Making the Geocode request geocoder.geocode(geocoderRequest, function(results, status) { // Check if status is OK before proceeding if (status == google.maps.GeocoderStatus.OK) { //Go back in for some data. document.getElementById('divBarLocations').innerHTML = "No bars found in your area..."; $.ajax({ url: 'ajax.php', data: { lat: results[0].geometry.location.lat(), lng: results[0].geometry.location.lng(), radius: radius }, type: 'post', success: function(output) { barLocations = $.parseJSON(output); //alert(obj[0].lat); /* So now that we have the JSON encoded array it has to be displayed into one of the div's probably below the map someplace */ var newInnerHTML = ""; for(var i = 0; i < barLocations.length; i++) { newInnerHTML = newInnerHTML + "<strong>" + barLocations[i].company + "</strong></br>"; newInnerHTML = newInnerHTML + barLocations[i].first_name + " " + barLocations[i].last_name + "</br>"; newInnerHTML = newInnerHTML + barLocations[i].street_address1 + "</br>" + barLocations[i].street_address2 + "</br>" + barLocations[i].city + "</br>"; newInnerHTML = newInnerHTML + "Phone: " + barLocations[i].phone_number + "</br>"; newInnerHTML = newInnerHTML + "Email: " + barLocations[i].email + "</br>"; newInnerHTML = newInnerHTML + "Website: " + barLocations[i].website + "</br>"; newInnerHTML = newInnerHTML + "<a href=\"standardprofile.php\" target=\"_blank\">Profile page >>>></a>"; newInnerHTML = newInnerHTML + "</br></br>"; } for (i = 0; i < barLocations.length; i++) { var markerImage = 'image/baricon.png'; marker = new google.maps.Marker({ position: new google.maps.LatLng(barLocations[i].lat,barLocations[i].lng), map: map, icon: markerImage, title: barLocations[i].company }); } if(barLocations.length > 0) { document.getElementById('divBarLocations').innerHTML = newInnerHTML; } } }); circ = null; var circ = new google.maps.Circle({ map: map, radius: radius * 1609.344 }); circ.setCenter(results[0].geometry.location); // Center the map on the returned location map.setCenter(results[0].geometry.location); map.fitBounds(circ.getBounds()); google.maps.event.trigger(map,'dragend'); var markerImage = 'image/home.png'; // Check to see if we've already got a Marker object if (!marker) { // Creating a new marker and adding it to the map marker = new google.maps.Marker({ map: map, icon: markerImage }); } // Setting the position of the marker to the returned location marker.setPosition(results[0].geometry.location); // Check to see if we've already got an InfoWindow object if (!infowindow) { // Creating a new InfoWindow infowindow = new google.maps.InfoWindow(); } // Creating the content of the InfoWindow to the address // and the returned position var content = '<span style="color: black;">Your location.</span>'; // Adding the content to the InfoWindow infowindow.setContent(content); // Opening the InfoWindow infowindow.open(map, marker); } }); }})();
  13. I write code for a school. Today someone changed my screen layout. Happened after I downloaded Soda PDF 3D Reader software. my screen attached. Classes and Graduates changed color, becaome clickable anchor and will re-direct to some site. My code generated the screen remains the same. Anyone seeing this before?
  14. <!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>Pincode search</title></head><body><form method="post"action="index.php"><input type="hidden" name="submitted"value="true"/><label>search category:<select name="category"><option value="PINCODE">PINCODE</option><option value="AREANAME">AREANAME</option><option value="STATE">STATE</option></select></label><label>search criteria:<input type="text" name="Criteria"/></label><input type="submit"/></form><?phpif(isset($_POST['submitted'])){include('connect.php');$category =$_POST['category'];$criteria =$_POST['criteria'];$query ="SELECT * FROM pincodesearch WHERE $category LIKE '%".$criteria."%'";$result = mysqli_query($dbcon, $query) or die('error getting data');$num_rows =mysqli_num_rows($result);echo"$num_rows results found";echo"<table>";echo"<tr> <th>PINCODE</th> <th>AREANAME</th> <th>STATE</th> </tr>";while ($row=mysqli_fetch_array($result,MYSQLI_ASSOC)){echo "<tr><td>";echo $row['PINCODE'];echo"</td><td>";echo $row['AREANAME'];echo"</td><td>";echo $row['STATE'];echo"</td><tr>";}echo"</table>"; } ?> </body></html> ------------------------------------------------------------------------------------------ Notice: Undefined index: criteria in C:\xampp\htdocs\project3\index.php on line 24error getting data-------------------- Getting error.... please help.......................
  15. I have this code from another programmer: function getHours($time, $day, $close){ if(!$close){ $hours = <<<htmltext <option value="1" {$time[$day]['hours1']} >1</option> <option value="2" {$time[$day]['hours2']} >2</option> <option value="3" {$time[$day]['hours3']} >3</option> <option value="4" {$time[$day]['hours4']} >4</option> <option value="5" {$time[$day]['hours5']} >5</option> <option value="6" {$time[$day]['hours6']} >6</option> <option value="7" {$time[$day]['hours7']} >7</option> <option value="8" {$time[$day]['hours8']} >8</option> <option value="9" {$time[$day]['hours9']} >9</option> <option value="10" {$time[$day]['hours10']} >10</option> <option value="11" {$time[$day]['hours11']} ">11</option> <option value="12" {$time[$day]['hours12']} ">12</option>htmltext;} It's good code but I need there to be an isset() happening somehow. I am currently working on the problem but I am not fully sure yet on the significance of the { }'s here and if I can just add an: { if(isset($time[$day]['hours1'])) echo $time[$day]['hours1']; } I'm not sure if that direct change would work but I'm about to find out. I am trying to change the code as little as possible and I would prefer not to change my php.ini settings. I actually like being warned if my variables are not set (call me crazy!). Love this forum by the way! Thanks....
  16. So I have been studying this code and I have read a bit about the callback function: xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4) { HandleResponse(xmlHttp.responseText); } } is asynchronous although I'm not fully sure exactly what that means to me at this point. Essentially I am starting with a page bars.php: <!DOCTYPE html><html><head><title>Daily Sports Guide Bars</title><link type="text/css" rel="stylesheet" href="style/style.css"><link type="text/css" rel="stylesheet" href="style/suckerfish.css"><style>#map { width: 80%; height: 500px; border: 1px solid #000; margin-left: 10%; }</style><script type="text/javascript" src="js/ajax.js"></script><script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script><script>(function() { window.onload = function() { var responseText = MakeRequest(); alert(responseText); // Creating a reference to the mapDiv var mapDiv = document.getElementById('map'); // Creating a latLng for the center of the map var latlng = new google.maps.LatLng(37.09, -95.71); // Creating an object literal containing the properties // we want to pass to the map var options = { center: latlng, zoom: 4, mapTypeId: google.maps.MapTypeId.ROADMAP }; // Creating the map var map = new google.maps.Map(mapDiv, options); }})();</script></head><body><div id="wrapper"><?php require('includes/i_header.php'); ?><div style='margin: 0px; padding: 0px; text-align: center;'><img height="100" width="413" src="image/underconstruction.gif"></div><div id="map"></div><?php require('includes/i_footer.php'); ?></div></body></html> So I guess the first thing would be to also list the contents of my ajax.js: function getXMLHttp(){ var xmlHttp try { //Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch(e) { //Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert("Your browser does not support AJAX!") return false; } } } return xmlHttp;} function MakeRequest(){ var xmlHttp = getXMLHttp(); xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4) { HandleResponse(xmlHttp.responseText); } } xmlHttp.open("GET", "ajax.php", true); xmlHttp.send(null); return xmlHttp.responseText;} function HandleResponse(response){ alert(response);} I am not sure at all of my design here but my intent would be (in bars.php that is): var responseText = MakeRequest();alert(responseText); in this case to get MakeRequest to return into 'responseText' the value in ajax.php which is: <?phpecho "This is a php response to your request!!!!!!";?> So maybe it just is not the right design or maybe I just can't make this work because I don't really understand the internals of it all yet. I do get the first alert from HandleResponse however what I can't figure out is how to get that data back into my mapping area. How should this be done? Thanks so much. As always any help from the forums is most welcome.
  17. how to make text watermark in a video file ??? i was assigned in a video project that i dont know about text watermarking my customer dont want image watermarking he want text watermarking that how would i do it i also googles about it but every tutorials are only about image watermark my server was linux can anyone could help me ............
  18. yoyo w3s...im having a little trouble with my login page... here you can see the example: http://speed-scene.c...scene/login.php anyways, i allready knew about sessions and such, so i was thinking that it was time to expand my knowledge a little. so i was trying to make a login page that was using cookies to log me in, and while expanding, i was thinking that i could try it out on one of my projects on the following link i have allready given. but the trouble is that when im trying to login, then im just staying at the same page, and nofthing by then happends... here is all my login codes/pages im using: 1. bittorrent.php inside include folder from root (The functions im using to get the login thing to work...): function dbconn($autoclean = false){global $SS;if (!@mysql_connect($SS['mysql_host'], $SS['mysql_user'], $SS['mysql_pass'])){ switch (mysql_errno()) { case 1040: case 2002: if ($_SERVER['REQUEST_METHOD'] == "GET") die("<html><head><meta http-equiv='refresh' content=\"5 $_SERVER[REQUEST_URI]\"></head><body><table border='0' width='100%' height='100%'><tr><td><h3 align='center'>The server load is very high at the moment. Retrying, please wait...</h3></td></tr></table></body></html>"); else die("Too many users. Please press the Refresh button in your browser to retry."); default: die("[" . mysql_errno() . "] dbconn: mysql_connect: " . mysql_error()); }}mysql_select_db($SS['mysql_db']) or die('dbconn: mysql_select_db: ' . mysql_error());//mysql_query("SET NAMES utf8");mysql_set_charset('utf8');userlogin();if ($autoclean) register_shutdown_function("autoclean");} /*LOGIN FUNCTIONS*/function sqlesc($x) {return "'".mysql_real_escape_string($x)."'";}function mkglobal($vars) {if (!is_array($vars))$vars = explode(":", $vars);foreach ($vars as $v) {if (isset($_GET[$v])) $GLOBALS[$v] = unesc($_GET[$v]);elseif (isset($_POST[$v])) $GLOBALS[$v] = unesc($_POST[$v]);else return 0;}return 1;}function set_mycookie( $name, $value = "", $expires_in = 0, $sticky = 1 ){ global $SS; if ( $sticky == 1 ){ $expires = time() + 60*60*24*365;} else if ( $expires_in ) { $expires = time() + ( $expires_in * 86400 ); } else { $expires = FALSE; } $SS['cookie_domain'] = $SS['cookie_domain'] == "" ? "" : $SS['cookie_domain']; $SS['cookie_path'] = $SS['cookie_path'] == "" ? "/" : $SS['cookie_path']; if ( PHP_VERSION < 5.2 ) { if ( $SS['cookie_domain'] ) { @setcookie( $SS['cookie_prefix'].$name, $value, $expires, $SS['cookie_path'], $SS['cookie_domain'] . '; HttpOnly' ); } else { @setcookie( $SS['cookie_prefix'].$name, $value, $expires, $SS['cookie_path'] ); }}else{ @setcookie( $SS['cookie_prefix'].$name, $value, $expires, $SS['cookie_path'], $SS['cookie_domain'], NULL, TRUE );}}function logincookie($id, $passhash, $updatedb = 1, $expires = 0x7fffffff){set_mycookie( "uid", $id, $expires );set_mycookie( "pass", $passhash, $expires );if ($updatedb) @mysql_query("UPDATE users SET last_login = ".TIME_NOW." WHERE id = $id");}function logoutcookie() {set_mycookie('uid', '-1');set_mycookie('pass', '-1');}function loggedinorreturn() {global $CURUSER, $SS;if (!$CURUSER){ header("Location: {$SS['baseurl']}/login.php?returnto=" . urlencode($_SERVER["REQUEST_URI"])); exit();}}function get_mycookie($name){global $SS; if (isset($_COOKIE[$SS['cookie_prefix'].$name]) AND !empty($_COOKIE[$SS['cookie_prefix'].$name])) { return urldecode($_COOKIE[$SS['cookie_prefix'].$name]); } else { return FALSE; }}function userlogin() {global $SS;unset($GLOBALS["CURUSER"]);$ip = getip();$nip = ip2long($ip);require_once "cache/bans_cache.php";if(count($bans) > 0){foreach($bans as $k) { if($nip >= $k['first'] && $nip <= $k['last']) { header("HTTP/1.0 403 Forbidden"); print "<html><body><h1>403 Forbidden</h1>Unauthorized IP address. Please, piss off... you had your chance.</body></html>\n"; exit(); }}unset($bans);}if (!$SS['site_online'] || !get_mycookie('uid') || !get_mycookie('pass'))return;$id = 0 + get_mycookie('uid');if (!$id || strlen( get_mycookie('pass') ) != 32)return;$res = mysql_query("SELECT * FROM users WHERE id = $id AND enabled='yes' AND status = 'confirmed'");// or die(mysql_error());$row = mysql_fetch_assoc($res);if (!$row)return;if (get_mycookie('pass') !== $row["passhash"])return;mysql_query("UPDATE users SET last_access='" . TIME_NOW . "', ip=".sqlesc($ip)." WHERE id=" . $row["id"]);// or die(mysql_error());$row['ip'] = $ip;$GLOBALS["CURUSER"] = $row;}/*LOGIN FUNCTIONS*/ 2. this is my password_functions.php file inside include folder from root: <?phpfunction mksecret($len=5){ $salt = ''; for ( $i = 0; $i < $len; $i++ ) { $num = rand(33, 126); if ( $num == '92' ) { $num = 93; } $salt .= chr( $num ); } return $salt;} function make_passhash_login_key($len=60){ $pass = mksecret( $len ); return md5($pass);} function make_passhash($salt, $md5_once_password){ return md5( md5( $salt ) . $md5_once_password );} function make_password(){ $pass = ""; $unique_id = uniqid( mt_rand(), TRUE ); $prefix = mksecret(); $unique_id .= md5( $prefix ); usleep( mt_rand(15000,1000000) ); mt_srand( (double)microtime()*1000000 ); $new_uniqueid = uniqid( mt_rand(), TRUE ); $final_rand = md5( $unique_id.$new_uniqueid ); mt_srand(); for ($i = 0; $i < 15; $i++) { $pass .= $final_rand{ mt_rand(0, 31) }; } return $pass; }?> 3. this is my login.php file from root: <?phprequire_once("include/bittorrent.php");echo stdhead("Login");?> <form method="post" action="takelogin.php"><table class="login_table" align="center" border="1"><tr><td>Username</td><td><input type="text" name="username" id="username" size="35" /></td></tr><tr><td>Password</td><td><input type="password" name="password" id="password" size="35" /></td></tr><tr><td align="center" colspan="2"><input type="submit" name="login_submit" value="Login Now!" /></td></tr></table></form> <?phpecho stdfooter();?> 4. and at last, this is my takelogin.php file from root: <?phprequire_once 'include/bittorrent.php';require_once "include/password_functions.php";echo stdhead("Login");if (!mkglobal('username:password'))die();dbconn();$lang = array_merge(load_language('takelogin'));$res = mysql_query("SELECT id, passhash, secret, enabled FROM users WHERE username = " . sqlesc($username) . " AND status = 'confirmed'");$row = mysql_fetch_assoc($res);if (!$row)stderr($lang['tlogin_failed'], 'Username or password incorrect');if ($row['passhash'] != make_passhash($row['secret'], md5($password)))stderr($lang['tlogin_failed'], 'Username or password incorrect');if ($row['enabled'] == 'no')stderr($lang['tlogin_failed'], $lang['tlogin_disabled']);logincookie($row['id'], $row['passhash']);header("Location: {$SS['baseurl']}/index.php");echo stdfooter();?> and now to the big question, what the heck is wrong since i cannot login?... ideas where to check... it seems for my eye that i cannot see where to edit, since its all looking pretty well for both me and 1 other guys online i am coding with sometimes ... but the login does not work, so it is obviously that the codes does not either...but in anyways... i would be very much happy if anyone in here could tell me where to have my eyes on... thanks alot! ... PS: if wish to see the whole project, then you can use the following .FTP user to grand acces to the server and read the files, just in case you need more information.. HOST: blackbitt.comUSER: ftp_reader@blackbitt.comPASS: Reader1PORT: 21 bittorrent.php file is the main design to the whole site, and all my functions. in this way i have maked a Global Based design... Hoping you guys once more can guid me on to the right road again, thanks alot in advance! ...
  19. i was trying to have a code from which i can upload the files on server via php and i got this code below from w3school but its not working can u help me with thisthanks_________________________________________________________ <?php$allowedExts = array("jpg", "jpeg", "gif", "png");$extension = end(explode(".", $_FILES["file"]["name"]));if ((($_FILES["file"]["type"] == "image/gif")|| ($_FILES["file"]["type"] == "image/jpeg")|| ($_FILES["file"]["type"] == "image/pjpeg"))&& ($_FILES["file"]["size"] < 20000))&& in_array($extension, $allowedExts)){if ($_FILES["file"]["error"] > 0){echo "Return Code: " . $_FILES["file"]["error"] . "<br />";}else{echo "Upload: " . $_FILES["file"]["name"] . "<br />";echo "Type: " . $_FILES["file"]["type"] . "<br />";echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";if (file_exists("upload/" . $_FILES["file"]["name"])){echo $_FILES["file"]["name"] . " already exists. ";}else{move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"]);echo "Stored in: " . "upload/" . $_FILES["file"]["name"];}}}else{echo "Invalid file";}?>
  20. rathish

    Barcode in Webpage

    hi am new to php..am doing a project for my college, which collects staff details and generate id card.the problem am facing is the size of id card changes depends up on the input data..and pls tell the easiest way to display staff id in barcode font.. i cant use barcode font in webpage..so pls help me on these issues thank you,,
  21. hey guys Basically i am trying to create a validation for the form. I want it to check if it can connect to the DB and if true to proceed to another page and if false to return an error. I am inputting the wrong details to make it just display the error but somehow it always returns "TRUE" on page load... and everytime i click the submit it doesnt do anything regardless of my entry... Can anyone tell me why? <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(function(){var u = $('#username');var s = $('#server');var p = $('#password'); $('#iValForm').submit($.post("connect.php", {u: u.val(),p: p.val(),s: s.val()}, function(fd){ if (fd == "true"){ alert("Is: " + fd); return false; } // if1 if (fd == "false"){ alert("Is2: " + fd); return false; } // if2} //post function) //Post) //submit }) //document </script></head> <body> <form class="iValForm" id="iValForm" method="post" action=""><fieldset><legend id="error"> </legend><p><label for="username">Username </label><input id="username" name="username" class="required" /> </input></p><p><label for="password">Password</label> <input id="password" name="password" class="required"/> </input></p><p><label for="server">Server</label> <input id="server" name="server" class="required"/> </input></p><p> <input class="submit" id ='submit' type="submit" value="Submit"/></p></fieldset></form> connect.php <?php$user = $_POST['u'];$password = $_POST['p'];$server = $_POST['s'];@$con = mysql_connect ($server, $user, $password); if (!$con) {$response = 'false';echo $response;} else { $response = 'true'; echo $response;}?>
  22. ckrudelux

    Project Blog

    IntroductionSo I finally decide to have a go with this idea of having a project blog I'm really bad at this sort of thing and often find my self working for hours not writing a single line of comment to my code.. I don't find it necessary cause my naming often tells what it does so I don't see the point typing out the same thing the name says. But maybe I just lake the guide lines of typing comments.. read once that if you have to think twice about what a code you written does you need a comment for it. I will be doing a MVC pattern system. I've already started with this project so the first post will be covering what I've done so far. I encourage to comment any spelling or miss use of words since English isn't my main language and it would be good to get some improvements.To be clear the questions I have in my post are meant for me and I don't expect on you answering them for me. So who am I? Well I'm Andreas, I've been a member since 2008 I know I'm not the most active user I usually ask questions to small thing I don't now how to search for or then I just got completely stuck at some code error. Lets get started.So to get things in motion I'm using a class I call a Mapper class and it's task is to register paths to a controller and method. I get the path from the global $_SERVER['PATH_INFO'] variable which takes everything after "index.php" so "index.php/blog/posts/entry" would be "/blog/posts/entry". I had no intention of having any SQL queries into this class but I soon realized that I had to have a "registerMap" method to the class so I could set paths from a controller or model classes.Only problem with using this mapper method is that I can't do pages like "blog/posts/entry/page/2" in the path so they are set as normal get keys. From the index file I define paths to various places including a web root which defines the index file location compared to the server root. This is good in case you want to put this code into a sub folder. The template engine i choose to use is Smarty, you can find it at http://smarty.net, I just find it easy to use. My abstract Controller class extends the Smarty class so I can set the data form the Controller class. I added a function to tell what template folder I want to use in my view directory.Another neat thing I did was to make a plugin for Smarty what inserts the CSS files to the head so I get less request to the server. I will change that later to handle JavaScript files too. I also have a ActiveUser class that handles the current user on the site. I like this class a lot cause of the way I use sessions with it. Since we aren't allowed to throw cookies at our visitor without any permission this class only starts the session if the session cookie is set and the cookie is only set then you login on the page. I mostly like this cause I've seen complains about just this problem then reading about that new law about cookies. I think that covers the basic introduction of that I've done without going into detail of the exact code looks like to the point there I'm now. The next step is to add an admin panel where I can add and remove users. And change settings to other component. Current issueSo this is about how I handle the users which isn't the active one like say I'm logged in and i want to change someone else user type. How should I get that object in the code.At the moment I can fetch users from the ActiveUser class but this feels wrong. Cause it's not within the task that is set for the ActiveUser class. So what I think the ActiveUser should handle is hold the current user id and type and have the responsibilities to create/update/remove users. (maybe change password and type for the current user but it feels like that should be in the User class)The User class extends the Person class and contains only one extra property which is the user type.Why I choose to not have the user name in the User class is cause I hashed the user name making it more time consuming if the database got out. I also written an abstract class for collections the idea is that the class could sett properties like limit the number of objects which would be returned or the sorting order of the query "ASC and DESC" (Maybe a random order would be a great thing to add). Problem with this Collection class is that it's not fully thought through. I've written some code that uses the concept but I find my self doing the same code over and over again mostly the only thing that is different is the query to the database unless the object has child objects to be loaded. I'm sure that I should get the users from a collection class i just don't know how to complete this collection class at the moment cause the case scenarios are too many. One example is that i can load a user from the user collection but since the user is a part of a person. The person data must be loaded to the object too. Question is should I add some sort of property in the person collection class to get the query for that specific table so I can add it to my object. Also what if the object I extends has child objects and how do get them, a public method for getting that particular property data set from that person. Well I think this will be all for this time.. hope this wasn't too confusing.
  23. (Based on earlier writings by "So Called" in this topic)1. Organization tips for all of programming 1.1. Start smallMake your big problems into little problems! Don't write 200 lines of code and then ask us why it doesn't work! Instead, write 10 or 20 lines of code and get that to work. Other things being equal, 20 lines of code will have 1/10 as many bugs as 200 lines of code. You are 10 times as likely to write good code if you write just a little not a lot, and 10 times more likely to have willing volunteers on the forum help you find out why it doesn't work. On a related note, don't write a whole mess of HTML, PHP and MySQL queries (even if it's well under 200 lines of code) and then ask yourself (or the forum) why it doesn't work. Write a few lines, test it, fix what's broke, then add more code. Don't add more complexity until you get what you've already written to work. This is the stage where you can expect help from an Internet forum. 1.2. Keep it readableSpeaking of creating a mess, avoid creating one by keeping your code readable. A lot of problems can be avoided or fixed quickly if you and other people can find their way around your code. You might have overlooked this as a "minor feature", but it's actually really important for this point - you can freely insert white space between different parts of your PHP code. This means you can (and should) insert white space wherever it makes logical sense. If you're not sure, err on the side of being with white space. For example, instead of <?php$f=$_GET['f'];$l=$_GET['l'];$r=0;for($i=0;$i<100;$i++) if($i%2===0||$i%5===0)$r+=$i;echo "$f $l: $r"; make that <?php$f = $_GET['f'];$l = $_GET['l']; $r = 0; for ($i = 0; $i < 100; $i++) if ($i % 2 === 0 || $i % 5 === 0) $r += $i; echo "$f $l: $r"; Also, use meaningful variable names that tell you what a variable is used for. For example, instead of the above, have it as <?php$firstName = $_GET['firstName'];$lastName = $_GET['lastName']; $result = 0; for ($i = 0; $i < 100; $i++) if ($i % 2 === 0 || $i % 5 === 0) $result += $i; echo "$firstName $lastName: $result"; And finally, if brackets/braces/whatever are allowed, but optional, use them anyway, to clearly define the intended boundaries, e.g.: <?php$firstName = $_GET['firstName'];$lastName = $_GET['lastName']; $result = 0; for ($i = 0; $i < 100; $i++) { if (($i % 2 === 0) || ($i % 5 === 0)) { $result += $i; }} echo "{$firstName} {$lastName}: {$result}"; If you search the web, you'll find different advises on how much and where should white spaces and brackets/braces be (e.g. some programmers prefer the opening bracket on a new line, while others prefer it on the same line as the statement - as above). No style is truly "better" than another. Whatever feels readable to you, use that. However, it's important to note: Whatever your preference is, be consistent. Don't use one style at one place, and another style at another place, as this makes your code harder to read.(Also worth noting: Some PHP editors allow you, with the click of a button, to automatically add white spaces according to predefined rules, so that at least the first part of what we did above is automated) 1.3. Probe your codeAsking for help on the forum may get you help in hours, days or sometimes weeks. But ask your code the same questions and you may get answers in seconds or (at worst) minutes! The remainder of this topic will address how you can ask your code to tell you why it won't work. These things are not "fixes", they're means to finding a fix (which is essentially what "debugging" means).
  24. Know what you are dealing with : ERROR AND EXCEPTION WHY THIS? When we debug our code that means we find errors and fix them. so it is wise to know about them whom we are dealing with GETTING STARTED:I cant see anything. where to find error?Errors will not always be visible to you. you will see what your php.ini setting is set to show. There is some directive which handle this behaviour.http://in2.php.net/m...en/ini.list.php find the directives here"display_error""error_reporting""error_log" (for error logging)You can set it in php.ini directly (Recomended for development server where you have access to them) or you can set it it using ini_set(). (extra reference)see the principle of changing configuration of php.inihttp://in2.php.net/m...nfiguration.phphttp://in2.php.net/m...anges.modes.php IF YOU USE INI_SET() , MAKE SURE IT IS THE TOP MOST CODE OF YOUR CODE OR INCLUDE/REQUIRE TREEError types: Syntactical error Runtime error Logical error Syntactical error: behaviour:This error means you are not following the grammer of PHP. you had mistaken somewhere that it can not parse your code. as it does not parse your code, this errors show you prior to running the code. so when you see thi error your code is not being run.How to fix them?It is the most easier to fix errors. it happends usually when we make typo or forgot to close braces or put expression terminator (";") etc. though when you see the error you have not to search your code randomly, php will tell you where to look for. the showed error line is not always the origin of the error.it could be prior to that line.READ THIShttp://in3.php.net/m...l/en/tokens.phphere you can see the list of avialable parser tokens. so next time when you will see them it won't be hard for you to fin the reason.prevention is better than cureYou can avoid much of parse error if you write well readable code followinga any code standard. likehttp://pear.php.net/...g-standards.phphttp://framework.zen...g-standard.html and using decent IDE(eg netbeans) or text editor(eg notepad++)http://netbeans.orghttp://notepad-plus-plus.org/Runtime Error:behaviour:Your code is gramatically right. your code has been parsed and it has turned into opcode. now it is time for running it. in runtime there may be such case arises when your program does not do what you expect. like you are trying to get an index of an array which does not exist, etchow to fix them?This is the part we spent mostly to debug our code. There is different level of error Fatal error Warning Notice Fatal error: as it is saying, it is fatal. when such error arised it exits the scripts. YOU MUST FIX IT Warning: It level is lower than Fatal error. but is origin of unexpected behaviour even can lead to fatal error. YOU MUST FIX ITNotice: Low level error. does not harm much. but can lead to higher level error. so YOU SHOULD FIX ITLogical error:behaviour:your code grammer is correct it runs well but it has problem with the logic. It is the hardes part of debugging codes. it is problem with your logic somewhere in the code, which prevent you to outputting expected result.How to fix?PHP cant help you with that. you have to do it yourself. you can do that by whitebox testing or blackbox testing. there is unit test for php which can also help you in that. How would i know so many different error?Runtime errors are documented in every function and method in. you will find that on the manual. when you see any error with particular function just go to manual and see what exception/error it can throw in certain situation. SOMETHING MODERATED:How to handle error?Error handling principle is not same in production and development enviourment. You would not like to show your code faults publicaly. would you? in that case you will log them somewhere instead of showing them.http://in.php.net/ma...n.error-log.phpthere is another option, recruite a error handler which will handle all the error as YOU WANT.http://php.net/set_error_handler I want to throw my own error. how to?there is trigger_error() which will let you throw your own error. remember user level error has also the three types, like Fatal error,warning,notice.check this for available error constant http://in.php.net/ma...c.constants.php TOWARD MORE ADVANCE:EXception?! what is it?Exception is a state where your code is not doing what you expected and you will have chance to terminate the program gracefully. as opposed to Errors which is state, unrecoverable(though there is conceptually difference in exception of php and other language like java. 'notice' and 'warning' is some kind of error but they are recoverable, program does not exist when they occurs)http://in2.php.net/m....exceptions.php Why we will use exception? why php API uses exception (eg PDO)?PHP already documented exception in their manual. there is no need to write down again. the most imporatnt features of exception is, it is CATCHABLE and it can BUBBLE UP. Most of newer API include exception for its robustness. It also needs less code to write. it is readable. People should use exception for error handling instead of old error handling methods (like $error=array()). is there any callback handler same as for error handler?yes there is.http://in.php.net/manual/en/function.set-exception-handler.php. it will also give you freedom to handle exception customacllyWe can catch exception. can we catch error?Yes we can. EVEN WE CAN CATCH THE FATAL ERROR. we can use error handler to catch error and then throw ErrorException. http://in.php.net/ma...orexception.php look at the example. errorException is also exception which extends exception class. they are intenteded for handling error with behaviour of exception. Why would i want to catch and throw errors?The answer is same, for the advantages of exception. a error may be thrown at bottom of the call stack. with exception or errorException you can catch in any level of call stack and show a gracefull error rather than terminating the application (incase of fatal error).Imagine a nonexistant file "require"ing breaking up your page in the middle. Notes:this is the summary of the story of error-exception for geting the concept. If there is any question and query about these, can post it in separate topic. if it needs to add something more or for any correction or improvements can PM me.the links are provided, have the depth information about what it is being posted here and posted links are meant to be followed. There is no any substitute for php manual itself.
  25. Hello Community I'm a newbie with coding , so i hope you guys can help me out so i have for example 3 iframe codes1. <iframe src="http://www.google.com"></iframe>2. <iframe src="http://www.yahoo.com"></iframe>3. <iframe src="http://www.bing.com"></iframe> so i want to shuffle these 3 iframes but i do not know how ?i have tryed using this code but a total fail <?php$iframe = array(); $iframe[0] = '<iframe src="http://www.google.com"></iframe>'; $iframe[1] = '<iframe src="http://www.yahoo.com"></iframe>'; $iframe[2] = '<iframe src="http://www.bing.com"></iframe>';shuffle($iframe);echo $iframe[0];?> it did not worked for me , do you have any idea how to get it work ? Regards
  • Create New...