Jump to content

spacepoet

Members
  • Posts

    320
  • Joined

  • Last visited

Everything posted by spacepoet

  1. Good point .. I should have been more specific .. When I enter the username and password into the form and hit submit, then form just clears the fields and doesn't "go" anywhere .. Does that make sense?? Thanks for the reply!
  2. Hello: I am getting an error message when I try to use my login page, so I am trying to update it. But, the login page does not work - it seems I am not registering the Session properly. Any idea why? Login.php <?php include('../include/myConn.php'); include('include/myAdminNav.php'); session_start(); session_destroy(); $message=""; $Login=$_POST['Login']; if($Login){ $myUserName=$_POST['myUserName']; $myPassword=$_POST['myPassword']; $result=mysql_query("select * from myAdmins where myUserName='$myUserName' and myPassword='$myPassword'"); if(mysql_num_rows($result)!='0'){ //session_register("myUserName"); $_SESSION['myUserName'] = $myUserName; header("location:a_Home.php"); exit; }else{ $message="<div class=\"myAdminLoginError\">Incorrect Username or Password</div>"; } } ?> <form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>"> ... </form> myCheckLogin.php <? session_start(); //if(!session_is_registered(myUserName)){ if(!$_SESSION['myUserName']); { header("location:Login.php"); } ?> I am stuck on what I am missing .. Thanks!
  3. Excellent! looks like that is the fix. i will give it a shot. thanks much.
  4. Hi: No, that's not it but thanks for the input .. I had it like this: <input type='checkbox' name='myPageActive' value='Yes' <?php if($myPageActive == 'Yes') echo 'checked'; ?>> Yes and it works fine .. It's just when I tried to put it into the IF ELSE statement that it fails ... Any other ideas?
  5. Hi: I am stuck on one little glitch with an IF ELSE statement .. hoping someone with fresh eyes can see what I am missing. The checkbox will not stay checked, and I'm over looking something but fail to see it. <? if ($id != "4" ) { echo "<input type='checkbox' name='myPageActive' value='Yes' <?php if($myPageActive == 'Yes') echo 'checked'; ?>> Yes"; } else { echo "<span class='myDeleteMessage'>Homepage must stay active</span>"; } ?> It seems to have something to do with this part: <?php if($myPageActive == 'Yes') echo 'checked'; ?>> Yes"; Can anyone see what I am missing? Thanks!
  6. Excellent! Works like a charm. Thanks for the tip!
  7. Hello: I have a quick question. I am currently using the following code to replace an apostrophe and quote marks when inserting and updating a database record: $myPageContent = mysql_real_escape_string(str_replace("'", "&#39;", $_POST['myPageContent'])); $myPageContent = mysql_real_escape_string(str_replace("", "&#34;", $_POST['myPageContent'])); My question is - how can I modify it so I only need to use one line. Like (but this does not work): $myPageContent = mysql_real_escape_string(str_replace("'", "&#39;", "", "&#34;", $_POST['myPageContent'])); It seems to me that the way I am currently doing it might be POSTing the data twice? Thanks!
  8. This one: <a href="http://www.mywebsite.com/Promotional.Products-Promotional.Items/Promotional-Products/<?php echo $product_id ?>-<?php echo str_replace(" ", "-", $myTitle) ?>-<?php echo $full_state ?>-Promotional-Products.html" title="<?php echo $myTitle?> <?php echo "$full_state"; ?>"><?php echo $myTitle?></a> However, I believe I know how to fix it, but don't know how to revise the middle RegEx expression. ...-([a-zA-Z]+)-... How do I add "replace spaces with hyphens" to that? I know that is the key to fixing this. Sorry about all the posts, but this is driving me nuts until I figure it out. Thanks!
  9. I know ... i just cant find the answer ....its driving me nuts.... i know it has to do with the regex and adding the the spacrs to hyphens ... im not good with regex ... let me find another forum that deals with javascript ...
  10. Hello: I have this RegEx: ([a-zA-Z]+) I wanted to know how I can also add some code to it to convert all spaces to hyphens. So something like this: 12 Oz Bottle Will look like this: 12-Oz-Bottle Can someone help me ... please ...
  11. It just dawned on me ... i think the middle regex needs to have a replace spaces with hyphens ... i think that will work ... do you know how to write that in??
  12. Hi: Thank you -worked perfectly! However, it did not solve my mod_rewrite issue (I thought it would). Any idea why this: #RewriteRule ^Promotional.Products-Promotional.Items/Promotional-Products/([0-9]+)-([a-zA-Z]+)-([a-zA-Z]+)-Promotional-Products.html$ Promotional.Products-Promotional.Items/Promotional-Products.php?product_id=$1&myTitleDashed=$2&full_state=$3 is not working? It keeps going to my 404 page. It works fine when I am doing: RewriteRule ^Promotional.Products-Promotional.Items/Promotional-Products/([0-9]+)-([a-zA-Z]+)-Promotional-Products.html$ Promotional.Products-Promotional.Items/Promotional-Products.php?product_id=$1&full_state=$2 <?php $query = "SELECT product_id,myTitle FROM myProducts ORDER BY myTitle ASC"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $product_id = stripslashes($row['product_id']); $myTitle = stripslashes($row['myTitle']); ?> <li><a href="http://www.mywebsite.com/Promotional.Products-Promotional.Items/Promotional-Products/<?php echo $product_id ?>-<?php echo $full_state ?>-Promotional-Products.html" title="<?php echo $myTitle?> <?php echo "$full_state"; ?>"><?php echo $myTitle?></a></li> <?php } ?> But when I add the product to it, it keeps failing. It has something to do with the spaces in the product name, because when there is a product with a single word, it goes to the page fine. I thought if I replaced the spaces with hyphens, it would match and I would not have any errors. Any ideas??
  13. Hello: I wanted to see if someone knows how to do a "str_replace" before it's in the link .. This is the code I currently have and it does work, but I want the "str_replace" to take place before it gets added to the link: <?php $query = "SELECT product_id,myTitle FROM myProducts ORDER BY myTitle ASC"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $product_id = stripslashes($row['product_id']); $myTitle = stripslashes($row['myTitle']); ?> <li><a href="http://www.mywebsite.com/Promotional.Products-Promotional.Items/Promotional-Products/<?php echo $product_id ?>-<?php echo str_replace(" ", "-", $myTitle) ?>-<?php echo $full_state ?>-Promotional-Products.html" title="<?php echo $myTitle?> <?php echo "$full_state"; ?>"><?php echo $myTitle?></a></li> <?php } ?> Is there anyway I can make it happen here" $myTitle = stripslashes($row['myTitle']); Everything I have tried has not worked .. Ideas?
  14. Because the mod rewrite fails. i dont know why. so, any idea about the question i just posted or should i try another area of this forum.
  15. Ok...thats a bummer ... however, is there a way to do the "string_replace" on $MyTitlt when it comrs out of the database and not in the href link? that might fix my problem but i cant seem to figure it out.
  16. Hello: I'm doing m first mod_rewrite and it is mostly going well. But, I have one issue I can't see to get right. The products I'm entering in the database have spaces, and I want to replace them with hyphens in the .htaccess file to match what I have replaced in the PHP file. Otherwise, it is not working. This is my PHP file: <?php $query = "SELECT product_id,myTitle FROM myProducts ORDER BY myTitle ASC"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $product_id = stripslashes($row['product_id']); $myTitle = stripslashes($row['myTitle']); ?> <li><a href="http://www.mywebsite.com/Promotional.Products-Promotional.Items/Promotional-Products/<?php echo $product_id ?>-<?php echo str_replace(" ", "-", $myTitle) ?>-<?php echo $full_state ?>-Promotional-Products.html" title="<?php echo $myTitle?> <?php echo "$full_state"; ?>"><?php echo $myTitle?></a></li> <?php } ?> This is the part in the .htacces file where it "matches" the PHP file: RewriteRule ^Promotional.Products-Promotional.Items/Promotional-Products/([0-9]+)-([a-zA-Z]+)-([a-zA-Z]+)-Promotional-Products.html$ Promotional.Products-Promotional.Items/Promotional-Products.php?product_id=$1&myTitle=$2&full_state=$3 (full_state is coming from a variable already on the page, BTW, and works fine) I think I need to somehow tell the middle RegEx ([a-zA-Z]+) to replace the spaces with hyphens. Everything works great otherwise. How can I do this?
  17. Hi: I have a site hosted (shared) on 1and1.com hosting, and they seem to have a file upload limit of 2MB. Is there a way to overwrite this? I have been trying a .htaccess and php.ini file, but can't get it to work. The folder with the upload form is called "admin," in the ROOT of the site. Been trying (in both the ROOT and the "admin" folder): php.ini ; Maximum size of POST data that PHP will accept. post_max_size = 8M ; Maximum allowed size for uploaded files. upload_max_filesize = 8M ini_set('memory_limit','128M'); .htaccess (in both the ROOT and the "admin" folder): php_value memory_limit 24M That is all the code in each file - am I missing some code? Can this be done? Thank you.
  18. Hi: OK - thanks for clarifying! I wanted to make sure I wasn't doing something "wrong" that would cause a problem, or drain the DB resources. Thanks again!
  19. Hello: I wanted to see what might be a better way to select data from 3 tables and display it on one page. I am currently doing this: <?php include("include/db.php"); include('include/myNav.php'); $con = mysql_connect($db_host, $db_user, $db_password); mysql_select_db($db_table); ?> <html> <head></head> <body> <div id="mainBody"> <div id="leftColumn"> <? $query = "SELECT * FROM mySchedule ORDER BY sch_listorder"; $result = mysql_query($query); $num_rows = mysql_num_rows($result); if($num_rows==0) { print ""; } else { print "<h3>". date('Y')." Schedule</h3>"; print "<div style='padding: 10px;'>"; print "<ul>"; for($i=0;$i<$num_rows;$i++) { $row = mysql_fetch_array($result); print "<li id='arrayorder_".$row['sch_id']."'>"; //print $row['photo_caption']; print "<span class='mySideScheduleTitle'>" .$row['sch_player_title']. "</span><br />"; print "<span class='mySideScheduleDate'>Date: " .$row['sch_player_number']. "</span><br />"; print "<span class='mySideScheduleContent'>" .$row['sch_photo_caption']. "</span>"; print "<span class='mySideScheduleContent'>" .$row['sch_years_played']. "</span><div style='clear: both; margin: 0 0 5px 0;'></div>"; print "</li>\n"; print "<hr class='sideBar2' />"; } print "</ul>"; print "</div>"; } ?> <br /><br /> <? $query = "SELECT * FROM myShoutout ORDER BY shout_listorder"; $result = mysql_query($query); $num_rows = mysql_num_rows($result); if($num_rows==0) { print "<h3>No Electronic Shout-Outs</h3>"; } else { print "<h3>". date('Y')." Electronic Shout-Outs</h3>"; print "<marquee scrollamount='2' direction='up'>"; print "<div style='padding: 10px;'>"; print "<ul>"; for($i=0;$i<$num_rows;$i++) { $row = mysql_fetch_array($result); print "<li id='arrayorder_".$row['shout_id']."'>"; //print $row['photo_caption']; print $row['shout_photo_caption']; print "</li>\n"; print "<hr class='sideBar' />"; } print "</ul>"; print "</div>"; print "</marquee>"; } ?> </div> <div id="mainColumn"> <? $query = "SELECT id, photo_filename, player_title, player_number, years_played, photo_caption FROM myRoster ORDER BY listorder"; $result = mysql_query($query); $num_rows = mysql_num_rows($result); if($num_rows==0) { print "<strong>There are currently no players in the database.</strong><br><br>"; } else { print "<table style='border-collapse:collapse' width='100%' cellpadding='4' cellspacing='4'>"; $i=0; for($j=0;$j<$num_rows;$j++) { $row = mysql_fetch_array($result); $id = $row['id']; $photo = $row['photo_filename']; $title = $row['player_title']; if($i==0) print "<tr>"; print "<td valign='bottom' align='center'><a href='rosterPlayer2.php?id=".$id."#myPlayer'>"; if($photo=="") { echo "<img src='uploads/tb_0.gif' border='0' width='100' />"; } else { if(file_exists('uploads/'.$photo)) echo "<img src='uploads/".$photo."?t=".strtotime("now")."' border='0' width='100' />"; else echo "<img src='uploads/tb_0.gif' border='0' width='100' />"; } print "</a><br/><a href='rosterPlayer2.php?id=".$id."#myPlayer'>".$title."</a></td>"; $i++; if($i==4) { $i=0; print "</tr><tr><td colspan='4'> </tr>"; } } print "</table>"; } ?> </div> </div> </body> </html> <? mysql_close($con); ?> It works, but is there a more proper way to do this? Is this where "joining" tables comes into play (I don't know much about that). Thanks.
  20. Hi ... Still no luck ... it is writing 5 blank entries each time, now that I have move the INSERT statement Maybe I should have posted and ask: "How can I revise the current form to do what I want" .. I'm stuck. The form has the option to upload up to 5 photos at once, but I only want to use 1 (I think I need to get rid of the "counter" portion of this code, on the form and the upload page): <?php // initialization $photo_upload_fields = ""; $counter = 1; // default number of fields $number_of_fields = 1; // 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 width='50'> Photo: <td width='550'> <input name='photo_filename[]' id='my_photo' type='file' /> </td> </tr> <tr> <td> Name: </td> <td> <input type='text' name='player_title[]' id='my_player_title' onblur='javascript:myWhite()' size='65' maxlength='65'> </td> </tr> <tr> <td> Number: </td> <td> <input type='text' name='player_number[]' size='10' maxlength='10'> </td> </tr> <tr> <td> Years Played: </td> <td> <input type='text' name='years_played[]' size='10' maxlength='10'> </td> </tr> <tr> <td> Details: </td> <td> <textarea name='photo_caption[]' cols='50' rows='10'></textarea> </td> </tr> __HTML_END; $counter++; } // Final Output echo <<<__HTML_END <form enctype="multipart/form-data" action="a_Photo_Upload.php" method="post" name="upload_form" onsubmit="return validate_form();"> <table width='600' border='0' id='tablepadding' align='center'> <tr style="display: none;"> <td style="display: none;"> Select Category </td> <td style="display: none;"> <select name='category'> $photo_category_list </select> </td> </tr style="display: none;"> <!-Insert the photo fields here --> $photo_upload_fields <tr> <td> <input type='submit' name='submit' value='Add Bio' /> </td> </tr> </table> </form> __HTML_END; ?> And then it goes to the current page I have posted: <?php $result_final = ""; $counter = 0; $known_photo_types = array( 'image/pjpeg' => 'jpg', 'image/jpeg' => 'jpg', 'image/gif' => 'gif', 'image/bmp' => 'bmp', 'image/x-png' => 'png' ); $gd_function_suffix = array( 'image/pjpeg' => 'JPEG', 'image/jpeg' => 'JPEG', 'image/gif' => 'GIF', 'image/bmp' => 'WBMP', 'image/x-png' => 'PNG' ); $photos_uploaded = $_FILES['photo_filename']; $player_title = $_POST['player_title']; $player_number = $_POST['player_number']; $years_played = $_POST['years_played']; $photo_caption = $_POST['photo_caption']; while( $counter <= count($photos_uploaded) ) { mysql_query( "INSERT INTO gallery_photos(`photo_filename`,`player_title`,`player_number`,`years_played`, `photo_caption`, `photo_category`) VALUES('0', '".addslashes($player_title[$counter])."', '".addslashes($player_number[$counter])."' , '".addslashes($years_played[$counter])."', '".addslashes($photo_caption[$counter])."', '".addslashes($_POST['category'])."')" ); 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`,`player_title`,`player_number`,`years_played`, `photo_caption`, `photo_category`) VALUES('0', '".addslashes($player_title[$counter])."', '".addslashes($player_number[$counter])."' , '".addslashes($years_played[$counter])."', '".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)."'" ); copy($photos_uploaded['tmp_name'][$counter], $images_dir."/".$filename); $size = GetImageSize( $images_dir."/".$filename ); if($size[0] > $size[1]) { $old_width = $size[0]; $old_height = $size[1]; $thumbnail_width = 690; $thumbnail_height = ($old_height * $thumbnail_width / $old_width); } else { $thumbnail_width = (int)(690 * $size[0] / $size[1]); $thumbnail_height = 500; } $function_suffix = $gd_function_suffix[$filetype]; $function_to_read = "ImageCreateFrom".$function_suffix; $function_to_write = "Image".$function_suffix; $source_handle = $function_to_read ( $images_dir."/".$filename ); if($source_handle) { $destination_handle = imagecreatetruecolor( $thumbnail_width, $thumbnail_height ); ImageCopyResized( $destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1] ); } $function_to_write( $destination_handle, $images_dir."/tb_".$filename ); ImageDestroy($destination_handle ); $result_final .= "<img src='".$images_dir. "/tb_".$filename."' style='margin-right: 20px; width: 100px;' />"; } } $counter++; } echo <<<__HTML_END $result_final __HTML_END; ?> What would be a better way to do this? I really just want the user to be able to upload 1 photo, player name, years played, number, and bio. I would like to be able to edit/update it as well. Stumped on this one. Any ideas?
  21. Ohhh .. OK, thanks for spotting that. What would be a suggestion to fix it? Thanks for pointing this out - really been stumped on this.
  22. Hi: That's part of the problem - I do not get an error message. If I add just a photo or a photo with 1 or all fields filled-in, it works fine. If I do not add a photo, nothing gets uploaded ... Any ideas? Thanks much.
  23. Well, can you show me 1 tutorial you would recommend that you would consider to be a secure way of doing this? So I can go through it and learn from it .. That's the problem I'm having - everyone's solution is the "best" one until another programmer sees it and says it's "crap." I don't know what direction I am suppose to focus one ..
  24. Hello: I am working with a script that I am using to make a player roster - the user can add a photo, player title, number, years played, and a bio. The data comes from a submit form, then goes to the code below to process everything. It works fine if a photo is added, but if a photo is not added, the script does not work. Any idea why, and how I can fix it? <?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' ); $photos_uploaded = $_FILES['photo_filename']; $player_title = $_POST['player_title']; $player_number = $_POST['player_number']; $years_played = $_POST['years_played']; $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`,`player_title`,`player_number`,`years_played`, `photo_caption`, `photo_category`) VALUES('0', '".addslashes($photo_caption[$counter])."', '".addslashes($_POST['category'])."')" ); mysql_query( "INSERT INTO gallery_photos(`photo_filename`,`player_title`,`player_number`,`years_played`, `photo_caption`, `photo_category`) VALUES('0', '".addslashes($player_title[$counter])."', '".addslashes($player_number[$counter])."' , '".addslashes($years_played[$counter])."', '".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; //} { //$thumbnail_width = 690; //$thumbnail_height = (int)(500 * $size[1] / $size[0]); $old_width = $size[0]; $old_height = $size[1]; $thumbnail_width = 690; $thumbnail_height = ($old_height * $thumbnail_width / $old_width); } else { $thumbnail_width = (int)(690 * $size[0] / $size[1]); $thumbnail_height = 500; } // 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 ); $destination_handle = imagecreatetruecolor( $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."' style='margin-right: 20px; width: 100px;' />"; } } $counter++; } // Print Result echo <<<__HTML_END $result_final __HTML_END; ?> Thanks!
  25. Is there an example you can show me, based upon the code I just posted? I add the table to the database via the phpMyAdmin panel: 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"); And then that's it. Ideas on how to improve what I'm using? 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.