Jump to content

simcoweb

Members
  • Posts

    1,104
  • Joined

  • Last visited

Everything posted by simcoweb

  1. simcoweb

    Fwrite

    You can also use the fopen with the 'a' parameter which appends to the last row. The 'w' mode overwrites the entire file AND appends to the last row.
  2. The simple answer to that would be yes. The complication is that any of them could satisfy the condition. So, kind of like this: IF Option1 is checked - ok IF OPtion1 is NOT checked BUT Option 2 or 3 are checked then - ok IF Option2 is NOT checked BUT Option 1 or 3 are checked then - ok IF Option 3 is NOT checked BUT Option 1 or 2 are checked then - ok Now, another issue. This guy has 1340 options. All named something different. And, 3 - 5 of them could be on one page. What i'm hoping for is some 'universal' scripting that checks each present option regardless of the name. Normally I would assume that the validation has to specify what the option name is in order to check against it. Make sense?
  3. I'm 99% on this one. Take the two commas out of this part (as shown): $where clause = "WHERE order_IN ('"imlpode("','",$arr_orders)"')";
  4. First, thanks for the post! In regards to your question on the quantity box, unfortunately this cart system is really lame. It has no method of determining how many of each item you want. So, IF someone entered 3 in the quantity box and selected Option 1 and Option 2 they'd have to either guess how many of each or call the person to get that info. The way this should have been set up is instead of 3 options it should have been 1 option with 3 choices. Then i'd just validate against that option being selected or not since it would be 'required'. Easy.  Problem is they've set it up with the 3 options for which, technically, ALL of them are required in an 'either-more than one-or all' sense. Each option represents a size of the product ( or some variant ) that, when selected, determines the price added to the cart. As of right now the shopper can click Add To Cart without selecting any of them. Now it's a true guessing game as the item is added to their cart but no $$$ amount! So the goal is to make them select one, or more, of the options prior to it adding anything to the cart. If none is selected then the alert box needs to pop up and point to the issue.
  5. Hey. I have a bit of a challenge in requiring the buyer to select an option prior to adding the item to their cart. The problem lies in the fact there are three separate options. Not one option with three separate choices. But three options with one choice each. But, it's imperative that the buyer select at least one of those options before clicking the Add To Cart button. I can figure out how to force them to select one option with 3 choices. But not the other scenario. So, it's like this: ** Buyer please select one of these options Option 1: 10 oz bottle [checkbox] Option 2: 12 oz bottle [checkbox] Option 3: 15 oz bottle [checkbox] Quantity: [textbox] [Add To Cart Button] Looking for some guidance on this. Thanks!
  6. Ok, gotcha. In regards to the video types...hardly anyone uses those formats anymore on sites showcasing mass amounts of vids. Too big. The .FLV format is taking over. Let's take your concept and break it down a bit. The 'screenshot' for a typical YouTube preview/thumbnail has a location and reference like this: [quote]http://sjl-static6.sjl.youtube.com/vi/JzqumbhfxRo/2.jpg[/quote] Which is a hyperlink pointing to this: [quote]http://www.youtube.com/watch?v=JzqumbhfxRo[/quote] And, if they wanted to embed that video on your site they'd use this link: [quote]<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/JzqumbhfxRo"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/JzqumbhfxRo" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>[/quote] The common ID in all this is the 'JzqumbhfxRo' identifier. I can't think of a way that would strip out all the other characters and isolate or even identify that part of the hyperlink. Some heavy duty use of regular expressions is the only thing I can imagine would work. If your goal is to snag the picture then assuming your 'user' enters the embed code above. You would need to isolate the ID part and then surround it by the necessary code to identify it on their site (which could be totally random as well without a specific pattern) and then somehow copy the file to a folder on your site, make a reference to it for that particular user/video upload. Maybe i'm looking at this wrong but that appears to be the challenge.
  7. I thought of that also but what IF it's not an automated way that he's completing the form? And, even though they have to enter the CAPTCHA code doesn't mean they'd enter a valid email address. Personally, in this case, i'd do both methods. CAPTCHA and the email confirmation.
  8. Honestly it's a little weird to validate their email using a email message/link system just for a contact form. Normally that's done when they register as a member or similar. However, that doesn't mean you can't do it. Here's a link that provides a tutorial on one way to do it: http://www.chauy.com/2006/01/email-activation-in-php/
  9. If i'm understanding your question, if a user doesn't actually upload a video but instead pastes in a link to a video ( like a YouTube link ) then you want to somehow download the video from YouTube into a folder on your site?
  10. If it fails there's no reason to re-execute it unless you fix it. If it works then there's no reason to re-execute it. :)
  11. mgallforever's code is a good example. The 'receiving' page/form needs to grab the code from the URL using the $_GET parameter which then sets the value for the $code variable. Then, in their form code, they populate the field with the variable: [quote]Code: <input type=text name=code value=$code>[/quote] To pass the code you'd need in your form script (in the action="yourscript.php") the command to do that. Probably a 'header' function similar to: [code]<?php header("Location: http://www.theirsite.com/formpage.php?code=54292kg") ?>[/code]
  12. Are you trying to create a security image? As in a CAPTCHA? Where they type in a random code before submitting the form?
  13. Here's some code for creating the .xls file. Works great. Just edit the query info to match the table you want to draw the data from. [code]<?php // next we gather up the tables and find the field count $select = "SELECT * FROM Datafeed";                $export = mysql_query($select); $fields = mysql_num_fields($export); // next we fetch the data in each row for ($i = 0; $i < $fields; $i++) {     $header .= mysql_field_name($export, $i) . "\t"; } // now we extract the data while($row = mysql_fetch_row($export)) {     $line = '';     foreach($row as $value) {                                                    if ((!isset($value)) OR ($value == "")) {             $value = "\t";         } else {             $value = str_replace('"', '""', $value);             $value = '"' . $value . '"' . "\t";         }         $line .= $value;     }     $data .= trim($line)."\n"; } $data = str_replace("\r","",$data); // just in case there is no data in the tables if ($data == "") {     $data = "\n(0) Records Found!\n";                        } // now to download the results and file header("Content-type: application/x-msdownload"); header("Content-Disposition: attachment; filename=extraction.xls"); header("Pragma: no-cache"); header("Expires: 0"); print "$header\n$data"; echo "<center><h2>Done!</h2></center>"; ?>[/code]
  14. Ken, thanks for that fix. Just a footnote, weird how the email I get regarding the post left out the \ in the \n at the end of the string. I copied from the email and pasted it into the script and, of course, everything was on one line. I added the \ and it worked fine...then came to the actual post here to respond and noticed the \ was in place. Just a word of caution to everyone...come to the actual post to get the correct code! One more question if I may. Right now after the file has been written I have it set up where it opens in a browser and they'd have to copy and paste it into a text file. I'd prefer to have this saved as a CSV file they'd download. I've been doing some research on this and most of the stuff is on 'importing' a csv file. NOT creating one. I need this to create a downloadable CSV file with the ',' separator and the fields in " which is what your code changes provide. Now it's the saving as .csv and the download. Ideas?
  15. Ok, cool. Made that change and now it writes. I knew that. Just didn't spot it as the problem. Now, another quick question. Right now it's creating the file with just commas separating the fields. I need to surround the fields in " " 's as well. Is there a quick and easy way to do this?
  16. Ok, i'm not getting any error messages but nothing is writing to the file either. I get a success notice but that doesn't necessarily mean there's data being written. Here's my modified code based upon your edits: [code]<?php // run our query based upon 5 rows of results $sql = "SELECT * FROM Datafeed LIMIT 5"; $results = mysql_query($sql) or die(mysql_error()); $fp = fopen("datafeed-test.txt", 'r') or die("Could not open file.");     if ($fp = fopen("datafeed-test.txt", 'r')) {     while ($row = mysql_fetch_assoc($results)) {         fwrite($fp, "{$row['URL']}, {$row['Product_ID']}, {$row['Product_Name']}, {$row['Price']}, {$row['Sale_Price']}, {$row['Description']}, {$row['Category']}, {$row['Image']}, {$row['Postage']}, {$row['Brand']}, {$row['Availability']}, {$row['Thumbnail']},   {$row['ThumbnailWidth']}, {$row['ThumbnailHeight']}");     }   echo "File written";   echo "<a href='datafeed-test.txt'>Click here</a> to open the file.<br>\n"; } else {   echo "Could not write to file.";   } echo "The file is a simple text file that needs to be saved as Datafeed.csv and uploaded in your administration area at the data upload page. This file is intended to test the accuracy of the datafeed information before uploading the entire product database."; ?>[/code] The 'datafeed-test.txt' file is present AND is writeable (chmod at 777).
  17. :) That's why I ask for guidance! Ok, let me make these changes and report back. Also, is there a way to create a .csv file that is downloadable instead of the way I have it now where it would simply open it?
  18. I need to retrieve data from the same mysql database to create two files in a text/csv format. Basically it's a product database. The first file needs to retrieve the first 5 rows only. The second one needs to retrieve all rows. Here's my code for the 5 row setup: [code]<?php // run our query based upon 5 rows of results $sql = "SELECT * FROM datafeed LIMIT 5 ORDER BY Product_ID"; $results = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_arry($results)) {   $fp = fopen("datafeed-test.txt", 'r') or die("Could not open file.")   if ( $fp = fopen("datafeed-test.txt", 'r'))   {   fwrite($fp, $URL, $Product_ID, $Product_Name, $Price, $Sale_Price, $Description, $Category, $Image, $Postage, $Brand, $Availability, $Thumbnail,   $ThumbnailWidth, $ThumbnailHeight);   echo "File successfully written."; } else {   echo "Could not write to file.";   echo "<a href='datafeed-test.txt'>Click here</a> to open the file.<br>\n"; } } ?>[/code] I'm not 100% sure if my fwrite uses the array variables in order to write the data. Plus, the end result needs to be a csv file so it has to be separated by commas. Need a bit of guidance on this. Thanks!
  19. Ok, cool. That's good to know. Learn a little bit every day :)
  20. DOHHHHHHHHh! Ok, overlooked that in my haste. That's why it's always good to have another set of eyes looking at this stuff. Sometimes the obvious becomes the oblivious. I'll insert the name tags. For this: [quote]Also, pay attention to retrieve $_POST($vars) properly.[/quote] Can you elaboarate on what you mean by that? Thanks for the post!
  21. I have member profiles that I would like them to be able to update from a member control panel link that uses their memberid to summon their data into a prepopulated form. I'm using this method to populate the form fields with their current data. Not sure if this is the right way to do it but it's the way I have working now: MySQL: [quote]$sql = "SELECT * FROM plateau_pros WHERE memberid='$memberid'"; $result = mysql_query($sql, $conn) or die(mysql_error());[/quote] page and form displayed as: [code]<?php while ($a_row = mysql_fetch_array($result)) {   echo "   <form action='updatemember.php' method='POST'>   <table width='95%' border='0' align='center'>   <tr>   <td><font class='bodytext'>First name: </td><td><input type='text' size='30' value='" . $a_row['firstname'] . "'></td>   </tr>   <tr>   <td><font class='bodytext'>Last name: </td><td><input type='text' size='30' value='" . $a_row['lastname'] . "'></td>   </tr>   <tr>   <td><font class='bodytext'>Business name: </td><td><input type='text' size='30' value='" . $a_row['business'] . "'></td>   </tr>   <tr>   <td><font class='bodytext'>Your title: </td><td><input type='text' size='30' value='" . $a_row['title'] . "'></td>   </tr>   <tr>   <td><font class='bodytext'>Address: </td><td><input type='text' size='30' value='" . $a_row['address'] . "'></td>   </tr>   <tr>   <td><font class='bodytext'>City: </td><td><input type='text' size='30' value='" . $a_row['city'] . "'></td>   </tr>   <tr>   <td><font class='bodytext'>Zip code: </td><td><input type='text' size='30' value='" . $a_row['zip'] . "'></td>   </tr>   <tr>   <td><font class='bodytext'>Phone: </td><td><input type='text' size='30' value='" . $a_row['phone'] . "'></td>   </tr>   <tr>   <td><font class='bodytext'>Fax: </td><td><input type='text' size='30' value='" . $a_row['fax'] . "'></td>   </tr>   <tr>   <td><font class='bodytext'>Email: </td><td><input type='text' size='30' value='" . $a_row['email'] . "'></td>   </tr>   <tr>   <td><font class='bodytext'>Details: </td><td><textarea cols='30' rows='5' value=''>" . $a_row['comments'] . "</textarea></td>   </tr>   <tr>   <td><font class='bodytext'>Specialties: </td><td><textarea cols='30' rows='5' value=''>" . $a_row['specialties'] . "</textarea></td>   </tr>   <tr>   <td><input type='submit' value='Update' name='update'></td>   </tr>   </table>   </form>   <p>\n"; ?>[/code] The form gets populated with the current data. They can edit their changes then hit 'Update' button which would then write this query: [code]<?php $sql = "UPDATE plateau_pros SET firstname='$firstname', lastname='$lastname', business='$business', title='$title', address='$address', city='$city', zip='$zip', phone='$phone', fax='$fax', mobile='$mobile', email='$email', comments='$comments', specialties='$specialties' WHERE memberid='$memberid'"; $result = mysql_query($sql, $conn) or die(mysql_error()); ?>[/code] Which, when I [code]<?php echo $result ?>[/code] I get the number '1' which indicates one row has been updated. However, when I check the fields in the MySQL database nothing has been changed or added.
  22. Hang on a sec.. there was an empty line at line #1 causing the headers error. I took it out and all that shows now is: [quote]empty username[/quote]
  23. Oh...heh :) Ok, that one produces this error: [quote]Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home2/wwwplat/public_html/login-mod.php:2) in /home2/xxxxxxxx/public_html/login-mod.php on line 4 empty username[/quote]
  24. I assume that means you want to see the entire code? [code]<?php session_start(); $loginError = ""; // declare this so it is always available // Turn on magic quotes to prevent SQL injection attacks if(!get_magic_quotes_gpc()) set_magic_quotes_runtime(1); // Validate users input if(!empty($_POST)) { // Check username has a value if(empty($_POST['username']))   $loginError['username'] = "Please enter a user name!"; // Check password has a value if(empty($_POST['password']))   $loginError['password'] = "Please enter a password!"; // Check if any errors were returned and run relevant code if(empty($loginError)) { $username = $_POST['username']; $password = $_POST['password']; include 'dbconfig.php'; // Connect to database $con = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname, $con) or die(mysql_error()); // Get Record Set $sql = ("SELECT * FROM plateau_pros  WHERE username = '$username' AND password = '$password'"); // mysql_query($sql) or die(mysql_error()); $results = mysql_query($sql, $con) or die(mysql_error()); $num_rows = mysql_num_rows($results) or die(mysql_error()); if (mysql_num_rows($results) == "1") { $_SESSION['username'] = $_POST['username']; $_SESSION['memberid'] = $_POST['memberid']; header("Location: members.php"); exit; } else { echo "Your user name and password do not match any in our database! Please try again. <a class='body' href='login.php'>Return to login page.<br>\n"; } } } include 'header.php'; ?> <div align="center"> <table style="BORDER-COLLAPSE: collapse" bordercolor="#666666" cellpadding="4" width="530" border="0"> <tbody> <tr> <td>&nbsp; <h2 align="center">Login page</h2> <font color="red"><div align="center"> <? // Loop through all errors if(!empty($loginError)) { ?> <ul> <? foreach($loginError as $eg_message) { ?> <li id="validationError"><?= @$eg_message ?></li> <? } ?> </ul> <? } ?> </font></div> <form action="<? $_SERVER['PHP_SELF'] ?>" name="login" method="post" > <table cellspacing="0" cols="2" cellpadding="0" align="center" border="0"> <tbody> <tr><td>User name:&nbsp;&nbsp;</td><td><input type='text' size='21' name="username" ></td> </tr> <tr> <td>Password:</td><td><input type="password" size="21" name="password"></td> </tr> <tr> <td></td> <td align="right"><br><input type="submit" value="Login"></td> </tr> </tbody> </table> </form> </td></tr> </tbody> </table> </div> <p> <hr width="80%" height="1"> <form action="forgot.php" method="POST" name="forgot"> <table width="450" border="0" align="center"> <tr><td><h2>Forgot Your Password?</h2><br> <font class='bodytext'>If you have forgotten your password complete the form below to have your information sent to you.</font><p> <tr><td><font class="bodytext">Enter your username: <br><input type="text" size="20" name="username" id="username"></td></tr> <tr><td><input type="submit" name="submit" value="Submit"></td></tr> </table> </form> <? include 'footer.php'; ?>[/code]
×
×
  • 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.