Jump to content

Mr_J

Members
  • Posts

    188
  • Joined

  • Last visited

    Never

Everything posted by Mr_J

  1. Hi, When I login to my database, after I added an extra field on table, I get this warning: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/pharmacz/public_html/ads/inlogger.php on line 28 So I had another look at my code and I can't see anything wrong. So I searched google and the best article I could get is http://www.php.net/manual/en/function.mysql-num-rows.php Then I see it is a FUNCTION and I do not use my statement like the example shows This is line 28: $count=mysql_num_rows($result); //Must be 1 row this is all of the code: <?php $host="localhost"; $username="my_username"; $password="my_password"; $db_name="db_name"; $tbl_name="table_name"; mysql_connect("$host", "$username", "$password")or die("cannot connect to Server"); mysql_select_db("$db_name")or die("cannot select DATABASE"); $usr=$_POST['usr']; $pw=md5($_POST['pw']); $phname=$_POST['phname'];// To protect MySQL injection $type=$_POST['type']; $usr = stripslashes($usr); $pw = stripslashes($pw); $phname = stripslashes($phname); $type = stripslashes($type); $usr = mysql_real_escape_string($usr); $pw = mysql_real_escape_string($pw); $phname = mysql_real_escape_string($phname); $type = mysql_real_escape_string($type); $sql="SELECT * FROM $tbl_name WHERE username='$usr' and password='$pw' and phname='$phname' and type='$type'"; $result=mysql_query($sql); $count=mysql_num_rows($result); //must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file session_register("usr"); session_register("pw"); session_register("phname"); session_register("type"); header("location:secure.php"); //else //echo 'Wrong Username or Password<br/><a href="javascript:history.go(-1)"><input type="button" value="Back">'; } ?>
  2. OK! Sorry about the POST above... I spoke to my senior and he gave me more insight of what they want EXACTLY... AND It all makes sense... I will simply use a Database with a couple of tables defining the different services and as the end user login, he/she will get the data as he/she registered... Hope I can help someone else like this... Jaco AKA Mr_J
  3. Hi all, ********* ONLINE ACCOUNTING ********* I need to do a project but not to sure what (function/global/.../...) to use just to get off the ground. Any input will be appreciated... I have a Register & Login (using MySQL & Sessions) system that work and can login and view specific pages as user-rights apply. Now I need 2 get input from the user on what data he/she require: e.g. User input will be "Account Balance" data will display (print/echo) to .html from a (authorized) file on Server. a Second instance could be that the user need data from a certain Date range i.e. Transaction Detail (recorded Transaction no. etc.). I haven't started yet as I'm unsure what/where to start. I would use the $_REQUEST PreVar but not sure if it will work in the setup I'm planning Any input please Regards, Jaco
  4. Mr_J

    Validation W3.org

    After reading a bit, I see the way NOT to go is <marquee> I will rather change it into a style...
  5. I have corrected a couple of missing alt attributes but I have a marquee and some counters that return invalid... http://validator.w3.org/check?uri=http%3A%2F%2Fwww.turboautoclinic.co.za%2F&charset=%28detect+automatically%29&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.2 Any input on the marquee would be great
  6. After some Google-ing I found lots of articles. I managed to change my .htaccess file to: Options +ExecCGI -Indexes DirectoryIndex index.php index.html index.htm ### DEFAULTS ### ServerSignature Off AddType video/x-flv .flv AddType application/x-shockwave-flash .swf AddType image/x-icon .ico AddDefaultCharset UTF-8 DefaultLanguage en-US SetEnv TZ SouthAfrica/Klerksdorp SetEnv SERVER_ADMIN [email protected] ### FAST-CGI ### AddHandler fastcgi-script fcgi AddHandler php-cgi .php Action php-cgi /cgi-bin/php5-wrapper.fcgi # MONTH <FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf)$"> Header set Cache-Control "max-age=2592000" </FilesMatch> # WEEK <FilesMatch "\.(js|css|pdf|txt)$"> Header set Cache-Control "max-age=604800" </FilesMatch> # DAY <FilesMatch "\.(html|htm)$"> Header set Cache-Control "max-age=43200" </FilesMatch> Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?pharmacy.za.org/.*$ [NC] Source: http://www.evolt.org/ultimate_htaccess_examples Very interesting for me as webmaster who, by no doubt, need to learn much more than just html/php coding... Cheers Jaco
  7. Hi all, I was hacked and found after a week that the .htaccess file shows to Scl.html as start page. I have changed it to: Options all DirectoryIndex index.html AddType text/plain .php AddHandler server-parsed .php AddType text/plain .html When I enter the address in my browser, it shows my html code instead of the actual webpage. Any idea how to get it to show my web page? Regards,
  8. I did run it through the validator but it only returned the ALT tag as not there in the images... So I googled for buttons and I'm now using it as: <button type="button"...>Button Text</button> Only problem, I can't test it... but will ask my client to see if it works! Thanks everyone!!
  9. Hi all, www.turboautoclinic.co.za On my product page, I have categories/products in buttons. The button is a hyperlink. When using IE6, when I click the link, nothing happens. So I installed IE8 with the same result. Any special programing necessary for IE and Linking Buttons? I have Win7 installed and running IE9/Firefox. Everything is fine when I test it... <a href="page.html"><input type="button" value="Button 1"></a> Regards, EDIT All pages is .php as I use the date function but the site is HTML based
  10. Thanx RussellReal
  11. Guess there is some info available but from my own experience, I usually summarize what I need e.g. Site functionality. If you know what your requirements are, you can work according to that. Like a cart, I will use a cart folder, same with a gallery, if I use a Gallery viewer, I will use a Gallery folder and even more, I have an Images folder and a sub-folder for my index pics etc. It makes it easy for me when I change the site... Enjoy
  12. Hi all, I have a small script I found somewhere but after I changed hosting, it just stop to work. I just want to record the user IP and Referrer etc. in a .txt file using fopen. It helps to see what users searched for in search engine etc. The headers are there but no data... Please help?? session_start(); if($session["logged"] != "yes") { $agent = $_SERVER['HTTP_USER_AGENT']; $uri = $_SERVER['REUEST_URI']; $ip = $_SERVER['REMOTE_ADDR']; $ref = $_SERVER['HTTP_REFERER']; $visitTime = date("r"); $logLine = "$visitTime - IP: $ip || User Agent: $agent || Page: $uri || Refererrer: $ref\n\n"; $fp = fopen("indexLog.txt", "a"); fputs($fp, $logLine); fclose($fp); $_SESSION["logged"] = "yes"; } ?> Thanx in advance Jaco
  13. Hi all, My client have legal issues and I need to protect a directory so that only allowed user(s) can ALTER/WRITE to the directory. The problem is that it must display the .html / .php content to the public. Path = domain.com/sub-domain.com/directory2protect I have set file attributes to 744 but the main account can still access the directory and in browser view it is Forbidden. This is a contact form in html where I display an iframe So I have contact.html <iframe src='contact/form.php' > I need to protect the directory with a password and/or user before you can replace any document/file Will .htaccess work in a case like this? or do I need to use Apache? I have tried using the cPanel to protect the directory but again, the main user still have access... Any ideas? Regards
  14. can you add a link? will help to actually see... I'm newish to php as well and started using sessions just a while ago so its all still fresh in my mind
  15. The rand function will generate unique no's. You can use mt_rand as well. To make sure you always start from a different place in sequence, you have to seed the random number generator by calling the srand function - mt_srand
  16. <form action="yourPHPfile.php" method="post"> form stuff here <input type="submit" value="Send"> <!-- your button --> </form>
  17. just have a look at this... It is ready to save as .html and upload to site... <!-- * FCKeditor - The text editor for Internet - http://www.fckeditor.net * Copyright (C) 2003-2008 Frederico Caldeira Knabben * * == BEGIN LICENSE == * * Licensed under the terms of any of the following licenses at your * choice: * * - GNU General Public License Version 2 or later (the "GPL") * http://www.gnu.org/licenses/gpl.html * * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") * http://www.gnu.org/licenses/lgpl.html * * - Mozilla Public License Version 1.1 or later (the "MPL") * http://www.mozilla.org/MPL/MPL-1.1.html * * == END LICENSE == * * Test page for the "File Uploaders". --> <html> <head> <title>FCKeditor - Uploaders Tests</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript"> // Automatically detect the correct document.domain (#1919). (function() { var d = document.domain ; while ( true ) { // Test if we can access a parent property. try { var test = window.opener.document.domain ; break ; } catch( e ) {} // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ... d = d.replace( /.*?(?:\.|$)/, '' ) ; if ( d.length == 0 ) break ; // It was not able to detect the domain. try { document.domain = d ; } catch (e) { break ; } } })() ; function SendFile() { var sUploaderUrl = cmbUploaderUrl.value ; if ( sUploaderUrl.length == 0 ) sUploaderUrl = txtCustomUrl.value ; if ( sUploaderUrl.length == 0 ) { alert( 'Please provide your custom URL or select a default one' ) ; return ; } eURL.innerHTML = sUploaderUrl ; txtUrl.value = '' ; var date = new Date() frmUpload.action = sUploaderUrl + '?time=' + date.getTime(); if (document.getElementById('cmbType').value) { frmUpload.action = frmUpload.action + '&Type='+document.getElementById('cmbType').value; } if (document.getElementById('CurrentFolder').value) { frmUpload.action = frmUpload.action + '&CurrentFolder='+document.getElementById('CurrentFolder').value; } frmUpload.submit() ; } function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg ) { switch ( errorNumber ) { case 0 : // No errors txtUrl.value = fileUrl ; alert( 'File uploaded with no errors' ) ; break ; case 1 : // Custom error alert( customMsg ) ; break ; case 10 : // Custom warning txtUrl.value = fileUrl ; alert( customMsg ) ; break ; case 201 : txtUrl.value = fileUrl ; alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ; break ; case 202 : alert( 'Invalid file' ) ; break ; case 203 : alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ; break ; default : alert( 'Error on file upload. Error number: ' + errorNumber ) ; break ; } } </script> </head> <body> <table cellSpacing="0" cellPadding="0" width="100%" border="0" height="100%"> <tr> <td> <table cellSpacing="0" cellPadding="0" width="100%" border="0"> <tr> <td nowrap> Select the "File Uploader" to use: <br> <select id="cmbUploaderUrl"> <option selected value="asp/upload.asp">ASP</option> <option value="aspx/upload.aspx">ASP.Net</option> <option value="cfm/upload.cfm">ColdFusion</option> <option value="lasso/upload.lasso">Lasso</option> <option value="perl/upload.cgi">Perl</option> <option value="php/upload.php">PHP</option> <option value="py/upload.py">Python</option> <option value="">(Custom)</option> </select> </td> <td> Resource Type<br /> <select id="cmbType" name="cmbType"> <option value="">None</option> <option value="File">File</option> <option value="Image">Image</option> <option value="Flash">Flash</option> <option value="Media">Media</option> <option value="Invalid">Invalid Type (for testing)</option> </select> </td> <td> Current Folder: <br> <input type="text" name="CurrentFolder" id="CurrentFolder" value="/"> </td> <td nowrap> </td> <td width="100%"> Custom Uploader URL:<BR> <input id="txtCustomUrl" style="WIDTH: 100%; BACKGROUND-COLOR: #dcdcdc" disabled type="text"> </td> </tr> </table> <br> <table cellSpacing="0" cellPadding="0" width="100%" border="0"> <tr> <td noWrap> <form id="frmUpload" target="UploadWindow" enctype="multipart/form-data" action="" method="post"> Upload a new file:<br> <input type="file" name="NewFile"><br> <input type="button" value="Send it to the Server" onclick="SendFile();"> </form> </td> <td style="WIDTH: 16px"> </td> <td vAlign="top" width="100%"> Uploaded File URL:<br> <INPUT id="txtUrl" style="WIDTH: 100%" readonly type="text"> </td> </tr> </table> <br> Post URL: <span id="eURL"> </span> </td> </tr> <tr> <td height="100%"> <iframe name="UploadWindow" width="100%" height="100%" src="javascript:void(0)"></iframe> </td> </tr> </table> </body> </html>
  18. For some reason, MIME-Version1.0 rings a bell... :?
  19. I have a simple script where you can upload // download files of any ext. (incl .exe .scr etc) will it help you? Do you have a website etc. or server of some sort??
  20. I had my own error if the mail was sent or not and I changed it afterwords. At the moment it simply gives me a blank screen and I don't receive any mail...
  21. Hi, I found a couple of topics in the search on this but can't resolve my problem. I have a cart and want to mail it to myself and the client. The cart I'm using works fine but the moment I "check out" (mail the order) it gives a error. I build an error trap but see nothing wrong then I tried a different way to send the order in html with no avail. 6x files I use: Index.php -The products I'm selling and "add to chart" Cart.php - To update and display the products in the basket SendOrder.php - To mail the cart etc. to me and client as the main files and some functions, db connection and global's... 1) Index.php by Simon Mayer <?php // Start the session session_start(); // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); // Include functions require_once('inc/functions.inc.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>MedSET Store</title> <link rel="stylesheet" href="css/styles.css" > </head> <body> <div id="shoppingcart"> <h1>Your Shopping Cart</h1> <?php echo writeShoppingCart(); ?> </div> <div id="booklist"> <h1>Products</h1> <?php $sql = 'SELECT * FROM books ORDER BY id'; $result = $db->query($sql); $output[] = '<ul>'; while ($row = $result->fetch()) { $output[] = '<li>"'.$row['title'].'" by '.$row['author'].': £'.$row['price'].'<br /><a href="cart.php?action=add&id='.$row['id'].'">Add to cart</a></li>'; } $output[] = '</ul>'; echo join('',$output); ?> </div> </body> </html> 2)Cart.php by Simon Mayer <?php // Start the session session_start(); // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); // Include functions require_once('inc/functions.inc.php'); // Process actions $cart = $_SESSION['cart']; $action = $_GET['action']; switch ($action) { case 'add': if ($cart) { $cart .= ','.$_GET['id']; } else { $cart = $_GET['id']; } break; case 'delete': if ($cart) { $items = explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($_GET['id'] != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } $cart = $newcart; } break; case 'update': if ($cart) { $newcart = ''; foreach ($_POST as $key=>$value) { if (stristr($key,'qty')) { $id = str_replace('qty','',$key); $items = ($newcart != '') ? explode(',',$newcart) : explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($id != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } for ($i=1;$i<=$value;$i++) { if ($newcart != '') { $newcart .= ','.$id; } else { $newcart = $id; } } } } } $cart = $newcart; break; } $_SESSION['cart'] = $cart; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>MedSET Store</title> <link rel="stylesheet" href="css/styles.css" > </head> <body> <div id="shoppingcart"> <h1>Your Shopping Cart</h1> <?php echo writeShoppingCart(); ?> </div> <div id="contents"> <h1>Please check quantities...</h1> <?php echo showCart(); ?> <form action="sendOrder.php" method="post"> //I added the action file to handle the form <input type="submit" name="sendmail" value="Check Out" > </form> <p><a href="index.php">Continue Shopping...</a></p> </div> </body> </html> 2.1)MySQL.class.php <?php /** * MySQL Database Connection Class * @access public * @package SPLIB */ class MySQL { /** * MySQL server hostname * @access private * @var string */ var $host; /** * MySQL username * @access private * @var string */ var $dbUser; /** * MySQL user's password * @access private * @var string */ var $dbPass; /** * Name of database to use * @access private * @var string */ var $dbName; /** * MySQL Resource link identifier stored here * @access private * @var string */ var $dbConn; /** * Stores error messages for connection errors * @access private * @var string */ var $connectError; /** * MySQL constructor * @param string host (MySQL server hostname) * @param string dbUser (MySQL User Name) * @param string dbPass (MySQL User Password) * @param string dbName (Database to select) * @access public */ function MySQL ($host,$dbUser,$dbPass,$dbName) { $this->host=$host; $this->dbUser=$dbUser; $this->dbPass=$dbPass; $this->dbName=$dbName; $this->connectToDb(); } /** * Establishes connection to MySQL and selects a database * @return void * @access private */ function connectToDb () { // Make connection to MySQL server if (!$this->dbConn = @mysql_connect($this->host, $this->dbUser, $this->dbPass)) { trigger_error('Could not connect to server'); $this->connectError=true; // Select database } else if ( !@mysql_select_db($this->dbName,$this->dbConn) ) { trigger_error('Could not select database'); $this->connectError=true; } } /** * Checks for MySQL errors * @return boolean * @access public */ function isError () { if ( $this->connectError ) return true; $error=mysql_error ($this->dbConn); if ( empty ($error) ) return false; else return true; } /** * Returns an instance of MySQLResult to fetch rows with * @param $sql string the database query to run * @return MySQLResult * @access public */ function query($sql) { if (!$queryResource=mysql_query($sql,$this->dbConn)) trigger_error ('Query failed: '.mysql_error($this->dbConn). ' SQL: '.$sql); return new MySQLResult($this,$queryResource); } } /** * MySQLResult Data Fetching Class * @access public * @package SPLIB */ class MySQLResult { /** * Instance of MySQL providing database connection * @access private * @var MySQL */ var $mysql; /** * Query resource * @access private * @var resource */ var $query; /** * MySQLResult constructor * @param object mysql (instance of MySQL class) * @param resource query (MySQL query resource) * @access public */ function MySQLResult(& $mysql,$query) { $this->mysql=& $mysql; $this->query=$query; } /** * Fetches a row from the result * @return array * @access public */ function fetch () { if ( $row=mysql_fetch_array($this->query,MYSQL_ASSOC) ) { return $row; } else if ( $this->size() > 0 ) { mysql_data_seek($this->query,0); return false; } else { return false; } } /** * Returns the number of rows selected * @return int * @access public */ function size () { return mysql_num_rows($this->query); } /** * Returns the ID of the last row inserted * @return int * @access public */ function insertID () { return mysql_insert_id($this->mysql->dbConn); } /** * Checks for MySQL errors * @return boolean * @access public */ function isError () { return $this->mysql->isError(); } } ?> 2.2)Global.inc.php <?php $host = 'localhost'; $user = 'MyUserName'; $pass = 'MyPassword'; $name = 'MyDataBase'; $db = &new MySQL($host,$user,$pass,$name); ?> 2.3)Function.inc.php <?php function writeShoppingCart() { $cart = $_SESSION['cart']; if (!$cart) { return '<p>You have no items in your shopping cart</p>'; } else { // Parse the cart session variable $items = explode(',',$cart); $s = (count($items) > 1) ? 's':''; return '<p>You have <a href="cart.php">'.count($items).' item'.$s.' in your shopping cart</a></p>'; } } function showCart() { global $db; $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $output[] = '<form action="cart.php?action=update" method="post" id="cart">'; $output[] = '<table>'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM books WHERE id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $output[] = '<tr>'; $output[] = '<td><a href="cart.php?action=delete&id='.$id.'" class="r">Remove</a></td>'; $output[] = '<td>'.$title.' by '.$author.'</td>'; $output[] = '<td>£'.$price.'</td>'; $output[] = '<td><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>'; $output[] = '<td>£'.($price * $qty).'</td>'; $total += $price * $qty; $output[] = '</tr>'; } $output[] = '</table>'; $output[] = '<p>Grand total: <strong>£'.$total.'</strong></p>'; $output[] = '<div><button type="submit">Update cart</button></div>'; $output[] = '</form>'; } else { $output[] = '<p>You shopping cart is empty.</p>'; } return join('',$output); } ?> 3)SendOrder.php <?php $cart = $_SESSION['cart']; $to = "[email protected]"; $subject = "MedSET Order"; $message = "<html> <head> <title>Email Order<Title> </head> <body> This is my message in body </body>"; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= 'From: "email address" <an email existing on same server as shopping cart>' . "\r\n"; mail($to, $subject,$message,$headers,$cart); ?> Any help will be appreciated...
  22. Thank you Nightslyr, This is my first "commerce" site. Will fix it up... Regards
  23. the url... http://www.pharmacy.za.org/ads Test username: riek password: riek e-mail: [email protected]
  24. Hi I have a site that sell medical equipment. It is still in Progress but I need some critique... Known problems: Cross browser compatibility After submitting the order, the conformation page need a lot of attention and there is no pricing yet... There is a lot of "broken links" as well. I'm concerned about the way the PUBLIC have to go about to actually purchase the product(s) Regards
  25. It is a form I got from phpfmg.sourceforge.net/ I haven't touched the lib file...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.