Jump to content

spacepoet

Members
  • Posts

    320
  • Joined

  • Last visited

Everything posted by spacepoet

  1. Hi: Ahhhhh! OK, I see this now. Thanks for shpwing me this. I will assume that edit and insert are also called like that. Let me play around with it and see what I come up with. Thanks for your help!
  2. Hello: Thanks for the reply. I do have this is a password protected area, so I am OK there. "call the add_category() function with the new category name as a parameter." (same with edit and delete functions): Can you show me a coding example of how to call these functions? That's where my big problem is: They don't show an example and I don't know how to do it. Help...
  3. Hello: Certainly can do so. I'm really not much further along that what the tutorial lists. But, I like the gallery they have because it is simple and not over-bloated. But, they don't show how to create, edit, delete the categories or photos, which is a bit furstrating. Really, all I want to do it be able to make a category, and assign photos/photo captions to each category. And, edit or delete them as I need to. So, this is the database tables: CREATE TABLE gallery_category ( category_id bigint(20) unsigned NOT NULL auto_increment, category_name varchar(50) NOT NULL default '0', PRIMARY KEY (category_id), KEY category_id (category_id) ) TYPE=MyISAM; CREATE TABLE gallery_photos ( photo_id bigint(20) unsigned NOT NULL auto_increment, photo_filename varchar(25), photo_caption text, photo_category bigint(20) unsigned NOT NULL default '0', PRIMARY KEY (photo_id), KEY photo_id (photo_id) ) TYPE=MyISAM; This is the "preupload.php" page where you can select a photo and give it a caption: <?php include("config.inc.php"); // initialization $photo_upload_fields = ""; $counter = 1; // default number of fields $number_of_fields = 5; // If you want more fields, then the call to this page should be like, // preupload.php?number_of_fields=20 if( $_GET['number_of_fields'] ) $number_of_fields = (int)($_GET['number_of_fields']); // Firstly Lets build the Category List $result = mysql_query( "SELECT category_id,category_name FROM gallery_category" ); while( $row = mysql_fetch_array( $result ) ) { $photo_category_list .=<<<__HTML_END <option value="$row[0]">$row[1]</option>\n __HTML_END; } mysql_free_result( $result ); // Lets build the Photo Uploading fields while( $counter <= $number_of_fields ) { $photo_upload_fields .=<<<__HTML_END <tr> <td> Photo {$counter}: <input name=' photo_filename[]' type='file' /> </td> </tr> <tr> <td> Caption: <textarea name='photo_caption[]' cols='30' rows='1'></textarea> </td> </tr> __HTML_END; $counter++; } // Final Output echo <<<__HTML_END <html> <head> <title>Lets upload Photos</title> </head> <body> <form enctype='multipart/form-data' action='upload.php' method='post' name='upload_form'> <table width='90%' border='0' align='center' style='width: 90%;'> <tr> <td> Select Category <select name='category'> $photo_category_list </select> </td> </tr> <tr> <td> <p> </p> </td> </tr> <!-Insert the photo fields here --> $photo_upload_fields <tr> <td> <input type='submit' name='submit' value='Add Photos' /> </td> </tr> </table> </form> </body> </html> __HTML_END; ?> This is the "upload.php" page where the files upload: <?php include("config.inc.php"); // initialization $result_final = ""; $counter = 0; // List of our known photo types $known_photo_types = array( 'image/pjpeg' => 'jpg', 'image/jpeg' => 'jpg', 'image/gif' => 'gif', 'image/bmp' => 'bmp', 'image/x-png' => 'png' ); // GD Function List $gd_function_suffix = array( 'image/pjpeg' => 'JPEG', 'image/jpeg' => 'JPEG', 'image/gif' => 'GIF', 'image/bmp' => 'WBMP', 'image/x-png' => 'PNG' ); // Fetch the photo array sent by preupload.php $photos_uploaded = $_FILES['photo_filename']; // Fetch the photo caption array $photo_caption = $_POST['photo_caption']; while( $counter <= count($photos_uploaded) ) { if($photos_uploaded['size'][$counter] > 0) { if(!array_key_exists($photos_uploaded['type'][$counter], $known_photo_types)) { $result_final .= "File ".($counter+1)." is not a photo<br />"; } else { mysql_query( "INSERT INTO gallery_photos(`photo_filename`, `photo_caption`, `photo_category`) VALUES('0', '".addslashes($photo_caption[$counter])."', '".addslashes($_POST['category'])."')" ); $new_id = mysql_insert_id(); $filetype = $photos_uploaded['type'][$counter]; $extention = $known_photo_types[$filetype]; $filename = $new_id.".".$extention; mysql_query( "UPDATE gallery_photos SET photo_filename='".addslashes($filename)."' WHERE photo_id='".addslashes($new_id)."'" ); // Store the orignal file copy($photos_uploaded['tmp_name'][$counter], $images_dir."/".$filename); // Let's get the Thumbnail size $size = GetImageSize( $images_dir."/".$filename ); if($size[0] > $size[1]) { $thumbnail_width = 100; $thumbnail_height = (int)(100 * $size[1] / $size[0]); } else { $thumbnail_width = (int)(100 * $size[0] / $size[1]); $thumbnail_height = 100; } // Build Thumbnail with GD 1.x.x, you can use the other described methods too $function_suffix = $gd_function_suffix[$filetype]; $function_to_read = "ImageCreateFrom".$function_suffix; $function_to_write = "Image".$function_suffix; // Read the source file $source_handle = $function_to_read ( $images_dir."/".$filename ); if($source_handle) { // Let's create an blank image for the thumbnail $destination_handle = ImageCreate ( $thumbnail_width, $thumbnail_height ); // Now we resize it ImageCopyResized( $destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1] ); } // Let's save the thumbnail $function_to_write( $destination_handle, $images_dir."/tb_".$filename ); ImageDestroy($destination_handle ); // $result_final .= "<img src='".$images_dir. "/tb_".$filename."' /> File ".($counter+1)." Added<br />"; } } $counter++; } // Print Result echo <<<__HTML_END <html> <head> <title>Photos uploaded</title> </head> <body> $result_final </body> </html> __HTML_END; ?> This is the "viewgallery.php" to see the gallery: <?php include("config.inc.php"); // initialization $result_array = array(); $counter = 0; $cid = (int)($_GET['cid']); $pid = (int)($_GET['pid']); // Category Listing if( empty($cid) && empty($pid) ) { $number_of_categories_in_row = 4; $result = mysql_query( "SELECT c.category_id,c.category_name,COUNT(photo_id) FROM gallery_category as c LEFT JOIN gallery_photos as p ON p.photo_category = c.category_id GROUP BY c.category_id" ); while( $row = mysql_fetch_array( $result ) ) { $result_array[] = "<a href='viewgallery.php?cid=".$row[0]."'>".$row[1]."</a> "."(".$row[2].")"; } mysql_free_result( $result ); $result_final = "<tr>\n"; foreach($result_array as $category_link) { if($counter == $number_of_categories_in_row) { $counter = 1; $result_final .= "\n</tr>\n<tr>\n"; } else $counter++; $result_final .= "\t<td>".$category_link."</td>\n"; } if($counter) { if($number_of_categories_in_row-$counter) $result_final .= "\t<td colspan='".($number_of_categories_in_row-$counter)."'> </td>\n"; $result_final .= "</tr>"; } } // Thumbnail Listing else if( $cid && empty( $pid ) ) { $number_of_thumbs_in_row = 5; $result = mysql_query( "SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."'" ); $nr = mysql_num_rows( $result ); if( empty( $nr ) ) { $result_final = "\t<tr><td>No Category found</td></tr>\n"; } else { while( $row = mysql_fetch_array( $result ) ) { $result_array[] = "<a href='viewgallery.php?cid=$cid&pid=".$row[0]."'><img src='".$images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' /></a>"; } mysql_free_result( $result ); $result_final = "<tr>\n"; foreach($result_array as $thumbnail_link) { if($counter == $number_of_thumbs_in_row) { $counter = 1; $result_final .= "\n</tr>\n<tr>\n"; } else $counter++; $result_final .= "\t<td>".$thumbnail_link."</td>\n"; } if($counter) { if($number_of_photos_in_row-$counter) $result_final .= "\t<td colspan='".($number_of_photos_in_row-$counter)."'> </td>\n"; $result_final .= "</tr>"; } } } // Full Size View of Photo else if( $pid ) { $result = mysql_query( "SELECT photo_caption,photo_filename FROM gallery_photos WHERE photo_id='".addslashes($pid)."'" ); list($photo_caption, $photo_filename) = mysql_fetch_array( $result ); $nr = mysql_num_rows( $result ); mysql_free_result( $result ); if( empty( $nr ) ) { $result_final = "\t<tr><td>No Photo found</td></tr>\n"; } else { $result = mysql_query( "SELECT category_name FROM gallery_category WHERE category_id='".addslashes($cid)."'" ); list($category_name) = mysql_fetch_array( $result ); mysql_free_result( $result ); $result_final .= "<tr>\n\t<td> <a href='viewgallery.php'>Categories</a> > <a href='viewgallery.php?cid=$cid'>$category_name</a></td>\n</tr>\n"; $result_final .= "<tr>\n\t<td align='center'> <br /> <img src='".$images_dir."/".$photo_filename."' border='0' alt='".$photo_caption."' /> <br /> $photo_caption </td> </tr>"; } } // Final Output echo <<<__HTML_END <html> <head> <title>Gallery View</title> </head> <body> <table width='100%' border='0' align='center' style='width: 100%;'> $result_final </table> </body> </html> __HTML_END; ?> So, can you show me how to make it dynamic, *OR* Is there a better way to do this? I am open to ideas. Thanks.
  4. Hello: What text editor can I use to edit an SQLLite file? I have tried NotePad and WordPad but they seem to then not allow the database to work. I just need to replace a misspelled word in the file >> "Edit / Replace" type of feature. Any ideas?
  5. Hi. Thanks for the reply. I know they are the functions, but i dont quite understand what page to add them too, how to call them, do i need to add more code or pages, etc. Hoping for some direction. Do you have any examples of what you mean? Thanks!
  6. Hi: I found this photo gallery tutorial online: http://www.sitepoint.com/php-gallery-system-minutes/ I uploaded it and it works really well, but I'm stumped on how to add the functions listed at the bottom of the tutorial. I want to be able to add, edit, and delete Categories and Photos. It has the code to do it, but it doesn't give and examples. Can someone show me how to make them work? I really do not understand where to add them, if I need to make new pages, etc. Any insight would be great!
  7. Sorry, I mean I did it like this: RewriteEngine on rewritecond %{http_host} ^mysite.com [nc] rewritecond %{http_host} ^www.mysite.com [nc] rewritecond %{http_host} ^http://www.mysite.com [nc] rewriterule ^(.*)$ https://www.mysite.com/$1 [r=301,nc] The other was was NOT working. Should I just hardcode the "https" into the navigation? <a href="https://www.mysite.com/about.htm">About</a> ?? I just thought there was a way to change it everywhere via an .htaccess file. Thanks! Any ideas how to fix this?
  8. Hello: Thanks for the post and the link. This is the one I think I need to use: RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$ RewriteRule ^(.+)$ - [env=askapache:%2] # redirect urls with index.html to folder RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/ RewriteRule ^(([^/]+/)*)index\.html$ http%{ENV:askapache}://%{HTTP_HOST}/$1 [R=301,L] # change // to / RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)//(.*)\ HTTP/ [NC] RewriteRule ^.*$ http%{ENV:askapache}://%{HTTP_HOST}/%1/%2 [R=301,L] I want to go from HTTP to HTTPS for all the pages, but not sure I'm following how to do it. Do I need to make a new "RewriteCond/RewriteRule" for every page? I am currently doing this: RewriteEngine on rewritecond %{http_host} ^mysite.com [nc] rewriterule ^(.*)$ https://www.mysite.com/$1 [r=301,nc] rewritecond %{http_host} ^www.mysite.com [nc] rewriterule ^(.*)$ https://www.mysite.com/$1 [r=301,nc] rewritecond %{http_host} ^http://www.mysite.com [nc] rewriterule ^(.*)$ https://www.mysite.com/$1 [r=301,nc] rewritecond %{http_host} ^http://www.mysite.com/about.htm [nc] rewriterule ^(.*)$ https://www.mysite.com/about.htm$1 [r=301,nc] It is working, but isn't there a more streamlined way to change it? Sorry, but I'm not to certain how to do mod rewrites like this. I appreciate the help.
  9. Hello: I'm trying to redirect my current site to point to the secure site, and am having a problem getting it to work for all instances. I currently have this: .htaccess RewriteEngine on RewriteRule ^$ https://www.mysite.com/index.htm This works fine when using the URLs "www.mysite.com" and "http://www.mysite.com" But when I enter "mysite.com" it directs to something like "https://www.mysite.com/www.mysite.com" which is incorrect. Also, if I enter a URL like "http://www.mysite.com/about.htm" it does not direct to "https" What is the trick to always have the "https" no matter what URL is entered? Any help would be great. Thanks!
  10. Oh .. OK, got it .. let me play around with it and see how I do .. Thanks!
  11. Hi: There are a lot of examples there .. which one do you think would work best with how my file is set-up?
  12. OK, so my "CheckLongin.php" page should look like this: : <? session_start(); isset($_SESSION[$myUserName]); { header("location:Login.php"); exit; }?> <html> ... ... </html> ?? One other thing - how do I do it so the session will timeout after 20 minutes on being inactice? Do I add it to the code listed above? Thanks!
  13. Hi again: 1st - so I should set my session code like this: <? session_start(); //if(!session_is_registered("myUserName")) isset($_SESSION[$myUserName]); { header("location:Login.php"); }?> <html> ... ... </html> Just in that file or in the other file? Wasn't sure about that. MD5 - maybe I need to change the code to what thorpe posted: $result=mysql_query("select * from myAdmins where myUserName='$myUserName' and myPassword='MD5($myPassword')"); The code was definitely scambled in the database. I insert the "myAdmins" table via phpmyAdmin, and then use the Login.php page for the admin area. I just wanted to know if I'm using the MD5 for the right purpose - in other words does this make logging in more secure? What I can't figure out is if I set a password to "123" and when it is insert into mySQL it becomes "asdagdauihdadGFtyda" (or whatever), how a user can type in "123" and be granted access to to site when the password is clearly not"123"??
  14. Hi: Thanks for the replies. Is there a better or more modern tutorial you can show me? I just want to create something like what I just posted, but if there is a more modern way to do it I would love to learn it. Thanks.
  15. Hi: I was reading a tutorial about making password protected pages and how to make the more secure by using MD5 to encrypt (I think) the password. But. I'm not sure if I don't understand the concept of what it does, or maybe 'm using it wrong. This is the code I am using: Database Table: CREATE TABLE `myAdmins` ( `id` int(4) NOT NULL auto_increment, `myUserName` varchar(65) NOT NULL default '', `myPassword` varchar(65) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; INSERT INTO myAdmins VALUES("1","abc", "123"); I was told in the tutorial to develop something like this (I think I'm doing it wrong): CREATE TABLE `myAdmins` ( `id` int(4) NOT NULL auto_increment, `myUserName` varchar(65) NOT NULL default '', `myPassword` varchar(65) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; INSERT INTO `myAdmins` VALUES(1, 'abc', md5('123')); My Login.php page: <?php include('../include/myConn.php'); session_start(); session_destroy(); $message=""; $Login=$_POST['Login']; if($Login){ $myUserName=$_POST['myUserName']; //$md5_myPassword=md5($_POST['myPassword']); // Encrypt password with md5() function. $myPassword=$_POST['myPassword']; //$result=mysql_query("select * from myAdmins where myUserName='$myUserName' and myPassword='$md5_myPassword'"); $result=mysql_query("select * from myAdmins where myUserName='$myUserName' and myPassword='$myPassword'"); if(mysql_num_rows($result)!='0'){ session_register("myUserName"); header("location:a_Home.php"); exit; }else{ $message="<div class=\"myAdminLoginError\">Incorrect Username or Password</div>"; } } ?> <html> ... </head> <form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>"> <? echo $message; ?> User Name: <input name="myUserName" type="text" id="myUserName" size="40" /> <br /><br /> Password: <input name="myPassword" type="password" id="myPassword" size="40" /> <input name="Login" type="submit" id="Login" value="Login" /> </form> ... </html> Protected Page: <? session_start(); if(!session_is_registered("myUserName")){ header("location:Login.php"); }?> <html> ... ... </html> I know I need to uncomment the 2 lines of code in Login.php and remove the 2 that I'm currently using, and use the Database Table that has the MD5 code, but whenever I do it will not let me login. The Login.php page (with the Database Table without the MD5 code) works fine. I just wanted to know if this is the right way to use MD5 to make logins even more secure, of if I am totally off on understanding it. Any help or code tweaks would be appreciated. Thanks!
  16. Hello: I wanted to learn how to add a file browse/save and send photo to a contact form. Form works fine, but I am trying to add this so a user can upload and send a photo of his or her artwork along with the contact information. Can someone tell me how this work? My other attempts failed so I'm trying to start with a clean form. This is the code I currently have: <?php $error = NULL; $myDate = NULL; $FullName = NULL; $Address = NULL; $City = NULL; $State = NULL; $Zip = NULL; $Phone = NULL; $Email = NULL; $Website = NULL; $Comments = NULL; if(isset($_POST['submit'])) { $myDate = $_POST['myDate']; $FullName = $_POST['FullName']; $Address = $_POST['Address']; $City = $_POST['City']; $State = $_POST['State']; $Zip = $_POST['Zip']; $Phone = $_POST['Phone']; $Email = $_POST['Email']; $Website = $_POST['Website']; $Comments = $_POST['Comments']; if(empty($FullName)) { $error .= '<div style=\'margin-bottom: 6px;\'>- Enter your Name.</div>'; } if(empty($Email) || !preg_match('~^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$~',$Email)) { $error .= '<div style=\'margin-bottom: 6px;\'>- Enter a valid Email.</div>'; } if($error == NULL) { $sql = sprintf("INSERT INTO myContactData(myDate,FullName,Address,City,State,Zip,Phone,Email,Website,Comments) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", mysql_real_escape_string($myDate), mysql_real_escape_string($FullName), mysql_real_escape_string($Address), mysql_real_escape_string($City), mysql_real_escape_string($State), mysql_real_escape_string($Zip), mysql_real_escape_string($Phone), mysql_real_escape_string($Email), mysql_real_escape_string($Website), mysql_real_escape_string($Comments)); if(mysql_query($sql)) { $error .= '<div style=\'margin-bottom: 6px;\'>Thank you for contacting us. We will reply to your inquiry shortly.<br /><br /></div>'; mail( "mt@gmail.com", "Contact Request", "Date Sent: $myDate\n Full Name: $FullName\n Address: $Address\n City: $City\n State: $State\n Zip: $Zip\n Phone: $Phone\n Email: $Email\n Website: $Website\n Comments: $Comments\n", "From: $Email" ); unset($FullName); unset($Address); unset($City); unset($State); unset($Zip); unset($Phone); unset($Email); unset($Website); unset($Comments); } else { $error .= 'There was an error in our Database, please Try again!'; } } } ?> <form name="myform" action="" method="post"> <input type="hidden" name="myDate" size="45" maxlength="50" value="<?php echo date("F j, Y"); ?>" /> <div id="tableFormDiv"> <fieldset><span class="floatLeftFormWidth"><span class="textErrorItalic">* - Required</span></span> <span class="floatFormLeft"> </span></fieldset> <?php echo '<span class="textError">' . $error . '</span>';?> <fieldset><span class="floatLeftFormWidth"><span class="textErrorItalic">*</span> Full Name:</span> <span class="floatFormLeft"><input type="text" name="FullName" size="45" maxlength="50" value="<?php echo $FullName; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Address:</span> <span class="floatFormLeft"><input type="text" name="Address" size="45" maxlength="50" value="<?php echo $Address; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">City:</span> <span class="floatFormLeft"><input type="text" name="City" size="45" maxlength="50" value="<?php echo $City; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">State:</span> <span class="floatFormLeft"><input type="text" name="State" size="45" maxlength="50" value="<?php echo $State; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Zip:</span> <span class="floatFormLeft"><input type="text" name="Zip" size="45" maxlength="50" value="<?php echo $Zip; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Phone:</span> <span class="floatFormLeft"><input type="text" name="Phone" size="45" maxlength="50" value="<?php echo $Phone; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth"><span class="textErrorItalic">*</span> Email:</span> <span class="floatFormLeft"><input type="text" name="Email" size="45" maxlength="50" value="<?php echo $Email; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Website:</span> <span class="floatFormLeft"><input type="text" name="Website" size="45" maxlength="50" value="<?php echo $Website; ?>" /></span></fieldset> <fieldset><span class="floatLeftFormWidth">Comments:</span> <span class="floatFormLeft"><textarea name="Comments" cols="40" rows="10"><?php echo $Comments; ?></textarea></span></fieldset> </div> <input type="submit" name="submit" value="Submit" class="submitButton" /><br /> </form> Thanks very much!
  17. Hi: Thanks for that, but I changed the credentials to "fake" ones before posting I never post that stuff online Any idea what is causing the issue? Maybe because I have tables in the DB that are not in use ??
  18. Hi: I have a script I use to allow the user to make a backup of the database. They click a lick and it goes to the below code, and writes a back-up of the database onto a folder on the server. This is the code: <?php include('../include/myConn.php'); backup_tables('DB credentials removed'); /* backup the db OR just a table */ function backup_tables($host,$user,$pass,$name,$tables = '*') { $link = mysql_connect($host,$user,$pass); mysql_select_db($name,$link); //get all of the tables if($tables == '*') { $tables = array(); $result = mysql_query('SHOW TABLES'); while($row = mysql_fetch_row($result)) { $tables[] = $row[0]; } } else { $tables = is_array($tables) ? $tables : explode(',',$tables); } //cycle through foreach($tables as $table) { $result = mysql_query('SELECT * FROM '.$table); $num_fields = mysql_num_fields($result); $return.= 'DROP TABLE '.$table.';'; $row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table)); $return.= "\n\n".$row2[1].";\n\n"; for ($i = 0; $i < $num_fields; $i++) { while($row = mysql_fetch_row($result)) { $return.= 'INSERT INTO '.$table.' VALUES('; for($j=0; $j<$num_fields; $j++) { $row[$j] = addslashes($row[$j]); $row[$j] = ereg_replace("\n","\\n",$row[$j]); if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; } if ($j<($num_fields-1)) { $return.= ','; } } $return.= ");\n"; } } $return.="\n\n\n"; } //save file //$handle = fopen('db-backup-'.time().'-'.(md5(implode(',',$tables))).'.sql','w+'); $handle = fopen('NLCDBBackUp-'.date("m.d.y").'-'.time().'-'.(md5(implode(',',$tables))).'.sql','w+'); fwrite($handle,$return); fclose($handle); } header ("Location: a_Home.php"); ?> I get this error: Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource in /home/content/64/8119464/html/admin/a_Export.php on line 32 Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/content/64/8119464/html/admin/a_Export.php on line 35 Warning: Cannot modify header information - headers already sent by (output started at /home/content/64/8119464/html/admin/a_Export.php:32) in /home/content/64/8119464/html/admin/a_Export.php on line 68 Line 32: $num_fields = mysql_num_fields($result); Line 35: $row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table)); I'm confuse because on some sites it works fine, while on others it gives me the error. Even with the error it still writes the copy of the database properly, but I would rather not have the error appear. Anyone know why this is happening? Is there a way to suppress the error? Thanks!
  19. I will try renaming as you suggested. So, what is a better approach to this? Got an example? Better place to find tutorials that are more modern?
  20. I can post the code ... but I don't use "register_globals = On" usually .. it's the only way it works for this crappy hosting account they gave me. Login.php: <?php include('../include/myConn.php'); include('../include/myCodeLib.php'); include('include/myAdminNav.php'); ?> <!DOCTYPE HTML> <html> <head> <meta charset="ISO-8859-1" /> <title>Admin Area</title> <?php echo spAdminLinks(); ?> </head> <body> <div id="siteContainer"> <div id="topContainer"> </div> <div id="topMenuContainer"> <div id="topMenu"> </div> </div> <div id="contentContainer"> <div id="mainContent"> <h1>Login Area</h1> <form name="form1" method="post" action="myLogin.php"> <div class="myAdminLoginFloatLeft"> User Name: <br /><br /> Password: </div> <div class="myAdminLoginFloatRight"> <input name="myUserName" type="text" id="myUserName"> <br /><br /> <input name="myPassword" type="password" id="myPassword"> </div> <div style="clear: both; padding-bottom: 20px;"></div> <input type="submit" name="Submit" value="Login"> </form> <br /> <a href="ForgotPassword.php">Forgot Password?</a> </div> <div style="clear: both;"></div> </div> <div id="footerContainer"> <?php echo spAdminFooter(); ?> </div> </div> </body> </html> myLogin.php <?php include('../include/myConn.php'); include('../include/myCodeLib.php'); include('include/myAdminNav.php'); ob_start(); $myUserName=$_POST['myUserName']; $myPassword=$_POST['myPassword']; $myUserName = stripslashes($myUserName); $myPassword = stripslashes($myPassword); $myUserName = mysql_real_escape_string($myUserName); $myPassword = mysql_real_escape_string($myPassword); $sql="SELECT * FROM myAdmins WHERE myUserName='$myUserName' and myPassword='$myPassword'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ session_register("myUserName"); session_register("myPassword"); header("location:a_Home.php"); } else { echo " <!DOCTYPE HTML> <html> <head> <meta charset=\"ISO-8859-1\" /> <meta http-equiv=\"refresh\" content=\"5;url='Login.php'\"> <title>Admin Area</title> ". spAdminLinks() ." </head> <body> <div id=\"siteContainer\"> <div id=\"topContainer\"> </div> <div id=\"topMenuContainer\"> <div id=\"topMenu\"> </div> </div> <div id=\"contentContainer\"> <div id=\"mainContent\"> <h1>Incorrect User Name or Password.</h1> <p>You will now be re-directed back to the login area to try again, or <a href=\"Login.php\">click here</a>.</p> </div> <div style=\"clear: both;\"></div> </div> <div id=\"footerContainer\"> ". spAdminFooter() ." </div> </div> </body> </html> "; } ob_end_flush(); ?> a_Home.php: <?php include('include/myCheckLogin.php'); ?> <html> ...STUFF... </html> myCheckLogin.php: <? session_start(); if(!session_is_registered(myUserName)){ header("location:Login.php"); } ?> mySQL "Admins" TABLE: -- -- Table structure for table `myAdmins` -- CREATE TABLE `myAdmins` ( `id` int(4) NOT NULL auto_increment, `myUserName` varchar(65) NOT NULL default '', `myPassword` varchar(65) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; -- -- Dumping data for table `myAdmins` -- INSERT INTO `myAdmins` VALUES (1, 'abc', 'abc'); My first login script .. How can I slim this down to do the same thing, but use less code AND make it more secure? Also, how do I set a "timeout" so if the page is in active for 20 minutes it will push the user back to the Login.php page? Thanks for the help.
  21. Odd .. but I just added a PHP.INI file to the ROOT, htdocs, and the "admin" folder. And it works! All the PHP.INI file has is: register_globals = On There must be a reason for it ... Right ... ??
  22. I did .. I made a new DB .. but it's the same code as the others .. very odd .. I don't know why it's an issue ??
  23. Well, the GoDaddy accounts have a PHP.INI file already installed: register_globals = off allow_url_fopen = off expose_php = Off max_input_time = 60 variables_order = "EGPCS" extension_dir = ./ upload_tmp_dir = /tmp precision = 12 SMTP = relay-hosting.secureserver.net url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset=" ; Only uncomment zend optimizer lines if your application requires Zend Optimizer support ;[Zend] ;zend_optimizer.optimization_level=15 ;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3 ;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3 ;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/ZendExtensionManager.so ;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/ZendExtensionManager_TS.so ; -- Be very careful to not to disable a function which might be needed! ; -- Uncomment the following lines to increase the security of your PHP site. ;disable_functions = "highlight_file,ini_alter,ini_restore,openlog,passthru, ; phpinfo, exec, system, dl, fsockopen, set_time_limit, ; popen, proc_open, proc_nice,shell_exec,show_source,symlink" This PowWeb account has no PHP.INI file at all .. I tried uploading the above file but it didn't work .. It has a myPhpAdmin area - do I need to enable something there? All the files are the exact same, which is why I'm confused ...
  24. Hello: I have a login form that I have been using successfully on GoDaddy. However, I am making a new site on a hosting platform with PowWeb (I think it's a poor platform) and the login script does not work. It seems like it is not "holding" the session. When I enter the UserName and Password, it keeps kicking me out and back to the Login area. I know I'm using the correct UserName/Password. My question is - do I need to add an .INI file to the host, and add some form of statement to make it "start" the sessions? I know it's not my browsers, as I tested my other sites in FireFox / Chrome, and they work fine. Ideas?
  25. Hi: Thanks for the reply. I have 3 other pages to make the Categories, Edit the Categories, and a page to add a photo and the data for each photo. I'm having trouble trying to use the code I posted to Edit the page data, (photo is edited on a separate page), specifically trying to edit the Category a photo is assigned to. It doesn't seem to "stick" when I select it - it keeps going back to the first one in the list. Any ideas? Better coding example? I've been stuck on this for awhile and am a bit frustrated. Thanks!
×
×
  • 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.